cameras/test/camera-routes.ts
Michael Mainguy 4931c3af83 Reach 99.8% test coverage and enforce a 95% floor
- Route tests for camera info, snapshot and credentials (vrek
  iss-nc2tj7c): input validation, store-only-after-verify, reconnects
  after login changes, and fixed error messages with no upstream text.
- Providers and layout tests (iss-nc5w0j8).
- Discovery tests for onvif.ts (iss-3bg4r6e): multicast parsing,
  unicast sweep batching and subnet limits, de-duplication and
  merging. They run on a fake network, replacing onvif Discovery,
  node:dgram and node:os, per new vrek principle pri-e14bahk
  (replaceable transport; tests never touch the real network).
- coverage.thresholds.lines = 95, so `npm run coverage` fails below
  the goal (iss-zjpc22k).

200 tests, 99.77% line coverage. Refreshes the vrek export.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 09:17:55 -05:00

22 lines
721 B
TypeScript

import type { CameraRecord } from "@/lib/camera-registry";
/** Shared fixtures for the /api/cameras/[id]/* route tests. */
export const ID = "11111111-2222-3333-4444-555555555555";
export const record: CameraRecord = {
id: ID,
urn: `urn:uuid:${ID}`,
host: "192.168.1.10",
port: 80,
lastSeen: "2026-09-19T00:00:00.000Z",
};
export const target = { id: ID, host: "192.168.1.10", port: 80 };
export const ctx = (id = ID) => ({ params: Promise.resolve({ id }) });
export const url = (path: string) => `http://localhost/api/cameras/${ID}/${path}`;
/** An upstream error message that must never reach the client. */
export const LEAKY = "SOAP fault from http://admin:hunter2@192.168.1.10/onvif/device_service";