# Web UI visual parity harness The visual gate for the pi2-web-ui-design v0.1.1 port (PLAN §3.3). Two scripts, no new dependencies, no daemon and no `pi`: ``` scripts/ui-mock-server.mjs zero-dependency mock of the daemon's browser surface scripts/ui-shots.mjs Playwright screenshot + assertion matrix scripts/ui-fixtures.mjs the fixture data both of them share ``` The mock answers the exact REST + WS contract the console speaks (`web/src/lib/api.ts`, `web/src/lib/ws.ts`); the shooter drives the **built** console the way a user would, then asserts the invariants a screenshot cannot show. Nothing here patches product code: a red assertion is a finding, not something this harness may fix. ## 1. Prerequisites | Requirement | Why | Check | |---|---|---| | `web/dist/index.html` | the shooter serves the production bundle | `pnpm --dir web build` | | Node ≥ 22 | `node:http`, `crypto`, `fetch` | `node -v` | | Playwright **resolvable** (not a dependency) | browser driver, resolved like `scripts/e2e/ui-e2e.mjs` | `node -e "require('playwright')"` or a mise npm-global install | | Chromium | headless browser | `/usr/bin/google-chrome-stable`, else Playwright's bundled build | Playwright is resolved from `PI2_SHOTS_PLAYWRIGHT_MODULE`, `PI2_E2E_PLAYWRIGHT_MODULE`, `require("playwright")`, then the mise `npm-playwright` install roots. Chrome comes from `PI2_SHOTS_CHROME` / `PI2_E2E_CHROME` / the distro paths. Neither is added to `package.json` — the harness must not change what the daemon ships. ## 2. Usage ```bash # 1. build the UI you want to inspect pnpm --dir web build # 2. full matrix: 4 pages × 3 viewports × light/dark = 24 PNGs + report.json node scripts/ui-shots.mjs --serve-static --round r1 --out /tmp/pi2d-port/shots/r1 # 3. quick matrix: 1440×900 × light/dark = 8 PNGs (fast loop while iterating) node scripts/ui-shots.mjs --serve-static --matrix=quick --round scratch # 4. shoot an already running daemon instead of the mock (real data, real auth) node scripts/ui-shots.mjs --base http://127.0.0.1:7676 --round live ``` | Flag | Default | Meaning | |---|---|---| | `--serve-static` | off | spawn the mock daemon and serve `web/dist` from it | | `--base ` | — | shoot a running daemon; disables spawning and the unpaired check | | `--out ` | `/tmp/pi2d-port/shots/` | where PNGs and `report.json` go | | `--round