Skip to content

Commit d7d5122

Browse files
committed
test(ui): adds globalFilter badge count test
Covers cor-1 fix: verifies tabCounts filters by viewState.globalFilter.repo
1 parent f8a1eac commit d7d5122

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/components/DashboardPage.test.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,38 @@ describe("DashboardPage — tab badge counts", () => {
364364
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("3");
365365
});
366366
});
367+
368+
it("filters badge counts by globalFilter repo", async () => {
369+
vi.mocked(pollService.fetchAllData).mockResolvedValue({
370+
issues: [
371+
makeIssue({ id: 1, title: "Issue A", repoFullName: "org/alpha" }),
372+
makeIssue({ id: 2, title: "Issue B", repoFullName: "org/beta" }),
373+
makeIssue({ id: 3, title: "Issue C", repoFullName: "org/alpha" }),
374+
],
375+
pullRequests: [
376+
makePullRequest({ id: 10, repoFullName: "org/alpha" }),
377+
makePullRequest({ id: 11, repoFullName: "org/beta" }),
378+
],
379+
workflowRuns: [
380+
makeWorkflowRun({ id: 20, repoFullName: "org/alpha" }),
381+
makeWorkflowRun({ id: 21, repoFullName: "org/beta" }),
382+
makeWorkflowRun({ id: 22, repoFullName: "org/beta" }),
383+
],
384+
errors: [],
385+
});
386+
// Set filter BEFORE render to avoid Kobalte Select onChange cascade in happy-dom
387+
viewStore.updateViewState({
388+
hideDepDashboard: false,
389+
globalFilter: { org: null, repo: "org/alpha" },
390+
});
391+
392+
render(() => <DashboardPage />);
393+
await waitFor(() => {
394+
expect(screen.getByRole("tab", { name: /Issues/ }).textContent?.replace(/\D+/g, "")).toBe("2");
395+
expect(screen.getByRole("tab", { name: /Pull Requests/ }).textContent?.replace(/\D+/g, "")).toBe("1");
396+
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("1");
397+
});
398+
});
367399
});
368400

369401
describe("DashboardPage — data flow", () => {

0 commit comments

Comments
 (0)