Skip to content

Commit 59e7a94

Browse files
fix(e2e): Add missing mock routes and resolve TODOs
Adds mock route handlers for `/api/stats/history`, `/api/event_ids`, and `/api/*/latest.webp` to the Playwright test configuration (`api-mocker.ts`). Fixes the `sub_labels` test regression by adjusting the mock route registration order. Removes corresponding resolved TODO comments from the E2E error allowlist (`error-allowlist.ts`). Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
1 parent 9679268 commit 59e7a94

2 files changed

Lines changed: 19 additions & 28 deletions

File tree

web/e2e/fixtures/error-allowlist.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,6 @@ export const GLOBAL_ALLOWLIST: RegExp[] = [
5656
// Fix: add route handlers for /api/review and /api/review/** in api-mocker.ts.
5757
/500 Internal Server Error.*\/api\/review(\?|\/|$)/,
5858

59-
// TODO(real-bug): /api/stats/history is not mocked; the system page fetches
60-
// it for the detector/process history charts.
61-
// Fix: add route handler for /api/stats/history in api-mocker.ts.
62-
/500 Internal Server Error.*\/api\/stats\/history/,
63-
64-
// TODO(real-bug): /api/event_ids is not mocked; the explore/search page
65-
// fetches it to resolve event IDs for display.
66-
// Fix: add route handler for /api/event_ids in api-mocker.ts.
67-
/500 Internal Server Error.*\/api\/event_ids/,
68-
69-
// TODO(real-bug): /api/sub_labels?split_joined=1 returns 500; the mock
70-
// registers "**/api/sub_labels" which may not match when a query string is
71-
// present, or route registration order causes the catch-all to win first.
72-
// Fix: change the mock route to "**/api/sub_labels**" in api-mocker.ts.
73-
/500 Internal Server Error.*\/api\/sub_labels/,
74-
75-
// TODO(real-bug): MediaMocker handles /api/*/latest.jpg but the app also
76-
// requests /api/*/latest.webp (webp format) for camera snapshots.
77-
// Affects: live.spec.ts, review.spec.ts, auth.spec.ts, navigation.spec.ts.
78-
// Fix: add route handler for /api/*/latest.webp in MediaMocker.install().
79-
/500 Internal Server Error.*\/api\/[^/]+\/latest\.webp/,
80-
/failed: net::ERR_ABORTED.*\/api\/[^/]+\/latest\.webp/,
81-
8259
// -------------------------------------------------------------------------
8360
// Mock infrastructure gap — WebSocket streams.
8461
//

web/e2e/helpers/api-mocker.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export class ApiMocker {
8181
await this.page.route("**/api/stats", (route) =>
8282
route.fulfill({ json: stats }),
8383
);
84+
await this.page.route("**/api/stats/history**", (route) =>
85+
route.fulfill({ json: [] }),
86+
);
8487

8588
// Reviews. The real backend exposes /review (singular) for the main
8689
// list and /review/summary for the summary — the previous plural glob
@@ -113,11 +116,7 @@ export class ApiMocker {
113116
route.fulfill({ json: [] }),
114117
);
115118

116-
// Sub-labels and attributes (for explore filters).
117-
// Use trailing ** so query-string variants (e.g. ?split_joined=1) match.
118-
await this.page.route("**/api/sub_labels**", (route) =>
119-
route.fulfill({ json: [] }),
120-
);
119+
121120
await this.page.route("**/api/labels**", (route) =>
122121
route.fulfill({ json: ["person", "car"] }),
123122
);
@@ -129,6 +128,9 @@ export class ApiMocker {
129128
);
130129

131130
// Events / search
131+
await this.page.route("**/api/event_ids**", (route) =>
132+
route.fulfill({ json: [] }),
133+
);
132134
await this.page.route("**/api/events**", (route) =>
133135
route.fulfill({ json: events }),
134136
);
@@ -222,6 +224,12 @@ export class ApiMocker {
222224
// Fall through to more specific routes for GET requests
223225
return route.fallback();
224226
});
227+
228+
// Sub-labels and attributes (for explore filters).
229+
// Use trailing ** so query-string variants (e.g. ?split_joined=1) match.
230+
await this.page.route("**/api/sub_labels**", (route) =>
231+
route.fulfill({ json: [] }),
232+
);
225233
}
226234
}
227235

@@ -234,6 +242,12 @@ export class MediaMocker {
234242

235243
async install() {
236244
// Camera snapshots
245+
await this.page.route("**/api/*/latest.webp**", (route) =>
246+
route.fulfill({
247+
contentType: "image/webp",
248+
body: PLACEHOLDER_PNG,
249+
}),
250+
);
237251
await this.page.route("**/api/*/latest.jpg**", (route) =>
238252
route.fulfill({
239253
contentType: "image/png",

0 commit comments

Comments
 (0)