mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
T1: demo/serve.mjs exports check/checkAll/finish — all 48 smokes now assert named facts and exit non-zero on a mismatch or an uncaught in-card exception (verified by breaking the kiosk guard on purpose). Informational values were frozen from a v1.43.1 run and cross-read against the source; timings assert budgets, not exact numbers. T2: new CI job 'smoke' gated on 'frontend', builds a FRESH bundle before running (the committed demo/srv/assets copy is a snapshot) and uploads per-file logs on failure. T3: [auto] now means 'a named failing check exists' and each line names it (43 lines); 72 aspirational markers honestly downgraded to [manual]. Fixed the 'ZERO edit buttons' contradiction (wrong since v1.30.1) and the opening-click line (true again since v1.43.1). Three smokes carried pre-v1.39.0/v1.25 expectations and were testing old behaviour: tap defaults for lights, card-wide tap action, label drag requiring plan mode. DEVELOPMENT.md documents the harness contract.
44 lines
2.7 KiB
JavaScript
44 lines
2.7 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;
|
|
c._setMode('plan'); c._tool = 'opening'; await c.updateComplete;
|
|
const rooms = c._spaceModel().rooms;
|
|
const r = rooms.find((x) => x.id === 'r1');
|
|
const poly = r.poly || [[r.x, r.y], [r.x + r.w, r.y], [r.x + r.w, r.y + r.h], [r.x, r.y + r.h]];
|
|
const wallMid = [(poly[0][0] + poly[1][0]) / 2, (poly[0][1] + poly[1][1]) / 2];
|
|
// 1) курсор возле стены → пунктирный призрак есть
|
|
c._cursorPt = [wallMid[0], wallMid[1] + c._gridPitch * 0.5]; c.requestUpdate(); await c.updateComplete;
|
|
const ghost = sr().querySelector('.opghost');
|
|
out.ghostNearWall = !!ghost;
|
|
if (ghost) {
|
|
const cs = getComputedStyle(ghost);
|
|
out.dashed = cs.strokeDasharray !== 'none' && cs.strokeDasharray !== '';
|
|
// призрак лежит на стене (y координаты концов совпадают с y стены)
|
|
out.onWall = Math.abs(Number(ghost.getAttribute('y1')) - poly[0][1]) < 0.5
|
|
&& Math.abs(Number(ghost.getAttribute('y2')) - poly[0][1]) < 0.5;
|
|
// длина = 90 см в рендер-единицах
|
|
const len = Math.hypot(ghost.getAttribute('x2') - ghost.getAttribute('x1'), ghost.getAttribute('y2') - ghost.getAttribute('y1'));
|
|
out.len90cm = Math.abs(len - c._cmToUnits(90)) < 0.5;
|
|
}
|
|
// 2) курсор далеко от стен → призрака нет
|
|
const center = c._roomCenter(r);
|
|
c._cursorPt = center; c.requestUpdate(); await c.updateComplete;
|
|
out.noGhostFarFromWall = !sr().querySelector('.opghost');
|
|
// 3) в других инструментах призрака нет
|
|
c._tool = 'draw'; c._cursorPt = [wallMid[0], wallMid[1] + 2]; c.requestUpdate(); await c.updateComplete;
|
|
out.noGhostOtherTool = !sr().querySelector('.opghost');
|
|
// 4) над существующим проёмом призрак не рисуется (там клик = редактирование)
|
|
c._serverCfg = { ...c._serverCfg, spaces: c._serverCfg.spaces.map((s) => s.id !== c._space ? s : ({
|
|
...s, openings: [{ id: 'op9', type: 'door', x: wallMid[0] / 1000, y: wallMid[1] / (1000 / (c._curSpaceCfg.aspect || 1)) * (c._curSpaceCfg.aspect ? 1 : 1), angle: 0, length: 0.09 }] })) };
|
|
c._tool = 'opening'; c.requestUpdate(); await c.updateComplete;
|
|
const op = c._openingsR[0];
|
|
c._cursorPt = [op.rx, op.ry]; c.requestUpdate(); await c.updateComplete;
|
|
out.noGhostOverExisting = !sr().querySelector('.opghost');
|
|
return out;
|
|
});
|
|
checkAll(res);
|
|
await finish(browser, res);
|