mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-15 08:21:16 +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
|
* @playwright/test directly. The `frigateApp` fixture provides a
|
||||||
* fully mocked Frigate frontend ready for interaction.
|
* 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()
|
* CRITICAL: All route/WS handlers are registered before page.goto()
|
||||||
* to prevent AuthProvider from redirecting to login.html.
|
* to prevent AuthProvider from redirecting to login.html.
|
||||||
*/
|
*/
|
||||||
@ -17,6 +22,11 @@ import {
|
|||||||
type ApiMockOverrides,
|
type ApiMockOverrides,
|
||||||
} from "../helpers/api-mocker";
|
} from "../helpers/api-mocker";
|
||||||
import { WsMocker } from "../helpers/ws-mocker";
|
import { WsMocker } from "../helpers/ws-mocker";
|
||||||
|
import {
|
||||||
|
installErrorCollector,
|
||||||
|
type ErrorCollector,
|
||||||
|
} from "./error-collector";
|
||||||
|
import { GLOBAL_ALLOWLIST } from "./error-allowlist";
|
||||||
|
|
||||||
export class FrigateApp {
|
export class FrigateApp {
|
||||||
public api: ApiMocker;
|
public api: ApiMocker;
|
||||||
@ -67,10 +77,32 @@ export class FrigateApp {
|
|||||||
|
|
||||||
type FrigateFixtures = {
|
type FrigateFixtures = {
|
||||||
frigateApp: FrigateApp;
|
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>({
|
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);
|
const app = new FrigateApp(page, testInfo.project.name);
|
||||||
await app.installDefaults();
|
await app.installDefaults();
|
||||||
await use(app);
|
await use(app);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user