Files
quality_analyse/web/verification/analysis_member_report.test.mjs
T
lyun f1a2fbd494 统一:DSH 智能分析、Top100 与图表静默恢复
接入 DSH 专用运行时和对话界面,保留模型原始回答,支持会话分页、连续追问与显式报告。
补齐组合筛选、各维度 Top100、分组查询到排名图的转换,图表故障静默省略并基于保存数据自动恢复。
优化报告风格、图表顺序和表格换行,更新接入说明及构建输入。

验证:独立目录前后端构建通过;118 项 Java、102 项前端、102 项图表、14 项 DSH 应用和 13 项组合筛选检查通过。
仅提交相关源码、锁定依赖与测试;不包含凭据、会话、业务数据或本地产物。
2026-11-12 11:57:41 +08:00

71 lines
2.9 KiB
JavaScript

import { tableTextAlignment } from '../src/tableTextAlignment.ts';
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import ts from 'typescript';
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import {
analysisMemberListFullyRead,
analysisMemberListPeriod,
parseAnalysisMemberList,
} from '../src/analysisMembersModel.ts';
const source = fs.readFileSync(new URL('../src/AnalysisMemberListReport.tsx', import.meta.url), 'utf8');
const script = source.replace(/^import .+;\n/gm, '').replace('export function ', 'function ');
const ReportDocument = new Function('tableTextAlignment', 'React',
'analysisMemberListFullyRead', 'analysisMemberListPeriod', 'parseAnalysisMemberList',
ts.transpileModule(`${script}
return AnalysisMemberListReport;`, {
fileName: 'analysis-member-report.tsx',
compilerOptions: { target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.React },
}).outputText
)(tableTextAlignment, React, analysisMemberListFullyRead, analysisMemberListPeriod, parseAnalysisMemberList);
function memberListFixture() {
return {
schemaVersion: 1,
releaseId: 'release-2026-09',
period: { year: 2026, month: 9 },
fields: [{ key: 'member', label: '成员' }, { key: 'note', label: '备注' }],
rows: Array.from({ length: 181 }, (_, index) => ({
values: { member: index === 180 ? '最后一行成员181' : `成员${index + 1}`, note: index === 0 ? '<img src=x onerror=alert(1)>' : index % 3 ? `备注${index + 1}` : null },
stages: [index % 2 ? 'bright' : 'black'],
})),
totalCount: 181,
rowsReturned: 181,
queryComplete: true,
};
}
test('the report includes every member row beyond the former 150-row limit as a static escaped table', () => {
const html = renderToStaticMarkup(React.createElement(ReportDocument, {
value: memberListFixture(),
}));
assert.match(html, /<h2>成员清单<\/h2>/);
assert.match(html, /<th>成员<\/th>/);
assert.match(html, /<th style="text-align:left">备注<\/th>/);
assert.match(html, /<th>阶段<\/th>/);
assert.equal((html.match(/<tr/g) || []).length, 182);
assert.match(html, /最后一行成员181/);
assert.match(html, /黑片/);
assert.match(html, /亮片/);
assert.match(html, /—/);
assert.match(html, /已读取全部 181 条/);
assert.match(html, /&lt;img src=x onerror=alert\(1\)&gt;/);
assert.doesNotMatch(html, /<img|<a\b/);
assert.doesNotMatch(html, /分页|每页显示|下一页/);
});
test('the report accepts a root memberList and labels incomplete coverage', () => {
const source = memberListFixture();
source.rows = source.rows.slice(0, 160);
source.rowsReturned = 160;
source.queryComplete = false;
const html = renderToStaticMarkup(React.createElement(ReportDocument, {
value: source,
}));
assert.equal((html.match(/<tr/g) || []).length, 161);
assert.match(html, /读取未完成 160 \/ 181 条/);
});