- tests/docgen/:DC-UNIT/API/CONF/E2E/UI/REGRESSION/PERF 分组用例与可复跑脚本,报告逐条留痕(R1-R3 全记录) - 意图 30 条前后端同表双跑(pytest + node) - Playwright headless:docgen-ui/docgen-regression spec + b3 benchpanel 第 5 TAB 断言更新 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
34 lines
1.4 KiB
JavaScript
34 lines
1.4 KiB
JavaScript
// tests/docgen/test_intent_frontend.mjs —— DC-INTENT-CASES-01~30(前端 node 双跑)
|
||
// 唯一事实源:docs/team/cases_intent.md;数据:tests/docgen/data/intent_cases.json
|
||
// 执行:bash tests/docgen/run_all.sh intent(或 node tests/docgen/test_intent_frontend.mjs)
|
||
// 前提:ui/src/intent.js 为纯函数(无 Vue 依赖),dev3 交付后可直接 import。
|
||
import { readFileSync, existsSync } from "node:fs";
|
||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||
import path from "node:path";
|
||
|
||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||
const repo = path.resolve(here, "../..");
|
||
const cases = JSON.parse(readFileSync(path.join(here, "data/intent_cases.json"), "utf-8"));
|
||
|
||
const intentPath = path.join(repo, "ui/src/intent.js");
|
||
if (!existsSync(intentPath)) {
|
||
console.log("[PENDING] ui/src/intent.js 未交付(dev3),本脚本 SKIP");
|
||
process.exit(77);
|
||
}
|
||
|
||
const { route } = await import(pathToFileURL(intentPath).href);
|
||
if (typeof route !== "function") {
|
||
console.error("intent.js 未导出 route 函数");
|
||
process.exit(1);
|
||
}
|
||
|
||
let fail = 0;
|
||
for (const c of cases) {
|
||
const got = route(c.text, c.has_attachments, c.has_active_artifact);
|
||
const ok = got === c.expected;
|
||
if (!ok) fail++;
|
||
console.log(`${ok ? "PASS" : "FAIL"} #${String(c.num).padStart(2, "0")} ${c.text} -> ${got}(期望 ${c.expected})`);
|
||
}
|
||
console.log(`===== 前端 intent 30 条:${30 - fail}/30 PASS =====`);
|
||
process.exit(fail === 0 ? 0 : 1);
|