feat: add scoped history and artifacts
This commit is contained in:
@@ -66,3 +66,46 @@ describe("new investigation report writes", () => {
|
||||
expect(updated.diagram?.node_refs.map((node) => node.status)).toEqual(["completed", "running", "pending"]);
|
||||
});
|
||||
});
|
||||
|
||||
const uiBlock = {
|
||||
version: "answer-ui@1" as const, block_id: "pressure", fallback_text: "演练数据,等待核验。",
|
||||
spec: { root: "chart", elements: { chart: { type: "Chart", children: [], props: {
|
||||
title: "演练压力", chart_type: "line", x_data: ["08:00", "09:00"],
|
||||
series: [{ name: "压力", data: [0.3, 0.28] }], source: "query-1",
|
||||
} } } },
|
||||
};
|
||||
|
||||
describe("interactive report publication", () => {
|
||||
it("preserves rich blocks and legacy reports without changing fixed facts", () => {
|
||||
expect(taskReportSchema.parse(report).ui_blocks).toBeUndefined();
|
||||
const parsed = taskReportSchema.parse({ ...report, ui_blocks: [{ block: uiBlock, evidence_refs: ["query-1"] }] });
|
||||
expect(parsed.ui_blocks?.[0].block).toEqual(uiBlock);
|
||||
expect(parsed.outcome).toBe("insufficient_data");
|
||||
expect(parsed.data_gaps).toEqual(report.data_gaps);
|
||||
});
|
||||
it("rejects foreign evidence, duplicate ids, executable props and malformed charts", () => {
|
||||
const item = { block: uiBlock, evidence_refs: ["query-1"] };
|
||||
for (const blocks of [
|
||||
[item, item], [{ ...item, evidence_refs: ["other-task"] }],
|
||||
Array.from({ length: 9 }, (_, index) => ({ ...item, block: { ...uiBlock, block_id: `b${index}` } })),
|
||||
...[
|
||||
{ type: "iframe" },
|
||||
{ props: { ...uiBlock.spec.elements.chart.props, onclick: "execute()" } },
|
||||
{ props: { ...uiBlock.spec.elements.chart.props, series: [{ name: "压力", data: [1] }] } },
|
||||
{ props: { ...uiBlock.spec.elements.chart.props, series: [{ name: "压力", data: [NaN, 1] }] } },
|
||||
].map((change) => [{ ...item, block: { ...uiBlock, spec: { ...uiBlock.spec,
|
||||
elements: { chart: { ...uiBlock.spec.elements.chart, ...change } } } } }]),
|
||||
]) expect(taskReportSchema.safeParse({ ...report, ui_blocks: blocks }).success).toBe(false);
|
||||
});
|
||||
it("bounds the total UTF-8 payload even when every individual block is valid", () => {
|
||||
const elements = Object.fromEntries(Array.from({ length: 20 }, (_, index) => [
|
||||
`n${index}`, { type: "Text", props: { text: "资".repeat(3900), tone: "neutral" }, children: [] },
|
||||
]));
|
||||
const block = { ...uiBlock, spec: { root: "root", elements: {
|
||||
root: { type: "Stack", props: { columns: "one", gap: "normal" }, children: Object.keys(elements) }, ...elements,
|
||||
} } };
|
||||
const blocks = ["first", "second"].map((block_id) => ({ block: { ...block, block_id }, evidence_refs: ["query-1"] }));
|
||||
expect(taskReportSchema.safeParse({ ...report, ui_blocks: [blocks[0]] }).success).toBe(true);
|
||||
expect(taskReportSchema.safeParse({ ...report, ui_blocks: blocks }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user