Add registry kind indexes and entity pages.
CONTENT-WP-0002-T02 reads kinds from each snapshot and serves both example dataspaces without oncology imports. Assistant: grok Assistant-Session: 01a1346c-fdff-7741-b1af-b7283661554b
This commit is contained in:
parent
a6e360aaa5
commit
e16aa03393
21 changed files with 608 additions and 59 deletions
34
ui/lib/catalog.test.ts
Normal file
34
ui/lib/catalog.test.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { entitySlug, findDataspace, findEntity, findKind } from "./catalog";
|
||||
|
||||
const root = join(process.cwd(), "../examples/dataspaces");
|
||||
|
||||
function titles(dataspaceId: string, kindId: string): string[] {
|
||||
const snapshot = JSON.parse(readFileSync(join(root, dataspaceId, "snapshot.json"), "utf8")) as {
|
||||
entities: { kindId: string; title: string }[];
|
||||
};
|
||||
return snapshot.entities.filter((entity) => entity.kindId === kindId).map((entity) => entity.title).sort();
|
||||
}
|
||||
|
||||
describe("catalog", () => {
|
||||
it("takes the kind index from the snapshot registry", () => {
|
||||
const concept = findKind("systems-thinking", "concept");
|
||||
const pattern = findKind("software-architecture", "pattern");
|
||||
expect(concept?.plural).toBe("Concepts");
|
||||
expect(concept?.rows.map((row) => row.title).sort()).toEqual(titles("systems-thinking", "concept"));
|
||||
expect(pattern?.rows.map((row) => row.title).sort()).toEqual(titles("software-architecture", "pattern"));
|
||||
expect(concept?.rows.every((row) => row.href?.startsWith("/systems-thinking/concept/"))).toBe(true);
|
||||
});
|
||||
|
||||
it("resolves one entity and hides unknown routes", () => {
|
||||
expect(entitySlug("urn:ce:systems-thinking:concept:system-boundary", "concept")).toBe("system-boundary");
|
||||
const feedback = findEntity("systems-thinking", "concept", "feedback");
|
||||
expect(feedback?.title).toBe("Feedback");
|
||||
expect(feedback?.relations.some((relation) => relation.otherTitle === "Causal loop diagram")).toBe(true);
|
||||
expect(findEntity("systems-thinking", "concept", "missing")).toBeNull();
|
||||
expect(findKind("systems-thinking", "no-such-kind")).toBeNull();
|
||||
expect(findDataspace("software-architecture")?.title).toBe("Software Architecture");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue