feat(batchdiff): remit rows drill to RemitDrawer
This commit is contained in:
@@ -29,6 +29,7 @@ vi.mock("@/lib/api", () => ({
|
||||
isConfigured: true,
|
||||
listBatches: vi.fn(),
|
||||
getBatchDiff: vi.fn(),
|
||||
getRemittance: vi.fn(),
|
||||
},
|
||||
ApiError: class ApiError extends Error {
|
||||
constructor(public status: number, message: string) {
|
||||
@@ -180,6 +181,13 @@ function makeDiffPayload(): BatchDiffResponse {
|
||||
describe("BatchDiff page", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
// Default for the per-remit detail fetch — the drawer fetches
|
||||
// this whenever `?remit=` is in the URL. Return a never-resolving
|
||||
// promise so the drawer stays in the loading state; the smoke
|
||||
// test only asserts the drawer mounts, not the loaded data.
|
||||
(
|
||||
api.getRemittance as unknown as ReturnType<typeof vi.fn>
|
||||
).mockReturnValue(new Promise(() => {}));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -189,6 +197,42 @@ describe("BatchDiff page", () => {
|
||||
.happyDOM.setURL("http://localhost/batch-diff");
|
||||
});
|
||||
|
||||
it("SP21 Task 4.5: deep-link ?remit=ID opens the RemitDrawer on mount", async () => {
|
||||
// Pre-set the URL with `?remit=`. The page doesn't surface any
|
||||
// per-remit rows (the diff payload is claim-level), but the
|
||||
// drawer must still mount so the URL contract is honored.
|
||||
//
|
||||
// `useRemitDrawerUrlState` reads `window.location.search`
|
||||
// (NOT React Router's search params) so we have to set the
|
||||
// global window URL via happyDOM AND give MemoryRouter an
|
||||
// initial entry — both stay in lockstep.
|
||||
(window as unknown as { happyDOM: { setURL: (u: string) => void } })
|
||||
.happyDOM.setURL("http://localhost/batch-diff?remit=REM-7");
|
||||
(
|
||||
api.listBatches as unknown as ReturnType<typeof vi.fn>
|
||||
).mockResolvedValue([BATCH_A, BATCH_B]);
|
||||
|
||||
const { unmount } = renderIntoContainer(
|
||||
<BatchDiff />,
|
||||
["/batch-diff?remit=REM-7"],
|
||||
);
|
||||
|
||||
// Page header must be present + drawer must be open.
|
||||
await waitFor(
|
||||
() => !!document.querySelector('[data-testid="batch-diff-page"]'),
|
||||
"page header mounted",
|
||||
);
|
||||
await waitFor(
|
||||
() => !!document.querySelector('[data-testid="remit-drawer"]'),
|
||||
"remit drawer mounted via deep link",
|
||||
);
|
||||
expect(
|
||||
document.querySelector('[data-testid="remit-drawer"]'),
|
||||
).not.toBeNull();
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it("renders the awaiting-picks empty state when no batches are selected", async () => {
|
||||
(api.listBatches as unknown as ReturnType<typeof vi.fn>).mockResolvedValue([
|
||||
BATCH_A, BATCH_B,
|
||||
|
||||
Reference in New Issue
Block a user