Skip to content

Commit e713016

Browse files
committed
test(ui): adds remaining identified-but-unactioned tests
PR/Actions un-ignore round-trip, showPrRuns+ignore combo, timer clear
1 parent 6c36842 commit e713016

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

tests/components/DashboardPage.test.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,15 @@ describe("DashboardPage — tab badge counts", () => {
322322
await waitFor(() => {
323323
expect(screen.getByRole("tab", { name: /Pull Requests/ }).textContent?.replace(/\D+/g, "")).toBe("2");
324324
});
325+
326+
// Un-ignore — badge should increment back to 3
327+
viewStore.unignoreItem("10");
328+
await waitFor(() => {
329+
expect(screen.getByRole("tab", { name: /Pull Requests/ }).textContent?.replace(/\D+/g, "")).toBe("3");
330+
});
325331
});
326332

327-
it("decrements Actions badge on ignore", async () => {
333+
it("decrements Actions badge on ignore and increments on un-ignore", async () => {
328334
vi.mocked(pollService.fetchAllData).mockResolvedValue({
329335
issues: [],
330336
pullRequests: [],
@@ -344,6 +350,12 @@ describe("DashboardPage — tab badge counts", () => {
344350
await waitFor(() => {
345351
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("1");
346352
});
353+
354+
// Un-ignore — badge should increment back to 2
355+
viewStore.unignoreItem("20");
356+
await waitFor(() => {
357+
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("2");
358+
});
347359
});
348360

349361
it("excludes PR-triggered runs from badge count by default", async () => {
@@ -389,6 +401,31 @@ describe("DashboardPage — tab badge counts", () => {
389401
});
390402
});
391403

404+
it("combines showPrRuns and ignore exclusions for Actions badge", async () => {
405+
vi.mocked(pollService.fetchAllData).mockResolvedValue({
406+
issues: [],
407+
pullRequests: [],
408+
workflowRuns: [
409+
makeWorkflowRun({ id: 20, isPrRun: false }),
410+
makeWorkflowRun({ id: 21, isPrRun: true }),
411+
makeWorkflowRun({ id: 22, isPrRun: true }),
412+
],
413+
errors: [],
414+
});
415+
viewStore.updateViewState({ showPrRuns: true });
416+
417+
render(() => <DashboardPage />);
418+
await waitFor(() => {
419+
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("3");
420+
});
421+
422+
// Ignore one PR-triggered run — badge should drop to 2
423+
viewStore.ignoreItem({ id: "21", type: "workflowRun", repo: "owner/repo", title: "CI", ignoredAt: Date.now() });
424+
await waitFor(() => {
425+
expect(screen.getByRole("tab", { name: /Actions/ }).textContent?.replace(/\D+/g, "")).toBe("2");
426+
});
427+
});
428+
392429
it("filters badge counts by globalFilter repo", async () => {
393430
vi.mocked(pollService.fetchAllData).mockResolvedValue({
394431
issues: [

tests/lib/reorderHighlight.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect } from "vitest";
1+
import { describe, it, expect, vi } from "vitest";
22
import { createRoot, createSignal, batch, type Accessor } from "solid-js";
33
import { createReorderHighlight } from "../../src/app/lib/reorderHighlight";
44

@@ -183,4 +183,31 @@ describe("createReorderHighlight", () => {
183183

184184
disposeRoot();
185185
});
186+
187+
it("clears highlight after 1500ms timeout", () => {
188+
vi.useFakeTimers();
189+
190+
let highlighted!: Accessor<ReadonlySet<string>>;
191+
let setOrder!: (v: string[]) => void;
192+
let disposeRoot!: () => void;
193+
194+
createRoot((dispose) => {
195+
const [order, _setOrder] = createSignal<string[]>(["a", "b", "c"]);
196+
const [locked] = createSignal<string[]>([]);
197+
const [ignored] = createSignal(0);
198+
setOrder = _setOrder;
199+
highlighted = createReorderHighlight(order, locked, ignored);
200+
disposeRoot = dispose;
201+
});
202+
203+
setOrder(["c", "a", "b"]);
204+
expect(highlighted().size).toBeGreaterThan(0);
205+
206+
// Advance past the 1500ms clear timeout
207+
vi.advanceTimersByTime(1500);
208+
expect(highlighted().size).toBe(0);
209+
210+
disposeRoot();
211+
vi.useRealTimers();
212+
});
186213
});

0 commit comments

Comments
 (0)