mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-15 00:11:15 +03:00
wire error collector into frigateApp fixture
This commit is contained in:
parent
b93e9df40b
commit
d69035f2a7
@ -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<FrigateFixtures>({
|
||||
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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user