Skip to content

Commit 828c315

Browse files
committed
test(ui): adds lockedChanged suppression and org-only globalFilter tests
Covers QA domain review findings: lockedChanged branch coverage and org prefix filter path
1 parent d7d5122 commit 828c315

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

tests/components/DashboardPage.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,36 @@ describe("DashboardPage — tab badge counts", () => {
396396
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("1");
397397
});
398398
});
399+
400+
it("filters badge counts by globalFilter org only", async () => {
401+
vi.mocked(pollService.fetchAllData).mockResolvedValue({
402+
issues: [
403+
makeIssue({ id: 1, repoFullName: "alpha/one" }),
404+
makeIssue({ id: 2, repoFullName: "beta/two" }),
405+
makeIssue({ id: 3, repoFullName: "alpha/three" }),
406+
],
407+
pullRequests: [
408+
makePullRequest({ id: 10, repoFullName: "alpha/one" }),
409+
makePullRequest({ id: 11, repoFullName: "beta/two" }),
410+
],
411+
workflowRuns: [
412+
makeWorkflowRun({ id: 20, repoFullName: "beta/two" }),
413+
makeWorkflowRun({ id: 21, repoFullName: "alpha/one" }),
414+
],
415+
errors: [],
416+
});
417+
viewStore.updateViewState({
418+
hideDepDashboard: false,
419+
globalFilter: { org: "alpha", repo: null },
420+
});
421+
422+
render(() => <DashboardPage />);
423+
await waitFor(() => {
424+
expect(screen.getByRole("tab", { name: /Issues/ }).textContent?.replace(/\D+/g, "")).toBe("2");
425+
expect(screen.getByRole("tab", { name: /Pull Requests/ }).textContent?.replace(/\D+/g, "")).toBe("1");
426+
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("1");
427+
});
428+
});
399429
});
400430

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

tests/lib/reorderHighlight.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,34 @@ describe("createReorderHighlight", () => {
153153

154154
disposeRoot();
155155
});
156+
157+
it("suppresses highlight when locked repos change simultaneously with reorder", () => {
158+
let highlighted!: Accessor<ReadonlySet<string>>;
159+
let setOrder!: (v: string[]) => void;
160+
let setLocked!: (v: string[]) => void;
161+
let disposeRoot!: () => void;
162+
163+
createRoot((dispose) => {
164+
const [order, _setOrder] = createSignal<string[]>(["a", "b", "c"]);
165+
const [locked, _setLocked] = createSignal<string[]>([]);
166+
const [ignored] = createSignal(0);
167+
setOrder = _setOrder;
168+
setLocked = _setLocked;
169+
highlighted = createReorderHighlight(order, locked, ignored);
170+
disposeRoot = dispose;
171+
});
172+
173+
// Reorder AND add a lock in single batch — should suppress
174+
batch(() => {
175+
setLocked(["c"]);
176+
setOrder(["c", "a", "b"]);
177+
});
178+
expect(highlighted().size).toBe(0);
179+
180+
// Next reorder without lock change — should highlight
181+
setOrder(["b", "c", "a"]);
182+
expect(highlighted().size).toBeGreaterThan(0);
183+
184+
disposeRoot();
185+
});
156186
});

0 commit comments

Comments
 (0)