diff --git a/ui/src/components/FeedCard.test.tsx b/ui/src/components/FeedCard.test.tsx new file mode 100644 index 0000000000..a1f76c0e97 --- /dev/null +++ b/ui/src/components/FeedCard.test.tsx @@ -0,0 +1,71 @@ +// @vitest-environment jsdom + +import { act } from "react"; +import { createRoot } from "react-dom/client"; +import type { ActivityEvent } from "@paperclipai/shared"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { FeedCard } from "./FeedCard"; + +const navigate = vi.fn(); + +vi.mock("@/lib/router", () => ({ + Link: ({ children, issueQuicklookSide: _, to, ...props }: React.ComponentProps<"a"> & { issueQuicklookSide?: string; to: string }) => ( + + {children} + + ), +})); + +const event: ActivityEvent = { + id: "event-1", + companyId: "company-1", + actorType: "user", + actorId: "user-1", + action: "issue.updated", + entityType: "issue", + entityId: "issue-1", + agentId: null, + runId: null, + details: null, + createdAt: new Date("2026-09-11T12:00:00.000Z"), +}; + +describe("FeedCard", () => { + let container: HTMLDivElement; + + beforeEach(() => { + container = document.createElement("div"); + document.body.appendChild(container); + navigate.mockClear(); + }); + + afterEach(() => { + container.remove(); + }); + + it("uses the whole visible card as the entity link", () => { + const root = createRoot(container); + act(() => { + root.render( + , + ); + }); + + const link = container.querySelector('[data-fc="link"]'); + const card = container.querySelector('[data-fc="card"]'); + + expect(link).not.toBeNull(); + expect(link?.className).toContain("w-full"); + expect(link?.contains(card ?? null)).toBe(true); + + card?.click(); + expect(navigate).toHaveBeenCalledOnce(); + + act(() => root.unmount()); + }); +});