From 9f492552531a953c6342ea4c7137036b5565f45e Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Mon, 20 Apr 2026 13:25:10 +0000 Subject: [PATCH] fix(e2e): add /api/invoices/stats/summary mock before broad /api/invoices catch-all PR #341 added a useEffect in the Invoices page that fetches /api/invoices/stats/summary. The existing /api/invoices mock was too broad and intercepted this URL, returning { data: [], total: 0 } instead of the stats shape { revenueThisMonth, outstanding, refundsThisMonth, methodBreakdown }. This caused a runtime crash when rendering paymentStats.revenueThisMonth. The fix adds a specific mock for /api/invoices/stats/summary before the general /api/invoices mock, so the stats endpoint returns the correct shape. Fixes GRO-820. Co-Authored-By: Paperclip --- apps/e2e/tests/navigation.spec.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/e2e/tests/navigation.spec.ts b/apps/e2e/tests/navigation.spec.ts index 29a7060..4101ed3 100644 --- a/apps/e2e/tests/navigation.spec.ts +++ b/apps/e2e/tests/navigation.spec.ts @@ -44,6 +44,17 @@ test.beforeEach(async ({ page }) => { json: { newClients: [], activeInPeriodCount: 0, churnRisk: [], churnRiskTotal: 0 }, }); } + // Specific route must come before /api/invoices to avoid intercepting stats/summary + 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 } }); } -- 2.52.0