content-explorer/ui/lib/browser-row.test.tsx
tegwick f8c94d3272
All checks were successful
synthetic / suite (push) Successful in 56s
Finish the computing-basics pilot and the local OnCo reference slice.
The single-operator pilot keeps static projection. Local OnCo use requires a CC BY-NC origin notice, and the slice stays out of public CI.

Assistant: grok
Assistant-Session: 01a15378-f601-7fe2-a143-8e1500a1d59c
2026-10-19 13:04:55 +02:00

40 lines
1.7 KiB
TypeScript

import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { renderCell } from "@/components/cell-renderers";
import { cellSortValue, columnDefs, mapBrowserRow } from "./browser-row";
const feedback = mapBrowserRow(
{
id: "urn:ce:systems-thinking:concept:feedback",
title: "Feedback",
tldr: "Effects of actions change subsequent behavior.",
tags: ["regulation"],
kindLabel: "Concept",
route: "/systems-thinking/concept/feedback/",
kindHref: "/systems-thinking/concept/",
},
["tags", "kind", "phase"],
);
describe("mapBrowserRow", () => {
it("fills generic columns and leaves unknown facets empty", () => {
expect(feedback.name).toBe("Feedback");
expect(feedback.route).toBe("/systems-thinking/concept/feedback/");
expect(feedback.facets).toEqual({ tags: ["regulation"], kind: ["Concept"], phase: [] });
expect(feedback.cols.tags).toEqual({ kind: "chips", values: ["regulation"] });
expect(feedback.cols.name).toEqual({ kind: "link", label: "Feedback", href: feedback.route });
expect("molecule" in feedback).toBe(false);
expect(cellSortValue(feedback, "tags")).toBe("regulation");
expect(columnDefs(["name", "tldr", "tags"]).map((column) => column.label)).toEqual(["Name", "Summary", "Tags"]);
});
it("lets a caller replace one cell renderer", () => {
const html = renderToStaticMarkup(
<>{renderCell("tags", feedback, { tags: () => "PIN" })}</>,
);
expect(html).toBe("PIN");
const linked = renderToStaticMarkup(<>{renderCell("name", feedback)}</>);
expect(linked).toContain('href="/systems-thinking/concept/feedback/"');
expect(renderCell("modality", feedback)).toBeNull();
});
});