import { renderToStaticMarkup } from "react-dom/server"; import { describe, expect, it, vi } from "vitest"; import { EntityRow } from "./EntityRow"; vi.mock("@/lib/router", () => ({ Link: ({ children, to, ...props }: React.ComponentProps<"a"> & { to: string }) => ( {children} ), })); describe("EntityRow", () => { it("keeps caller text color classes on linked rows", () => { const markup = renderToStaticMarkup( , ); expect(markup).toContain("text-foreground/55"); expect(markup).not.toContain("text-inherit"); }); it("renders an optional meta slot and stops the title from flex-growing", () => { const markup = renderToStaticMarkup( gpt-5.4} trailing={badge} />, ); // meta content renders alongside trailing expect(markup).toContain("meta-cell"); expect(markup).toContain("trailing-cell"); // a flex-1 spacer is inserted (between meta and trailing); the title block // itself no longer flex-grows expect(markup).toContain('class="flex-1"'); expect(markup).not.toContain("min-w-0 flex-1"); }); it("lets callers make the meta spacer responsive", () => { const markup = renderToStaticMarkup( gpt-5.4} trailing={badge} metaSpacerClassName="hidden xl:block" />, ); expect(markup).toContain('class="flex-1 hidden xl:block"'); }); it("keeps the title flex-growing when no meta is provided", () => { const markup = renderToStaticMarkup(); expect(markup).toContain("min-w-0 flex-1"); }); it("gives the title a min-width floor and lets meta shrink under titlePriority (PAP-12988)", () => { const markup = renderToStaticMarkup( chips} />, ); // The name keeps a usable floor instead of collapsing to zero... expect(markup).toContain("min-w-(--sz-6rem)"); // ...and the meta cluster is the item that yields (shrinks), not the title. expect(markup).toContain("min-w-0 shrink"); expect(markup).not.toContain('class="flex items-center gap-2 shrink-0"'); }); it("stacks a secondaryRow on its own line beneath the main row (PAP-12988)", () => { const markup = renderToStaticMarkup( chips-inline} secondaryRow={chips-stacked} />, ); // The secondary content renders, and the shell switches from a single flex // row to a stacked block layout so the cluster gets its own full-width line. expect(markup).toContain("secondary-cell"); expect(markup).toContain("chips-stacked"); expect(markup).not.toMatch(/^