# Visual testing rig Dummy backend + frozen fixtures + screenshot reference/compare. No npm deps beyond the repo (uses system Chrome at `/usr/bin/google-chrome`). ## Workflow ```bash # Build reference screenshots from live data (:4208 must run in dashback). # Collects fixtures, then captures 21 routes × 2 viewports into # test/screenshots/reference/ (committed to git). npm run rig:reference # Capture fresh screenshots and compare against reference (all in one). # Fails when > 0.1% of pixels differ; diffs → test/screenshots/diff/ npm run rig:compare ``` ## Viewports - `1920x1200`, `1280x960` (see `test/routes.mjs`) ## Files | File | Role | |---|---| | `test/routes.mjs` | Route + viewport definitions (concrete ids: `ART-000001`, delivery `6`, entity `1`) | | `test/collect.mjs` | Fixture collector (mints JWT via dashback env + signing lib) | | `test/dummyBackend.mjs` | Always-authed stub serving `test/fixtures/snapshot.json` + `images/` | | `test/cdp.mjs` | Zero-dep CDP client (fresh page target per shot, settle wait, PNG capture) | | `test/capture.mjs` | Builds prod bundle, serves via preview + dummy, drives Chrome | | `test/compare.mjs` | Zero-dep PNG decoder + comparator (0.1% tolerance, red diff PNGs) | | `test/fixtures/` | Committed snapshot + binary thumbs (2.5 MiB) | | `test/screenshots/reference/` | Committed reference PNGs (7.5 MiB) | ## Notes - `vite.config.js` honors `RIG_API_TARGET` for the `/api` proxy (default `http://localhost:4208`), so the rig runs alongside live dev servers on :4208/:4209. - The dummy holds `/api/events` open with heartbeats and never emits — fixtures stay frozen. - Mutations (POST/PATCH/PUT/DELETE) echo fixtures so UI actions don't crash mid-run. - `GET /api/history` and `GET /api/article/history` don't exist in the backend yet (frontend already renders empty grids); the collector stores empty fixtures for them. - Capture waits for `#root` content > 20 KB with zero `[role=progressbar]` spinners, plus a settle delay, then hides carets/scrollbars for determinism.