Files
piik/scripts/room-layout/click.js
T
AAA 69bf4c7b81 test(ui): a harness that renders the room's states and measures them against the accepted design
The room layout is accepted by measurement. drive.mjs renders named states of the room preview in a Chrome that listens for remote debugging and records the edges of each main element; align.mjs checks the grid; compare.mjs compares a run with reference-edges.json, the settled prototype.

With it: the integrated shell at 945db7f4 is not accepted, two tests fail on that line after cef99882, and the voice shortcut proposal is revised.
2026-11-26 04:47:30 -05:00

6 lines
805 B
JavaScript

// usage: CLICK("name", index) — clicks visible element whose accessible name equals or starts with name
window.__click = (n, i = 0, exact = false) => { const name = e => (e.getAttribute('aria-label') || e.getAttribute('title') || e.innerText || '').replace(/\s+/g, ' ').trim();
const all = [...document.querySelectorAll('button,a[href],[role=button],[role=menuitem],[role=menuitemradio],[role=menuitemcheckbox],[role=tab],[role=option],label,summary')].filter(e => { const r = e.getBoundingClientRect(); return r.width > 0 && r.height > 0; });
const m = all.filter(e => exact ? name(e) === n : name(e) === n || name(e).startsWith(n));
if (!m[i]) return 'NOTFOUND ' + n + ' (' + m.length + ')'; m[i].scrollIntoView({block:'nearest'}); m[i].click(); return 'clicked ' + name(m[i]).slice(0, 40); };