第3项:旧界面与 React 共用对账、回收及基础业务规则

This commit is contained in:
黄健铭 committed 2026-12-05 07:43:18 -08:00
1 parent 54c05879d5
commit 389952f31c
65 files changed
+2265 -3800

No files matched your search

+18 -7
View File
@@ -45,9 +45,8 @@ function safeData(value) {
);
}
async function run(browser, group, scenario, version) {
async function run(browser, group, scenario, version, target = oldApp) {
const dir = fs.mkdtempSync(path.join(temp, group + '-' + version + '-'));
const target = version === 'old' ? oldApp : app;
const previousPreload = process.env.E2E_MUTATION_REQUIRE;
if (group === 'settings') {
fs.writeFileSync(
@@ -283,6 +282,8 @@ let browser;
try {
oldApp = fixedReference(temp, process.env.LEDGER_REFERENCE_APP);
const only = process.argv.indexOf('--only');
const legacyCandidate = process.argv.includes('--legacy-candidate');
assert.ok(!(legacyCandidate && process.argv.includes('--prove')), '金额负控使用新版候选页面');
if (process.argv.includes('--prove'))
assert.equal(process.argv[only + 1], 'settings', '使用 --only settings --prove');
const groups =
@@ -303,17 +304,21 @@ try {
'operations-access',
'recovery-quote',
'employee-retry',
...(legacyCandidate ? ['historical-cardfee'] : []),
]
: process.argv[only + 1].split(',');
const allHits = {},
outcomes = {};
console.log('旧版', reference, '新版', candidate);
console.log('固定旧版', reference, legacyCandidate ? '候选旧界面 /' : '候选新版 /next/', candidate);
process.env.WEB_NEXT = '1';
browser = await chromium.launch();
for (const group of groups) {
try {
const { default: scenario } = await import('./writes/' + group + '.mjs');
const results = await Promise.allSettled(['old', 'new'].map(version => run(browser, group, scenario, version)));
const results = await Promise.allSettled([
run(browser, group, scenario, 'old'),
run(browser, group, scenario, legacyCandidate ? 'old' : 'new', app),
]);
for (const [i, rs] of results.entries())
if (rs.status === 'rejected') console.error(group, ['old', 'new'][i], redact(String(rs.reason)));
if (results.some(rs => rs.status === 'rejected')) {
@@ -324,7 +329,7 @@ try {
const raw = compare(old.result, next.result);
let expected = old.result;
let control;
if (!old.failure && !next.failure) {
if (!legacyCandidate && !old.failure && !next.failure) {
if (['issue', 'issue-pool-date', 'issue-reopen'].includes(group)) {
const { expectedIssueResult } = await import('./writes/issue-contract.mjs');
if (group === 'issue-pool-date') {
@@ -409,8 +414,14 @@ try {
fs.mkdirSync(output, { recursive: true });
const name = only < 0 ? 'all' : groups.join('-') + (process.argv.includes('--prove') ? '-negative' : '');
fs.writeFileSync(
path.join(output, name + '.json'),
redact(JSON.stringify({ reference, head: candidate, outcomes, coverage: routes }, null, 2)),
path.join(output, (legacyCandidate ? 'legacy-candidate-' : '') + name + '.json'),
redact(
JSON.stringify(
{ reference, head: candidate, candidatePage: legacyCandidate ? '/' : '/next/', outcomes, coverage: routes },
null,
2,
),
),
);
} finally {
await browser?.close();