[verified] feat: add specialized diagram profiles
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import type { DiagramPage } from "../../model/diagram-ir.js";
|
||||
import { validateDiagramIR } from "../../model/diagram-ir.js";
|
||||
import { compressExecutiveView } from "./compression.js";
|
||||
|
||||
const PAGE: DiagramPage = { id: "platform", title: "Platform", nodes: [{ id: "a", label: "A", provenance: { source: "a.yaml" } }, { id: "b", label: "B" }, { id: "c", label: "C" }, { id: "d", label: "D" }], edges: [{ id: "ab", source: "a", target: "b" }, { id: "bc", source: "b", target: "c" }, { id: "cd", source: "c", target: "d" }] };
|
||||
|
||||
test("compression deterministically clusters topology into linked summary and full pages", () => {
|
||||
const before = structuredClone(PAGE); const ir = compressExecutiveView(PAGE, { maxClusterSize: 2 });
|
||||
assert.deepEqual(ir, compressExecutiveView(PAGE, { maxClusterSize: 2 })); assert.deepEqual(PAGE, before); assert.equal(validateDiagramIR(ir), ir);
|
||||
assert.deepEqual(ir.pages.map((p) => p.id), ["executive-summary", "platform-full"]);
|
||||
assert.deepEqual(ir.pages[0].nodes.map((n) => n.properties?.memberIds), [["a", "b"], ["c", "d"]]);
|
||||
assert.equal(ir.pages[0].nodes[0].properties?.drillDownPage, "platform-full");
|
||||
assert.equal(ir.pages[1].nodes[0].provenance?.source, "a.yaml");
|
||||
assert.equal(ir.pages[0].edges.length, 1);
|
||||
});
|
||||
|
||||
test("compression rejects invalid and empty pages", () => {
|
||||
assert.throws(() => compressExecutiveView({ id: "empty", title: "Empty", nodes: [], edges: [] }), /non-empty/i);
|
||||
assert.throws(() => compressExecutiveView({ id: "bad", title: "Bad", nodes: [{ id: "a", label: "A" }], edges: [{ id: "e", source: "a", target: "missing" }] }), /unknown target/i);
|
||||
});
|
||||
Reference in New Issue
Block a user