From eed8e36a69d94afb1eb020c49ee33788c2b21bc6 Mon Sep 17 00:00:00 2001 From: Naiyuan Qing <145280634+NevilleQingNY@users.noreply.github.com> Date: Wed, 8 Apr 2026 10:41:29 +0800 Subject: [PATCH] fix(test): update mockListIssues for two-phase fetch (open_only + closed) issueListOptions now makes 2 api.listIssues calls (open_only + closed page). Tests that mock the response must return data only for the open_only call, otherwise issues appear twice in the merged result. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/web/app/(dashboard)/issues/page.test.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web/app/(dashboard)/issues/page.test.tsx b/apps/web/app/(dashboard)/issues/page.test.tsx index 261287fc..86389051 100644 --- a/apps/web/app/(dashboard)/issues/page.test.tsx +++ b/apps/web/app/(dashboard)/issues/page.test.tsx @@ -295,7 +295,10 @@ describe("IssuesPage", () => { }); it("renders issues in board view after loading", async () => { - mockListIssues.mockResolvedValue({ issues: mockIssues, total: mockIssues.length }); + // issueListOptions makes 2 calls: open_only + closed page. Return issues for open, empty for closed. + mockListIssues.mockImplementation((params: any) => + Promise.resolve(params?.open_only ? { issues: mockIssues, total: mockIssues.length } : { issues: [], total: 0 }), + ); renderWithQuery(); @@ -305,7 +308,9 @@ describe("IssuesPage", () => { }); it("renders board columns", async () => { - mockListIssues.mockResolvedValue({ issues: mockIssues, total: mockIssues.length }); + mockListIssues.mockImplementation((params: any) => + Promise.resolve(params?.open_only ? { issues: mockIssues, total: mockIssues.length } : { issues: [], total: 0 }), + ); renderWithQuery(); @@ -331,11 +336,12 @@ describe("IssuesPage", () => { }); it("shows filter and display icon buttons", async () => { - mockListIssues.mockResolvedValue({ issues: mockIssues, total: mockIssues.length }); + mockListIssues.mockImplementation((params: any) => + Promise.resolve(params?.open_only ? { issues: mockIssues, total: mockIssues.length } : { issues: [], total: 0 }), + ); renderWithQuery(); - // Wait for query to resolve and component to render past loading state await screen.findByText("Implement auth"); const buttons = screen.getAllByRole("button"); expect(buttons.length).toBeGreaterThan(0);