From 8b3e21703ded458757bb0d2ddb1a56e6d3337aca Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Tue, 21 Apr 2026 16:36:55 -0500 Subject: [PATCH] add mock data --- web/e2e/fixtures/mock-data/debug-replay.ts | 54 ++++++++++++++++++++++ web/e2e/fixtures/mock-data/faces.ts | 45 ++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 web/e2e/fixtures/mock-data/debug-replay.ts create mode 100644 web/e2e/fixtures/mock-data/faces.ts diff --git a/web/e2e/fixtures/mock-data/debug-replay.ts b/web/e2e/fixtures/mock-data/debug-replay.ts new file mode 100644 index 0000000000..9b9d2c650d --- /dev/null +++ b/web/e2e/fixtures/mock-data/debug-replay.ts @@ -0,0 +1,54 @@ +/** + * Debug replay status factory. + * + * The Replay page polls /api/debug_replay/status every 1s via SWR. + * The no-session state shows an empty state; the active state + * renders the live camera image + debug toggles + objects/messages + * tabs. Used by replay.spec.ts. + */ + +export type DebugReplayStatus = { + active: boolean; + replay_camera: string | null; + source_camera: string | null; + start_time: number | null; + end_time: number | null; + live_ready: boolean; +}; + +export function noSessionStatus(): DebugReplayStatus { + return { + active: false, + replay_camera: null, + source_camera: null, + start_time: null, + end_time: null, + live_ready: false, + }; +} + +export function activeSessionStatus( + opts: { + camera?: string; + sourceCamera?: string; + startTime?: number; + endTime?: number; + liveReady?: boolean; + } = {}, +): DebugReplayStatus { + const { + camera = "front_door", + sourceCamera = "front_door", + startTime = Date.now() / 1000 - 3600, + endTime = Date.now() / 1000 - 1800, + liveReady = true, + } = opts; + return { + active: true, + replay_camera: camera, + source_camera: sourceCamera, + start_time: startTime, + end_time: endTime, + live_ready: liveReady, + }; +} diff --git a/web/e2e/fixtures/mock-data/faces.ts b/web/e2e/fixtures/mock-data/faces.ts new file mode 100644 index 0000000000..ed2f944cb1 --- /dev/null +++ b/web/e2e/fixtures/mock-data/faces.ts @@ -0,0 +1,45 @@ +/** + * Face library factories. + * + * The /api/faces endpoint returns a record keyed by collection name + * with the list of face image filenames. Grouped training attempts + * live under the "train" key with filenames of the form + * `${event_id}-${timestamp}-${label}-${score}.webp`. + * + * Used by face-library.spec.ts and chat.spec.ts (attachment chip). + */ + +export type FacesMock = Record; + +export function basicFacesMock(): FacesMock { + return { + alice: ["alice-1.webp", "alice-2.webp"], + bob: ["bob-1.webp"], + charlie: ["charlie-1.webp"], + }; +} + +export function emptyFacesMock(): FacesMock { + return {}; +} + +/** + * Adds a grouped recent-recognition training attempt to an existing + * faces mock. The grouping key on the backend is the event id — so + * images with the same event-id prefix render as one dialog-able card. + */ +export function withGroupedTrainingAttempt( + base: FacesMock, + opts: { + eventId: string; + attempts: Array<{ timestamp: number; label: string; score: number }>; + }, +): FacesMock { + const trainImages = opts.attempts.map( + (a) => `${opts.eventId}-${a.timestamp}-${a.label}-${a.score}.webp`, + ); + return { + ...base, + train: [...(base.train ?? []), ...trainImages], + }; +}