Add dev/demo login selector for quick user switching #62
@@ -1,14 +1,22 @@
|
|||||||
import { test as base } from "@playwright/test";
|
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.
|
* When AUTH_DISABLED=true, the app fetches /api/dev/config and redirects to
|
||||||
* This fixture ensures E2E tests bypass that redirect by pre-selecting a
|
* /login if no dev-user is in localStorage. This fixture:
|
||||||
* default staff user.
|
* 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({
|
export const test = base.extend({
|
||||||
page: async ({ page }, use) => {
|
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(() => {
|
await page.addInitScript(() => {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"dev-user",
|
"dev-user",
|
||||||
|
|||||||
Reference in New Issue
Block a user