fix(gro-558): add paginated mock for /api/invoices #261
Reference in New Issue
Block a user
Delete Branch "fix/gro-531-social-login"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Context
The InvoicesPage component expects a paginated response . When it receives a plain array , accessing returns , crashing the component on — preventing the page from rendering.
Testing
pnpm lint— passespnpm typecheck— passescc @cpfarhood
E2E Tests job still failed on CI (job 70914520950, step 'Run E2E tests' conclusion: failure).
The single-line fix (adding before the assertion) did not stabilize the test. Please investigate and push a more robust fix.
E2E Tests job still failed on CI (job 70914520950, step Run E2E tests conclusion: failure).
The single-line fix (adding waitForLoadState before the assertion) did not stabilize the test. Please investigate and push a more robust fix.
Changes Requested
The
waitForLoadState('networkidle')addition does not address the root cause. The test still fails on all 3 retries with "element(s) not found" — the textGroomBooknever appears because the page crashes during render.Root Cause
The generic API mock (line ~48 in
navigation.spec.ts) returns a plain array[]for all unmatched endpoints. The/api/invoicesendpoint gets this response, but theInvoicesPagecomponent expects a paginated structure:{ data: [...], total: N }.When the component does:
This causes a React error that prevents the entire page (including the AdminLayout nav with "GroomBook") from rendering.
Required Fix
Add a specific mock for
/api/invoicesbefore the generic fallback in thebeforeEachroute handler:Also revert the
waitForLoadState("networkidle")addition — it's unnecessary once the mock is correct, andnetworkidleis fragile in CI (as shown byconsole-health.spec.tstiming out on the same wait).cc @cpfarhood
Deployed to groombook-dev
Images:
pr-261URL: https://dev.groombook.farh.net
Ready for UAT validation.
All CI checks green (lint, typecheck, tests, E2E, build, deploy). Mock correctly returns paginated response.
Fix looks correct. The paginated mock
{ data: [], total: 0 }for/api/invoicesmatches the API contract and prevents the React crash. The fragilewaitForLoadState("networkidle")is properly removed. All CI checks pass including E2E (48 tests green).Routing to QA for re-review.
cc @cpfarhood