Files
Agent-System/deploy/pi-agent/change-report-narrative-v1.test.mjs
T
weichenandCursor 51568ea080 feat(web): distinguish change-report narrative vs factual fields
Panel and view-model label server risk/lineage separately from PI narrative;
add change_report_narrative_v1 helper aligned with typed-result patterns.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 15:39:54 +00:00

33 lines
1.0 KiB
JavaScript

import assert from "node:assert/strict";
import {
NARRATIVE_SCHEMA_KIND,
buildChangeReportNarrative,
validateChangeReportNarrative,
} from "./change-report-narrative-v1.mjs";
const digest = "abc123";
const good = buildChangeReportNarrative({
inputDigest: digest,
fromSha: "f1",
toSha: "t1",
summary: ["阈值调整"],
});
assert.equal(good.schema_kind, NARRATIVE_SCHEMA_KIND);
assert.equal(validateChangeReportNarrative(good, { input_digest: digest, from_sha: "f1", to_sha: "t1" }).ok, true);
assert.equal(validateChangeReportNarrative({ ...good, partial: true }, { input_digest: digest }).ok, false);
assert.equal(validateChangeReportNarrative({ ...good, input_digest: "other" }, { input_digest: digest }).ok, false);
assert.equal(
validateChangeReportNarrative(
{ ...good, summary: [] },
{ input_digest: digest, from_sha: "f1", to_sha: "t1" },
).ok,
false,
);
assert.equal(
validateChangeReportNarrative({ error_code: "TIMEOUT", schema_kind: NARRATIVE_SCHEMA_KIND }).ok,
false,
);
console.log("change-report-narrative-v1.test.mjs: ok");