import { describe, expect, test } from "bun:test";
import { renderToStaticMarkup } from "react-dom/server";
import { DetailSection } from "./detail-sheet";
import {
DetailAside,
DetailAsideItem,
DetailMeta,
DetailPage,
DetailPageBody,
DetailPageHeader,
} from "./detail-page";
describe("DetailPage anatomy", () => {
test("renders the back link, a focusable h1, chips, the joined meta line and tabs", () => {
const html = renderToStaticMarkup(
{} }}>
Organization}
meta={["4 variables", null, "updated 3 days ago"]}
actions={}
tabs={}
/>
,
);
expect(html).toContain("Variable sets");
expect(html).toMatch(/
]*>AWS production<\/h1>/);
expect(html).toContain("data-chip");
expect(html).toContain("data-tabs");
// Two parts survive (null is dropped), so exactly one separator.
expect(html.match(/·/g)?.length).toBe(1);
});
test("DetailMeta skips empty parts", () => {
const html = renderToStaticMarkup(
{["by Maja", "", false, "in Design"]},
);
expect(html).toContain("by Maja");
expect(html).toContain("in Design");
expect(html.match(/·/g)?.length).toBe(1);
});
test("sections inside the body render as page sections, and the aside is labelled", () => {
const html = renderToStaticMarkup(
Maja Berg
}
>
rows,
);
expect(html).toContain("