2.0 KiB
2.0 KiB
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
# 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(seetest/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 |
Orchestrates dummy + vite + 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.jshonorsRIG_API_TARGETfor the/apiproxy (defaulthttp://localhost:4208), so the rig runs alongside live dev servers on :4208/:4209.- The dummy holds
/api/eventsopen 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/historyandGET /api/article/historydon't exist in the backend yet (frontend already renders empty grids); the collector stores empty fixtures for them.- Capture waits for
#rootcontent > 20 KB with zero[role=progressbar]spinners, plus a settle delay, then hides carets/scrollbars for determinism.