冻结十六组逐笔对照的真实步骤与写入动作
This commit is contained in:
1 parent
716ae7e8ee
commit
5fbcf45911
3 files changed
+382
-31
No files matched your search
+42
-31
@@ -12,6 +12,7 @@ import { dumpDatabase } from './lib/db-dump.js';
|
||||
import { Normalizer } from './lib/normalize.js';
|
||||
import { readOnlyPost, ReadOnlyChecks } from './writes/readonly.mjs';
|
||||
import { coverage } from './write-coverage.mjs';
|
||||
import { fullGroups, contracts, assertSequence, assertStepActions, observeStep } from './lib/frozen-write-steps.mjs';
|
||||
import { compare, report } from './lib/diff.js';
|
||||
|
||||
import { app, git, reference, fixedReference } from './lib/write-reference.mjs';
|
||||
@@ -225,7 +226,7 @@ async function run(browser, group, scenario, version, target = oldApp) {
|
||||
assert.ok(!active && !Object.hasOwn(steps, label), '重复或嵌套的步骤 ' + label);
|
||||
active = { label, before: database(), requests: [] };
|
||||
try {
|
||||
const result = await fn();
|
||||
const result = await observeStep(group, label, fn, pages, session);
|
||||
assert.ok(
|
||||
active.requests.every(req => Object.hasOwn(req, 'status')),
|
||||
label + ' 仍有未完成的请求',
|
||||
@@ -256,6 +257,7 @@ async function run(browser, group, scenario, version, target = oldApp) {
|
||||
dbPath: path.join(dir, 'ledger.sqlite'),
|
||||
prove: process.argv.includes('--prove'),
|
||||
});
|
||||
assertSequence(Object.keys(steps), Object.keys(contracts[group]), group + ' ' + version + ' 冻结步骤');
|
||||
assert.deepEqual(session.problems, []);
|
||||
assert.deepEqual(errors, []);
|
||||
} catch (error) {
|
||||
@@ -286,27 +288,9 @@ try {
|
||||
assert.ok(!(legacyCandidate && process.argv.includes('--prove')), '金额负控使用新版候选页面');
|
||||
if (process.argv.includes('--prove'))
|
||||
assert.equal(process.argv[only + 1], 'settings', '使用 --only settings --prove');
|
||||
const groups =
|
||||
only < 0
|
||||
? [
|
||||
'orders',
|
||||
'funds',
|
||||
'operations',
|
||||
'settings',
|
||||
'report',
|
||||
'setup',
|
||||
'demo',
|
||||
'create',
|
||||
'history',
|
||||
'issue',
|
||||
'issue-reopen',
|
||||
'issue-pool-date',
|
||||
'operations-access',
|
||||
'recovery-quote',
|
||||
'employee-retry',
|
||||
...(legacyCandidate ? ['historical-cardfee'] : []),
|
||||
]
|
||||
: process.argv[only + 1].split(',');
|
||||
const groups = only < 0 ? [...fullGroups] : (process.argv[only + 1] ?? '').split(',');
|
||||
assert.ok(groups.every(group => Object.hasOwn(contracts, group)), '--only 需要指定已冻结的业务组');
|
||||
assert.equal(new Set(groups).size, groups.length, '--only 重复指定业务组');
|
||||
const allHits = {},
|
||||
outcomes = {};
|
||||
console.log('固定旧版', reference, legacyCandidate ? '候选旧界面 /' : '候选新版 /next/', candidate);
|
||||
@@ -337,6 +321,7 @@ try {
|
||||
// 由真实业务事务产生新版的预期账本,不在比对器里重算成本或忽略账表。
|
||||
control = await run(browser, group, ctx => scenario({ ...ctx, selectOrderDatePool: true }), 'old');
|
||||
assert.ok(!control.failure, '显式选择订单日料池的旧版对照失败:' + control.failure);
|
||||
assertStepActions(group, 'old', coverage({ [group]: { old: control.hits, new: [] } }));
|
||||
}
|
||||
expected = expectedIssueResult(group, old.result, control?.result);
|
||||
} else if (group === 'funds' || group === 'funds-transfer') {
|
||||
@@ -403,6 +388,24 @@ try {
|
||||
}
|
||||
}
|
||||
const routes = coverage(allHits);
|
||||
try {
|
||||
assertSequence(Object.keys(outcomes), only < 0 ? fullGroups : groups, '冻结业务组');
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
for (const group of groups) {
|
||||
if (!outcomes[group]) continue;
|
||||
for (const side of ['old', 'new']) {
|
||||
try {
|
||||
assertStepActions(group, side, routes);
|
||||
} catch (error) {
|
||||
outcomes[group].failures[side] = [outcomes[group].failures[side], error.message].filter(Boolean).join('\n');
|
||||
console.error(error.message);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (only < 0 && routes.missing.length) {
|
||||
console.error(
|
||||
'未命中的动作',
|
||||
@@ -413,16 +416,24 @@ try {
|
||||
const output = path.join(app, 'e2e', 'out', 'write-parity');
|
||||
fs.mkdirSync(output, { recursive: true });
|
||||
const name = only < 0 ? 'all' : groups.join('-') + (process.argv.includes('--prove') ? '-negative' : '');
|
||||
fs.writeFileSync(
|
||||
path.join(output, (legacyCandidate ? 'legacy-candidate-' : '') + name + '.json'),
|
||||
redact(
|
||||
JSON.stringify(
|
||||
{ reference, head: candidate, candidatePage: legacyCandidate ? '/' : '/next/', outcomes, coverage: routes },
|
||||
null,
|
||||
2,
|
||||
function writeResult(name, outcomes, routes) {
|
||||
fs.writeFileSync(
|
||||
path.join(output, (legacyCandidate ? 'legacy-candidate-' : '') + name + '.json'),
|
||||
redact(
|
||||
JSON.stringify(
|
||||
{ reference, head: candidate, candidatePage: legacyCandidate ? '/' : '/next/', outcomes, coverage: routes },
|
||||
null,
|
||||
2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
writeResult(name, outcomes, routes);
|
||||
if (only < 0 && !legacyCandidate) {
|
||||
// 保留原来独立交付的第 16 组证据。其路由覆盖仅反映该组,两份报告来自同一次执行。
|
||||
const group = 'historical-cardfee';
|
||||
writeResult(group, { [group]: outcomes[group] }, coverage(allHits[group] ? { [group]: allHits[group] } : {}));
|
||||
}
|
||||
} finally {
|
||||
await browser?.close();
|
||||
fs.rmSync(temp, { recursive: true, force: true });
|
||||
|
||||
Reference in new issue
Block a user