3388895912
* Add dev/demo login selector for quick user switching When AUTH_DISABLED=true, the app now shows a login selector page that lists staff members and clients from the database. Selecting a user sets a localStorage-based session and sends X-Dev-User-Id header on all API requests. A persistent bottom bar shows the active persona with a "Switch user" link. - API: /api/dev/config (public) and /api/dev/users (auth-disabled only) - API: auth middleware reads X-Dev-User-Id header when auth is disabled - Frontend: DevLoginSelector page, DevSessionIndicator bar - Frontend: fetch interceptor injects X-Dev-User-Id on /api/* calls - Tests: 7 passing (5 nav + 2 dev login) Closes #60 Co-Authored-By: Paperclip <noreply@paperclip.ing> * fix(e2e): seed dev user in localStorage to prevent login redirect E2E tests were failing because the dev login selector redirects to /login when AUTH_DISABLED=true and no dev user is in localStorage. Added a shared Playwright fixture that pre-seeds localStorage with a default dev user before each test. Also rebased onto latest main to resolve merge conflict in App.test.tsx. Co-Authored-By: Paperclip <noreply@paperclip.ing> * 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> --------- Co-authored-by: Groom Book CTO <cto@groombook.app> Co-authored-by: Paperclip <noreply@paperclip.ing>
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { test as base } from "@playwright/test";
|
|
|
|
/**
|
|
* Custom test fixture that bypasses the dev login redirect for E2E tests.
|
|
*
|
|
* 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",
|
|
JSON.stringify({ type: "staff", id: "dev-user", name: "Dev User" })
|
|
);
|
|
});
|
|
await use(page);
|
|
},
|
|
});
|
|
|
|
export { expect } from "@playwright/test";
|