Publish graph deltas using the Server-owned cumulative graph contract. Validate historical comparison chart publications and consolidate Agent documentation.
32 lines
1.9 KiB
TypeScript
32 lines
1.9 KiB
TypeScript
import { expect, it } from "bun:test";
|
|
import { readFileSync } from "node:fs";
|
|
import cases from "../fixtures/chart-publication-cases.json" with { type: "json" };
|
|
import presentView from "../../.opencode/tools/present_view.js";
|
|
import { taskPublicationCommandSchema } from "../../.opencode/tools/task-publication-schema.js";
|
|
import { taskPresentationCommandSchema } from "../../src/product/task-presentation.js";
|
|
import { createViewCommandSchema, safeChartInput } from "../../src/frontendAction/command.js";
|
|
import { FrontendActionCoordinator } from "../../src/frontendAction/coordinator.js";
|
|
|
|
const schemas = [presentView.args.command, taskPublicationCommandSchema, taskPresentationCommandSchema,
|
|
createViewCommandSchema({ publication: false, validateCharts: true })];
|
|
|
|
it.each(cases)("matches Frontend and Server chart publication: $name", ({ chart, accepted }) => {
|
|
const command = { action: "open_chart", chart_id: "comparison", evidence_refs: ["dev:synthetic"], chart };
|
|
for (const schema of schemas)
|
|
expect(schema.safeParse(command).success).toBe(accepted);
|
|
expect(() => new FrontendActionCoordinator().request({ sessionId: "synthetic", toolCallId: "case", command }))
|
|
.toThrow(accepted ? "no active browser sink" : "invalid view command");
|
|
});
|
|
|
|
it("keeps historical mixed charts structurally readable", () => {
|
|
expect(safeChartInput.safeParse(cases.find((item) => item.name === "old mixed charts are read only")!.chart).success).toBe(true);
|
|
});
|
|
|
|
it("accepts all exported commands in both host and native publication validators", () => {
|
|
const examples = readFileSync(new URL("../fixtures/unified-presentation.jsonl", import.meta.url), "utf8");
|
|
for (const record of examples.trim().split("\n").map((line) => JSON.parse(line))) {
|
|
if (record.record_type !== "presentation") continue;
|
|
for (const schema of schemas) expect(schema.safeParse(record.command).success).toBe(true);
|
|
}
|
|
});
|