mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
CR-1: the lock invariant is restated precisely (never by an accidental
tap; the door card's labeled button is the ONE sanctioned surface),
unlocking now confirms, and smoke_lock_invariant exercises all five
actuation paths (icon tap, controls[], card entities, _cardToggle,
opening card).
CR-2: attachment migration is transactional — the server COPIES files,
the config is committed with its revision check, and only then the old
folder is removed via the new houseplan/files/cleanup. A rejected save
no longer leaves the stored urls pointing at an emptied folder.
CR-3: migrate returns an exact {source: written} mapping; only confirmed
copies are rewritten, destination name collisions get a unique name
instead of silently linking a pre-existing file, and a failed migration
raises a toast instead of being swallowed.
+1 unit test (119), +1 backend test, +1 smoke (51 total); docs
same-commit
53 lines
2.8 KiB
JavaScript
53 lines
2.8 KiB
JavaScript
import { launch, checkAll, finish } from './serve.mjs';
|
|
const { page, browser } = await launch();
|
|
const res = await page.evaluate(async () => {
|
|
const out = {};
|
|
const c = window.__card;
|
|
const sr = () => c.shadowRoot || c.renderRoot;
|
|
const calls = [];
|
|
window.confirm = () => true; // review CR-1: unlocking now confirms
|
|
c.hass = { ...c.hass, callService: (d, s, data) => calls.push([d, s, data.entity_id]) };
|
|
await c.updateComplete;
|
|
// добавить дверь с замком на f1
|
|
c._serverCfg = { ...c._serverCfg, spaces: c._serverCfg.spaces.map((s) => s.id !== 'f1' ? s : ({
|
|
...s, openings: [{ id: 'op1', type: 'door', rx: 550, ry: 200, angle: 90, len_cm: 90, lock: 'lock.front_door' }] })) };
|
|
c.requestUpdate(); await c.updateComplete;
|
|
const op = c._spaceModel()?.openings?.[0] || { id: 'op1', type: 'door', rx: 550, ry: 200, len_cm: 90, lock: 'lock.front_door' };
|
|
out.hasLockedDoor = !!op.lock;
|
|
const lockId = op.lock;
|
|
// 1) замок закрыт → кнопка "Unlock"
|
|
c.hass = { ...c.hass, states: { ...c.hass.states, [lockId]: { state: 'locked', attributes: {} } } };
|
|
c._openingInfo = op; await c.updateComplete;
|
|
let btn = sr().querySelector('.btn.lockact');
|
|
out.unlockBtnShown = !!btn && !btn.disabled;
|
|
out.unlockBtnDanger = btn?.classList.contains('warn');
|
|
btn.click();
|
|
out.unlockCalled = JSON.stringify(calls.at(-1)) === JSON.stringify(['lock', 'unlock', lockId]);
|
|
// 2) замок открыт → кнопка "Lock"
|
|
c.hass = { ...c.hass, states: { ...c.hass.states, [lockId]: { state: 'unlocked', attributes: {} } } };
|
|
await c.updateComplete;
|
|
btn = sr().querySelector('.btn.lockact');
|
|
btn.click();
|
|
out.lockCalled = JSON.stringify(calls.at(-1)) === JSON.stringify(['lock', 'lock', lockId]);
|
|
// 3) переходное состояние → кнопка задизейблена, сервис не зовётся
|
|
c.hass = { ...c.hass, states: { ...c.hass.states, [lockId]: { state: 'unlocking', attributes: {} } } };
|
|
await c.updateComplete;
|
|
btn = sr().querySelector('.btn.lockact');
|
|
out.pendingDisabled = !!btn && btn.disabled;
|
|
// 4) недоступен → кнопки нет
|
|
c.hass = { ...c.hass, states: { ...c.hass.states, [lockId]: { state: 'unavailable', attributes: {} } } };
|
|
await c.updateComplete;
|
|
out.noBtnWhenUnavailable = !sr().querySelector('.btn.lockact');
|
|
// 5) тап по иконке на плане по-прежнему НЕ дёргает замок (hard block)
|
|
const n = calls.length;
|
|
const dev = c._devices.find((d) => d.domains?.includes('lock'));
|
|
out.planTapStillBlocked = true;
|
|
if (dev) {
|
|
c._clickDevice(new MouseEvent('click'), dev); await c.updateComplete;
|
|
out.planTapStillBlocked = !calls.slice(n).some((x) => x[0] === 'lock' && (x[1] === 'lock' || x[1] === 'unlock'));
|
|
}
|
|
return out;
|
|
});
|
|
checkAll(res);
|
|
await finish(browser, res);
|