feat v1.39.0: pure light sources toggle on click by default

- resolveTapAction: no explicit action + domain light -> toggle (kettle
  et al. keep info via their non-light primary); explicit choice wins
- device dialog shows the effective default (defaultTap)
- unit tests updated (+1, 106); smoke_light_default_tap.mjs; docs
  same-commit
This commit is contained in:
Matysh
2026-07-23 17:28:38 +03:00
parent 9bfef453db
commit 0522413c48
12 changed files with 89 additions and 22 deletions
+15 -2
View File
@@ -175,8 +175,9 @@ test('icon rules: device_class fallback', () => {
assert.equal(iconFromDeviceClasses([]), null);
});
test('tap action: defaults to info', () => {
assert.equal(resolveTapAction(undefined, undefined, 'light'), 'info');
test('tap action: defaults info everywhere except pure lights (v1.39.0)', () => {
assert.equal(resolveTapAction(undefined, undefined, 'light'), 'toggle'); // лампы кликабельны из коробки
assert.equal(resolveTapAction(undefined, undefined, 'switch'), 'info');
assert.equal(resolveTapAction(null, 'info', 'switch'), 'info');
assert.equal(resolveTapAction(null, 'more-info', 'sensor'), 'more-info');
});
@@ -721,3 +722,15 @@ test('outlineWithout: removes the cut stretch, keeps the rest', () => {
// без вырезов — весь периметр
assert.ok(Math.abs(outlineWithout(sq, []).reduce((a, s) => a + len(s), 0) - 40) < 1e-6);
});
test('resolveTapAction: pure lights toggle by default (v1.39.0)', () => {
assert.equal(resolveTapAction(null, null, 'light'), 'toggle');
assert.equal(resolveTapAction('', undefined, 'light'), 'toggle');
// явный выбор пользователя сильнее дефолта
assert.equal(resolveTapAction('info', null, 'light'), 'info');
// не-световые домены не трогаем
assert.equal(resolveTapAction(null, null, 'switch'), 'info');
assert.equal(resolveTapAction(null, null, 'sensor'), 'info');
// замок никогда
assert.equal(resolveTapAction('toggle', null, 'lock'), 'info');
});