From d69035f2a7d910dd1f013954c6505381ca07fcfe Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 8 Apr 2026 10:22:12 -0500 Subject: [PATCH] wire error collector into frigateApp fixture --- web/e2e/fixtures/frigate-test.ts | 34 +++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/web/e2e/fixtures/frigate-test.ts b/web/e2e/fixtures/frigate-test.ts index 88a2945d71..1f1aa46eab 100644 --- a/web/e2e/fixtures/frigate-test.ts +++ b/web/e2e/fixtures/frigate-test.ts @@ -6,6 +6,11 @@ * @playwright/test directly. The `frigateApp` fixture provides a * fully mocked Frigate frontend ready for interaction. * + * The fixture also installs the error collector (see error-collector.ts). + * Any console error, page error, or same-origin failed request that is + * not on the global allowlist or the test's `expectedErrors` list will + * fail the test in the fixture's teardown. + * * CRITICAL: All route/WS handlers are registered before page.goto() * to prevent AuthProvider from redirecting to login.html. */ @@ -17,6 +22,11 @@ import { type ApiMockOverrides, } from "../helpers/api-mocker"; import { WsMocker } from "../helpers/ws-mocker"; +import { + installErrorCollector, + type ErrorCollector, +} from "./error-collector"; +import { GLOBAL_ALLOWLIST } from "./error-allowlist"; export class FrigateApp { public api: ApiMocker; @@ -67,10 +77,32 @@ export class FrigateApp { type FrigateFixtures = { frigateApp: FrigateApp; + /** + * Per-test additional allowlist regex patterns. Tests that intentionally + * trigger errors (e.g. error-state tests that hit a mocked 500) declare + * their expected errors here so the collector ignores them. + * + * Default is `[]` — most tests should not need this. + */ + expectedErrors: RegExp[]; + errorCollector: ErrorCollector; }; export const test = base.extend({ - frigateApp: async ({ page }, use, testInfo) => { + expectedErrors: [[], { option: true }], + + errorCollector: async ({ page, expectedErrors }, use) => { + const collector = installErrorCollector(page, [ + ...GLOBAL_ALLOWLIST, + ...expectedErrors, + ]); + await use(collector); + collector.assertClean(); + }, + + frigateApp: async ({ page, errorCollector }, use, testInfo) => { + // Reference the collector so its `use()` runs and teardown fires + void errorCollector; const app = new FrigateApp(page, testInfo.project.name); await app.installDefaults(); await use(app);