25 lines
1.4 KiB
TypeScript
25 lines
1.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { createElement } from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { ResultView } from "./ResultView";
|
|
import type { AssistantResult } from "../../../shared/assets/assistant";
|
|
|
|
test("count answer renders prose without report cards and only offers records for positive counts", () => {
|
|
for (const count of [0, 7]) {
|
|
const result: AssistantResult = {
|
|
plan: {kind:"assets",category:"abnormal",groupBy:"none",view:"chart",filters:{}},
|
|
conciseCount:true,outcome:"complete",summary:`当前异动车辆为 ${count} 台。`,
|
|
title:"异动车辆概览",metrics:[{label:"异动车辆",value:count,unit:"台"}],
|
|
rows:[],groups:[],source:"测试台账",fetchedAt:"2026-09-23T00:00:00Z",suggestions:["查看全部车辆"],
|
|
};
|
|
const noop = () => {};
|
|
const html = renderToStaticMarkup(createElement(ResultView,{result,ask:noop,operate:noop,restore:noop,active:true,activate:noop,subject:null,disabled:false,showCorrection:noop}));
|
|
assert.match(html,new RegExp(`当前异动车辆为 ${count} 台`));
|
|
assert.doesNotMatch(html,/aq-primary-metrics|aq-result-card|aq-followups|aq-query-heading/);
|
|
assert.equal(html.includes("查看车辆明细"),count > 0);
|
|
assert.equal(html.includes("导出明细"),count > 0);
|
|
assert.match(html,/统计口径、权限与数据时间/);
|
|
}
|
|
});
|