feat: 接入模板诊断人工审阅登记

This commit is contained in:
que01 committed 2026-10-10 16:43:12 +08:00
1 parent f57e1b1336
commit d2ce2d2a84
4 files changed
+113 -3

No files matched your search

+68 -1
View File
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
import test from "node:test";
import fs from "node:fs";
import { spawnSync } from "node:child_process";
import { diagnoseTemplate } from "../lib/template-doctor.mjs";
import { applyManualReview, diagnoseTemplate } from "../lib/template-doctor.mjs";
test("真实模板自动发现并读取完整声明,生成可追溯区域报告", () => {
const root = new URL("../../packages/", import.meta.url);
@@ -70,6 +70,73 @@ test("CLI 自动发现全部模板,问题退出 1,未知模板退出 2", ()
assert.equal(missing.status, 2);
});
test("人工审阅登记只能匹配真实 review,新问题仍会失败", () => {
const report = {
template: "fixture",
staticStatus: "pass",
completionStatus: "unverified",
issues: [],
};
const reviewed = {
file: "taro/index.tsx",
page: "home",
target: "identity",
binding: null,
line: 20,
message: "条件显示需验证全部分支与空数据入口。",
severity: "review",
reviewStatus: "source-reviewed",
decision: "已核对空数据分支。",
};
const clone = (issue) => structuredClone({ ...report, issues: issue ? [issue] : [] });
const issue = {
code: "CONDITIONAL_RENDER_REVIEW",
file: "taro/index.tsx",
page: "home",
target: "identity",
line: 20,
message: "条件显示需验证全部分支与空数据入口。",
severity: "review",
};
const empty = applyManualReview(
[clone()],
[],
"人工映射审查,保留原诊断,不是自动豁免或全条件组合证明",
);
assert.equal(empty[0].staticStatus, "pass");
assert.equal(
applyManualReview(
[clone(issue)],
[reviewed],
"人工映射审查,保留原诊断,不是自动豁免或全条件组合证明",
)[0].staticStatus,
"pass",
);
assert.equal(
applyManualReview(
[clone(issue)],
[],
"人工映射审查,保留原诊断,不是自动豁免或全条件组合证明",
)[0].staticStatus,
"fail",
);
assert.throws(() =>
applyManualReview(
[clone(issue)],
[{ ...reviewed, severity: "blocker" }],
"人工映射审查,保留原诊断,不是自动豁免或全条件组合证明",
),
);
assert.throws(() =>
applyManualReview(
[clone(issue)],
[{ ...reviewed, reviewStatus: "verified" }],
"人工映射审查,保留原诊断,不是自动豁免或全条件组合证明",
),
);
assert.throws(() => applyManualReview([clone(issue)], [reviewed], "unsupported scope"));
});
const manifest = () => ({
packageKey: "independent-template",
admin: {