fix(e2e): mock /api/dev/config to bypass auth redirect in tests
The fixture now also mocks /api/dev/config to return authDisabled: false, preventing the app from entering the redirect flow during E2E tests. Previously only seeded localStorage, but the async config fetch from the real Docker API was still triggering the redirect check. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
import { test as base } from "@playwright/test";
|
||||
|
||||
/**
|
||||
* Custom test fixture that seeds a dev user in localStorage before each test.
|
||||
* Custom test fixture that bypasses the dev login redirect for E2E tests.
|
||||
*
|
||||
* When AUTH_DISABLED=true, the app redirects to /login if no dev-user is set.
|
||||
* This fixture ensures E2E tests bypass that redirect by pre-selecting a
|
||||
* default staff user.
|
||||
* When AUTH_DISABLED=true, the app fetches /api/dev/config and redirects to
|
||||
* /login if no dev-user is in localStorage. This fixture:
|
||||
* 1. Mocks /api/dev/config to return authDisabled: false
|
||||
* 2. Seeds localStorage with a dev user as a fallback
|
||||
*
|
||||
* This ensures E2E tests render pages directly without the login redirect.
|
||||
*/
|
||||
export const test = base.extend({
|
||||
page: async ({ page }, use) => {
|
||||
// Mock the dev config endpoint so the app skips the auth-disabled redirect
|
||||
await page.route("**/api/dev/config", (route) =>
|
||||
route.fulfill({ json: { authDisabled: false } })
|
||||
);
|
||||
// Seed localStorage as a fallback in case the mock is bypassed
|
||||
await page.addInitScript(() => {
|
||||
localStorage.setItem(
|
||||
"dev-user",
|
||||
|
||||
Reference in New Issue
Block a user