Files
PlantAI-rag-new/tests/docgen/test_intent_frontend.mjs
jerryandClaude Fable 5 5888e1d5c1 test(docgen): 测试治理资产——131 条验收用例 + 三轮留痕 + E2E/回归套件
- 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>
2026-09-03 21:13:47 +08:00

34 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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);