From 10ad5e7b043b95c2a54eea5d5f58afc227b583b4 Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 19 Apr 2026 02:25:12 +0000 Subject: [PATCH] fix(e2e): mock /api/invoices/stats/summary to prevent useEffect crash on Invoices page The GRO-609 paymentStats useEffect fetches /api/invoices/stats/summary on every render. Without a mock, the response {} (from the generic // Appointments, clients, ... fallback) doesn't contain revenueThisMonth, causing the page to fail rendering before AdminLayout ever mounts. Other admin pages don't have this problem because they don't make unconditional side-effect fetches. E2E tests mock all /api/** calls, so the new endpoint needs its own mock. cc @cpfarhood --- apps/e2e/tests/navigation.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/e2e/tests/navigation.spec.ts b/apps/e2e/tests/navigation.spec.ts index 29a7060..dc9b4aa 100644 --- a/apps/e2e/tests/navigation.spec.ts +++ b/apps/e2e/tests/navigation.spec.ts @@ -44,6 +44,16 @@ test.beforeEach(async ({ page }) => { json: { newClients: [], activeInPeriodCount: 0, churnRisk: [], churnRiskTotal: 0 }, }); } + if (url.includes("/api/invoices/stats/summary")) { + return route.fulfill({ + json: { + revenueThisMonth: 0, + outstanding: 0, + refundsThisMonth: 0, + methodBreakdown: [], + }, + }); + } if (url.includes("/api/invoices")) { return route.fulfill({ json: { data: [], total: 0 } }); }