E2E tests: add login and impersonation test coverage (GRO-77)

- apps/e2e/tests/login.spec.ts: 8 tests for DevLoginSelector page
  - renders staff and clients sections
  - shows loading state
  - displays staff with role/email, clients with pet count
  - clicking staff navigates to /admin with dev-user stored
  - clicking client navigates to / with dev-user stored
  - skip login removes dev-user and navigates to /admin
  - handles empty users response

- apps/e2e/tests/impersonation.spec.ts: 8 tests for ImpersonationBanner
  - banner displays when session is active
  - shows reason and started time
  - End Session and Audit buttons visible
  - clicking End Session calls API and hides banner
  - Extend button appears when time < 5 mins and not extended
  - URL is cleaned when session ends

- apps/e2e/tests/fixtures.ts: added /api/dev/users mock for login tests
This commit is contained in:
Lint Roller
2026-03-21 23:47:01 +00:00
parent 4f233e7bd3
commit a466053000
3 changed files with 170 additions and 0 deletions
+15
View File
@@ -10,12 +10,27 @@ import { test as base } from "@playwright/test";
*
* This ensures E2E tests render pages directly without the login redirect.
*/
const MOCK_DEV_USERS = {
staff: [
{ id: "staff-1", name: "Alice Groomer", email: "alice@groombook.dev", role: "groomer" },
{ id: "staff-2", name: "Bob Manager", email: "bob@groombook.dev", role: "manager" },
],
clients: [
{ id: "client-1", name: "Carol Client", email: "carol@example.com", petCount: 2 },
{ id: "client-2", name: "Dave Client", email: null, petCount: 1 },
],
};
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 } })
);
// Mock the dev users endpoint for login selector tests
await page.route("**/api/dev/users", (route) =>
route.fulfill({ json: MOCK_DEV_USERS })
);
// Mock the branding endpoint so BrandingProvider resolves immediately
await page.route("**/api/branding", (route) =>
route.fulfill({