Files
Jyotisha/frontend/tests/consultation-report-export.test.ts
T

46 lines
1.8 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { consultationReportMarkdown } from "../src/lib/consultation-report-export.ts";
const rowSource = readFileSync(new URL("../src/components/chat-message-row.tsx", import.meta.url), "utf8");
const globalStyles = readFileSync(new URL("../src/app/globals.css", import.meta.url), "utf8");
test("exports latest consultation answer with workflow receipt and claim boundary", () => {
const report = consultationReportMarkdown({
title: "事业咨询",
messages: [
{ role: "user", text: "未来一年事业如何?" },
{
role: "assistant",
text: "先看阶段,不承诺具体日期。",
techniqueTruth: "partial",
workflowReceipt: {
route: "career",
status: "ready",
preciseTiming: "blocked",
missingLayers: ["MEVG"],
},
},
],
});
assert.match(report, /# 事业咨询/);
assert.match(report, /先看阶段/);
assert.match(report, /这次说不到具体哪一天/);
assert.match(report, /有些依据还没补上/);
assert.match(report, /有些判断还没闭合/);
assert.doesNotMatch(report, /technique_truth/);
assert.doesNotMatch(report, /workflow_route/);
assert.doesNotMatch(report, /workflow_status/);
assert.doesNotMatch(report, /precise_timing/);
assert.doesNotMatch(report, /missing_layers/);
assert.doesNotMatch(report, /MEVG/);
assert.doesNotMatch(report, /career/);
assert.doesNotMatch(report, /Claim boundary/);
});
test("assistant answer does not expose internal report controls", () => {
assert.doesNotMatch(rowSource, /下载本次报告/);
assert.doesNotMatch(rowSource, /downloadMarkdownReport/);
assert.doesNotMatch(globalStyles, /\.report-download-button/);
});