界面:表格长文本列统一左对齐,保留名称与属性对齐
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { tableTextAlignment } from '../src/tableTextAlignment.ts';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
@@ -14,14 +15,14 @@ import {
|
||||
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',
|
||||
const ReportDocument = new Function('tableTextAlignment', '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 : {},
|
||||
)(tableTextAlignment, 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,
|
||||
@@ -51,7 +52,7 @@ test('the report includes every member row beyond the former 150-row limit as a
|
||||
|
||||
assert.match(html, /<h2>成员清单<\/h2>/);
|
||||
assert.match(html, /<th>成员<\/th>/);
|
||||
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/);
|
||||
|
||||
Reference in New Issue
Block a user