mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-04 05:41:34 +00:00
committed by
claude[bot]
parent
20cd3241c0
commit
ea7803230a
@@ -64,6 +64,23 @@ test('issue 362 makes the whole device package inert only in Background', () =>
|
||||
assert.match(render, /@pointermove=\$\{[\s\S]*this\._mode !== 'view' && this\._mode !== 'devices'/);
|
||||
});
|
||||
|
||||
test('issue 381 consumes an explicit no-op before any action side effect', () => {
|
||||
const card = source('houseplan-card.ts');
|
||||
const click = card.slice(
|
||||
card.indexOf('private _clickDevice('),
|
||||
card.indexOf('private _showUnavailableToggleTargets('),
|
||||
);
|
||||
const stop = click.indexOf('ev.stopPropagation();');
|
||||
const live = click.indexOf('const actionDevice = this._devices.find');
|
||||
const projection = click.indexOf('const action = projectedTapAction(');
|
||||
const noOp = click.indexOf("if (action === 'none') return;");
|
||||
const guard = click.indexOf('const guarded =');
|
||||
const toggle = click.indexOf("if (action === 'toggle')");
|
||||
assert.ok(stop >= 0 && live > stop && projection > live);
|
||||
assert.ok(noOp > projection && guard > noOp && toggle > guard);
|
||||
assert.doesNotMatch(click.slice(projection, noOp), /callService|callWS|_showToast|_infoCard|_startDevicePressFeedback/);
|
||||
});
|
||||
|
||||
test('issue 213 projects opening locks through the compact package layers', () => {
|
||||
const styles = source('styles.ts');
|
||||
const card = source('houseplan-card.ts');
|
||||
|
||||
@@ -83,6 +83,8 @@ test('action projection is universal while persisted legacy/default origins stay
|
||||
assert.equal(projectedTapAction('', 'light'), 'toggle');
|
||||
assert.equal(projectedTapAction(undefined, 'switch'), 'info');
|
||||
assert.equal(projectedTapAction('future-action', 'light'), 'info');
|
||||
assert.equal(projectedTapAction('none', 'light'), 'none');
|
||||
assert.equal(projectedTapAction('none', 'switch'), 'none');
|
||||
assert.equal(toggleOriginOf(device({ tapAction: 'toggle' })), 'explicit-toggle');
|
||||
assert.equal(toggleOriginOf(device({ tapAction: 'cover' })), 'legacy-cover');
|
||||
assert.equal(toggleOriginOf(device({ tapAction: null, primary: 'light.lamp' })), 'default-light');
|
||||
|
||||
+5
-1
@@ -21,7 +21,7 @@ import {
|
||||
openingShoulders, openingEntityReferences, fillColorsOf, lerpColor, roomFillStyle,
|
||||
resolveEffectiveRoomFill, stateIcon, lightColorOf, isAlarmState, parseRoomRef,
|
||||
diffNewDevices, poleOfInaccessibility, runServiceFor, coverMoving,
|
||||
normalizeDeviceDisplay, isAlarmCapable,
|
||||
normalizeDeviceDisplay, isAlarmCapable, TAP_ACTIONS,
|
||||
liveText, liveTextValue, liveTextReference, liveTextToken,
|
||||
hassValue, valueWithUnit, decorTextScale, decorTextLines,
|
||||
LIVE_TEXT_DASH, LIVE_TEXT_VALUE_MAX, DECOR_TEXT_SCALE_MIN, DECOR_TEXT_SCALE_MAX,
|
||||
@@ -31,6 +31,10 @@ import {
|
||||
iconFor, compileIconRules, isValidPattern, iconFromDeviceClasses,
|
||||
} from '../test-build/rules.js';
|
||||
|
||||
test('tap action editor choices keep the canonical order', () => {
|
||||
assert.deepEqual([...TAP_ACTIONS], ['info', 'more-info', 'toggle', 'run', 'none']);
|
||||
});
|
||||
|
||||
test('display normalization and alarm-capable metadata share one contract', () => {
|
||||
assert.equal(normalizeDeviceDisplay(undefined), 'badge');
|
||||
assert.equal(normalizeDeviceDisplay('ripple'), 'icon_ripple');
|
||||
|
||||
Reference in New Issue
Block a user