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 <noreply@paperclip.ing>
This commit is contained in:
@@ -44,6 +44,17 @@ test.beforeEach(async ({ page }) => {
|
|||||||
json: { newClients: [], activeInPeriodCount: 0, churnRisk: [], churnRiskTotal: 0 },
|
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")) {
|
if (url.includes("/api/invoices")) {
|
||||||
return route.fulfill({ json: { data: [], total: 0 } });
|
return route.fulfill({ json: { data: [], total: 0 } });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user