Tests and checks
The tests follow the data: the search, grouping and OCR decoding are pure functions, so they are tested without a browser. The interface has Playwright tests for the paths a person actually takes.
Unit tests
bun test runs the *.test.ts files beside the code.
| File | Covers |
|---|---|
src/lib/plates.test.ts |
Normalising, UK grouping, private plates, partial matches, confidence |
src/lib/sightings.test.ts |
Grouping, sorting, time ranges, relative and absolute labels |
src/lib/seo.test.ts |
Canonical paths, absolute URLs, page titles |
src/lib/docs/paths.test.ts |
Doc routes, sections and relative Markdown links |
src/lib/vision/decode.test.ts |
OCR slot decoding, pad handling, region head, strict confidence |
src/lib/vision/detect.test.ts |
Raw and end-to-end YOLO26 decoding, NMS, letterbox mapping |
src/lib/vision/models.test.ts |
The Nano catalogue, the retired-tier fallback, sizes and URLs |
src/lib/vision/scan-plan.test.ts |
Adaptive/fixed look gaps, region-read gating and old-setting fallback |
src/lib/vision/video-scan.test.ts |
Video sampling, plate grouping, time labels |
src/lib/vision/consensus.test.ts |
Temporal voting, length preference, confirmation thresholds, provisional reads |
src/lib/vision/area.test.ts |
Viewport: clamping, the whole-picture case, share and label |
src/lib/capture.test.ts |
Capture presets: ordering, hints, bitrate, fallbacks |
src/lib/vehicle.test.ts |
DVLA reply parsing, MOT/tax flags, summaries, freshness |
src/lib/vehicle-server.test.ts |
The lookup endpoint: no key, bad body, forwarding, reduced reply |
src/lib/trips.test.ts |
GPS distance, stationary-point suppression, duration and map projection |
src/lib/movement.test.ts |
Credible movement and standstill, drift, stale fixes and the journey boundary |
Loop recording is covered in src/lib/clips.test.ts: an hour of one-minute segments keeps
exactly the newest files, the newest is never pruned for size, the kept clips fit the megabyte
budget, an unreadable timestamp is not deleted for its age, and equal start times prune stably.
The time tests build their fixtures on the reader’s own clock so they pass in any timezone.
decodeOcr, decodeDetections and buildConsensus are tested with synthetic model output, and
scanDue with invented clocks; the real ONNX models are not run in unit tests. The camera loop
was checked by hand in Chromium against a fake camera, which proves the start, mode swap and stop
paths but says nothing about speed.
Browser tests
bun run test:e2e runs Playwright against a dev server (bun --bun astro dev --host 127.0.0.1). The suite covers:
- the setup wizard on first run, and skipping it;
- plain-language Settings with no model names and a centred sheet;
- the empty real app, and
/demowith its example data and confirmation back to/app; - the Clips tab and its empty state;
- timeline colouring, road names, and Back keeping the map in place;
- focus moving to the new heading, and Settings locking the page behind it;
- creating a vault, locking it, rejecting a wrong password and unlocking again after a reload;
- clip search by plate, the slash shortcut and the clip page metadata;
- saving a plate from a clip and the Saved-plates filter;
- the home search deep link into the demo;
- the mobile navigation and Settings;
- the Timeline map and its location opt-in.
It runs on a desktop and a Pixel 7 profile. It does not require a camera or run the ONNX models. A separate local check uses a fake camera, a Playwright geolocation override and Timeline to verify live coordinates, route projection and distance.
Motion needs a phone: desktop browsers expose DeviceMotionEvent but fire no sensor data. To check
it, turn on Settings → Motion, start the dashcam, drive a corner, then open Timeline and
confirm the rail shows a peak turn and a peak jolt for the drive. On iPhone the browser asks for
motion access when you flip the switch; if it was refused, the setting stays off and says why.
Testing the camera locally
Chromium can use a fake camera fed from a Y4M file:
ffmpeg -loop 1 -i plate.jpg -vf "scale=640:-2,fps=8" -t 8 \
-pix_fmt yuv420p -f yuv4mpegpipe plate.y4m
Launch Chromium with:
--use-fake-ui-for-media-stream
--use-fake-device-for-media-stream
--use-file-for-fake-video-capture=/absolute/path/plate.y4m
Then press Start recording in /app. The plate should be read, a sighting should appear in
the dock, and after pausing the one-minute segment should be saved and available in Clips.
Screen share as a test camera
Settings → Camera and recording → Use screen share calls getDisplayMedia and uses the
selected tab or window as the camera. This is useful for a repeatable test: play a YouTube video
with a plate in another tab, choose that tab when the browser asks, and press Start recording.
The scanning and recording pipeline is unchanged. Screen sharing requires HTTPS or localhost.
The shared surface is processed locally like the camera; the browser’s own sharing indicator stays visible. Stopping the share ends the scan cleanly.
Unit tests worth knowing
src/lib/clips.test.ts— which clips the storage limits remove, and the byte totals.src/lib/demo.test.ts— the demo dataset: seven routes, stills, motion and one clip.src/lib/preferences.test.ts— clamping typed or stored limits.src/lib/motion.test.ts— the motion summary and its formatting.src/lib/route.test.ts— speed, G-force and cornering bands, and run merging.src/lib/clip-search.test.ts— clip summaries and plate/road/time search.src/lib/vault.test.ts— vault creation, wrong password, media/JSON round-trip, tampering and the encrypted file container.src/lib/journey.test.ts— manifests, legs, merging without losing pruned media, telemetry and tags.src/lib/clips.test.ts— the retention limits (including media that no longer exists).src/lib/geocode.test.ts— road-name extraction and drive names.
Other gates
bun run lint— oxlint.bun run typecheck:tests— TypeScript over the tests and scripts.bun run check— Astro’s type check over pages and components.bun run build— a full static build; broken content collection entries fail here.
Not covered
There is no OCR accuracy benchmark, no long-drive recording test and no evidence-export test, because the export writer is not implemented. The model files are large; CI runs the unit and browser tests but not the ONNX models.