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 ? '' : 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, /