同步:完善质量分析工作台并更新主题字体
同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
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 { parseServerReadingSummary } from '../src/analysisReadingModel.ts';
|
||||
import {
|
||||
analysisMemberListFullyRead,
|
||||
analysisMemberListPeriod,
|
||||
parseAnalysisMemberList,
|
||||
} from '../src/analysisMembersModel.ts';
|
||||
|
||||
const exportSource = fs.readFileSync(new URL('../src/AnalysisReportExport.tsx', import.meta.url), 'utf8');
|
||||
const reportDocumentSource = exportSource.slice(exportSource.indexOf('function ReportDocument('), exportSource.indexOf('\nfunction reportHtmlFromElement('));
|
||||
const node = (tag, props) => React.createElement(tag, props, props?.children);
|
||||
const ReportDocument = new Function('React', 'reportCss', 'record', 'text', 'buildAnalysisNarrative', 'analysisScopeText',
|
||||
'parseServerReadingSummary', 'resolveAnalysisReportTitle', 'sanitizeAnalysisDisplayText', 'stripDuplicateFirstMarkdownH1', 'AnalysisReportNarrative',
|
||||
'AnalysisLegacyResults', 'AnalysisRecordListReport', 'analysisMemberListFullyRead', 'analysisMemberListPeriod', 'parseAnalysisMemberList',
|
||||
ts.transpileModule(`${reportDocumentSource}\nreturn ReportDocument;`, {
|
||||
fileName: 'analysis-report-document.tsx',
|
||||
compilerOptions: { target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.React },
|
||||
}).outputText
|
||||
)(React, '', value => value && typeof value === 'object' && !Array.isArray(value) ? value : {},
|
||||
value => value === null || value === undefined || value === '' ? '—' : String(value),
|
||||
() => ({ period: '2026年9月' }), () => '', parseServerReadingSummary, () => '分析报告', value => value, value => value,
|
||||
({ answer }) => node('div', { className: 'report-summary', children: answer }), () => null, () => null,
|
||||
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, {
|
||||
turn: { id: 'turn-1', status: 'COMPLETED', result: { answer: '摘要内容', memberList: memberListFixture() } },
|
||||
stamp: '2026-10-27 12:00:00', visualImages: [],
|
||||
}));
|
||||
|
||||
assert.match(html, /<h2>成员清单<\/h2>/);
|
||||
assert.match(html, /<th>成员<\/th>/);
|
||||
assert.match(html, /<th>备注<\/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, /<img src=x onerror=alert\(1\)>/);
|
||||
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, {
|
||||
turn: { id: 'turn-2', status: 'PARTIAL', answer: '摘要', memberList: source },
|
||||
stamp: '2026-10-27 12:00:00', visualImages: [],
|
||||
}));
|
||||
assert.equal((html.match(/<tr/g) || []).length, 161);
|
||||
assert.match(html, /读取未完成 160 \/ 181 条/);
|
||||
});
|
||||
Reference in New Issue
Block a user