Add dev/demo login selector for quick user switching #62
@@ -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