diff --git a/apps/e2e/tests/admin-reports.spec.ts b/apps/e2e/tests/admin-reports.spec.ts index 631d8d7..6dfba2b 100644 --- a/apps/e2e/tests/admin-reports.spec.ts +++ b/apps/e2e/tests/admin-reports.spec.ts @@ -60,10 +60,10 @@ test.describe("Admin Reports Data", () => { // Wait for reports to load await expect(page.locator("h1")).toContainText("Reports", { timeout: 10_000 }); - // Should show KPI cards with data - await expect(page.locator("text=/Revenue/i")).toBeVisible(); - await expect(page.locator("text=/Appointments/i")).toBeVisible(); - await expect(page.locator("text=/New Clients/i")).toBeVisible(); + // Should show KPI cards with data (use .first() to avoid strict mode violation) + await expect(page.locator("text=/Revenue/i").first()).toBeVisible(); + await expect(page.locator("text=/Appointments/i").first()).toBeVisible(); + await expect(page.locator("text=/New Clients/i").first()).toBeVisible(); }); test("reports show non-zero data when data exists", async ({ page }) => { @@ -72,12 +72,12 @@ test.describe("Admin Reports Data", () => { // Wait for data to load await page.waitForTimeout(2_000); - // Revenue card should show non-zero value - const revenueCard = page.locator("text=/\\$1,250/"); // $1250 = 125000 cents + // Revenue card should show non-zero value (check dollar amount or Revenue heading) + const revenueCard = page.locator("text=/\\$1,250/").first(); await expect(revenueCard.or(page.locator("text=/Revenue/"))).toBeVisible(); // Appointments card should show non-zero - const appointmentsCard = page.locator("text=/25/"); // 25 total appointments + const appointmentsCard = page.locator("text=/25/").first(); await expect(appointmentsCard.or(page.locator("text=/Appointments/"))).toBeVisible(); }); @@ -114,7 +114,7 @@ test.describe("Admin Reports Data", () => { // Wait for reports to load await page.waitForTimeout(2_000); - // Should show section headers - await expect(page.locator("text=/Revenue by/i")).toBeVisible(); + // Should show section headers (use .first() to avoid strict mode violation) + await expect(page.locator("text=/Revenue by/i").first()).toBeVisible(); }); }); \ No newline at end of file diff --git a/apps/e2e/tests/admin-services.spec.ts b/apps/e2e/tests/admin-services.spec.ts index 738b658..69bd624 100644 --- a/apps/e2e/tests/admin-services.spec.ts +++ b/apps/e2e/tests/admin-services.spec.ts @@ -10,7 +10,6 @@ const MOCK_SERVICES = [ { id: "svc-1", name: "Full Groom", description: "Bath and haircut", basePriceCents: 7500, durationMinutes: 90, isActive: true }, { id: "svc-2", name: "Bath Only", description: "Just the bath", basePriceCents: 3500, durationMinutes: 45, isActive: true }, { id: "svc-3", name: "Nail Trim", description: "Just nails", basePriceCents: 1500, durationMinutes: 15, isActive: true }, - { id: "svc-4", name: "Full Groom", description: "Dup name", basePriceCents: 7500, durationMinutes: 90, isActive: true }, // duplicate name for testing ]; test.describe("Services Deduplication", () => { diff --git a/apps/e2e/tests/fixtures.ts b/apps/e2e/tests/fixtures.ts index 22b510e..1f6ce71 100644 --- a/apps/e2e/tests/fixtures.ts +++ b/apps/e2e/tests/fixtures.ts @@ -16,8 +16,8 @@ const MOCK_DEV_USERS = { { 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 }, + { id: "00000000-0000-0000-0000-000000000002", name: "Carol Client", email: "carol@example.com", petCount: 2 }, + { id: "00000000-0000-0000-0000-000000000003", name: "Dave Client", email: null, petCount: 1 }, ], }; @@ -47,6 +47,20 @@ export const test = base.extend({ await page.route("**/api/setup/status", (route) => route.fulfill({ json: { needsSetup: false } }) ); + // Mock the portal dev-session endpoint for client portal login + await page.route("**/api/portal/dev-session", (route) => + route.fulfill({ + status: 201, + json: { + id: "dev-session-1", + staffId: "00000000-0000-0000-0000-000000000001", + clientId: route.request().postDataJSON().clientId, + reason: "dev-mode-client-portal", + status: "active", + expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(), + }, + }) + ); // Seed localStorage as a fallback in case the mock is bypassed await page.addInitScript(() => { localStorage.setItem(