Add dev/demo login selector for quick user switching #62

Merged
ghost merged 3 commits from feat/dev-login-selector into main 2026-03-19 07:35:07 +00:00
5 changed files with 27 additions and 3 deletions
Showing only changes of commit e62343fdd3 - Show all commits
+1 -1
View File
@@ -1,4 +1,4 @@
import { test, expect } from "@playwright/test";
import { test, expect } from "./fixtures.js";
/**
* Booking portal happy-path E2E test.
+1 -1
View File
@@ -1,4 +1,4 @@
import { test, expect } from "@playwright/test";
import { test, expect } from "./fixtures.js";
/**
* Client management E2E tests.
+22
View File
@@ -0,0 +1,22 @@
import { test as base } from "@playwright/test";
/**
* Custom test fixture that seeds a dev user in localStorage before each test.
*
* 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.
*/
export const test = base.extend({
page: async ({ page }, use) => {
await page.addInitScript(() => {
localStorage.setItem(
"dev-user",
JSON.stringify({ type: "staff", id: "dev-user", name: "Dev User" })
);
});
await use(page);
},
});
export { expect } from "@playwright/test";
+1 -1
View File
@@ -1,4 +1,4 @@
import { test, expect } from "@playwright/test";
import { test, expect } from "./fixtures.js";
/**
* Navigation smoke tests — verifies that each page loads without errors.
+2
View File
@@ -5,6 +5,8 @@ const originalFetch = window.fetch;
/**
* Patches global fetch to include X-Dev-User-Id header on API requests
* when a dev user is selected via the login selector.
*
* Intentionally mutates window.fetch — this is dev-only (AUTH_DISABLED=true).
*/
export function installDevFetchInterceptor() {
window.fetch = function (input: RequestInfo | URL, init?: RequestInit) {