逐项验收冻结页面、表单和命令,拒绝调试与漏跑
This commit is contained in:
1 parent
5fbcf45911
commit
f1dcb472de
10 files changed
+1291
-32
No files matched your search
@@ -5,6 +5,7 @@
|
||||
// 并核对两边页面显示的成交合计与纸单号一致。
|
||||
// node e2e/parity-create-order.mjs [--reference-app 旧版应用目录] [--only 场景关键字] [--headed] [--keep]
|
||||
// PARITY_SELF_TEST=1:自检,新界面第一处附加金额多填 1 元,对照必须报告不一致。
|
||||
import assert from 'node:assert/strict';
|
||||
import { createRequire } from 'node:module';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
@@ -20,6 +21,7 @@ const { compare, report } = require('./lib/diff.js');
|
||||
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const OUT = path.join(HERE, 'out', 'parity');
|
||||
const frozen = JSON.parse(fs.readFileSync(path.join(HERE, 'frozen-page-scenarios.json'), 'utf8')).create;
|
||||
const args = process.argv.slice(2),
|
||||
headed = args.includes('--headed'),
|
||||
only = args.includes('--only') ? args[args.indexOf('--only') + 1] : '';
|
||||
@@ -613,7 +615,8 @@ async function runSide(browser, ui, scenario, tag) {
|
||||
clockStart: new Date(at(9)).toISOString(),
|
||||
seed: 'parity-seed',
|
||||
});
|
||||
const problems = [];
|
||||
const problems = [],
|
||||
completedSteps = [];
|
||||
let context,
|
||||
stopped = null;
|
||||
const stop = () => (stopped ??= server.stop());
|
||||
@@ -638,6 +641,7 @@ async function runSide(browser, ui, scenario, tag) {
|
||||
for (const step of scenario.steps) {
|
||||
try {
|
||||
await ui.step(page, step);
|
||||
completedSteps.push(step);
|
||||
} catch (error) {
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
await page.screenshot({
|
||||
@@ -666,7 +670,7 @@ async function runSide(browser, ui, scenario, tag) {
|
||||
context = null;
|
||||
await stop();
|
||||
const dump = dumpDatabase(path.join(dataDir, 'ledger.sqlite'));
|
||||
return { total, shown, dump, problems };
|
||||
return { total, shown, dump, problems, completedSteps };
|
||||
} finally {
|
||||
await context?.close().catch(() => {});
|
||||
await stop();
|
||||
@@ -697,17 +701,26 @@ function normalized(dump) {
|
||||
}
|
||||
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const expected = frozen.filter(item => !only || item.name.includes(only));
|
||||
const selected = scenarios.filter(item => !only || item.name.includes(only));
|
||||
assert.ok(expected.length, '开单筛选没有匹配的冻结场景');
|
||||
assert.deepEqual(
|
||||
selected.map(({ name, user, steps }) => ({ name, user, steps })),
|
||||
expected,
|
||||
'开单角色、场景和输入步骤必须与冻结清单一致',
|
||||
);
|
||||
const results = [];
|
||||
const browser = await chromium.launch({ headless: !headed });
|
||||
try {
|
||||
for (const scenario of scenarios) {
|
||||
if (only && !scenario.name.includes(only)) continue;
|
||||
for (const [index, scenario] of selected.entries()) {
|
||||
const tag = scenario.name.slice(0, 2);
|
||||
console.log('▶ ' + scenario.name);
|
||||
const result = { name: scenario.name, ok: false, notes: [] };
|
||||
try {
|
||||
const oldSide = await runSide(browser, oldUi, scenario, tag);
|
||||
const newSide = await runSide(browser, newUi, scenario, tag);
|
||||
assert.deepEqual(oldSide.completedSteps, expected[index].steps, '旧版开单实际步骤 ' + scenario.name);
|
||||
assert.deepEqual(newSide.completedSteps, expected[index].steps, '新版开单实际步骤 ' + scenario.name);
|
||||
const diff = compare(normalized(oldSide.dump), normalized(newSide.dump));
|
||||
const counts = Object.fromEntries(
|
||||
['orders', 'payments', 'expenses', 'movements', 'journal', 'material_pool_usages', 'team_fund_entries'].map(
|
||||
@@ -734,6 +747,11 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
assert.deepEqual(
|
||||
results.map(r => r.name),
|
||||
expected.map(s => s.name),
|
||||
'开单已执行场景',
|
||||
);
|
||||
const failed = results.filter(r => !r.ok);
|
||||
console.log(
|
||||
`\nparity ${failed.length ? 'FAIL' : 'PASS'}:${results.length - failed.length}/${results.length} 个场景新旧界面结果一致(截图在 e2e/out/parity/)`,
|
||||
|
||||
Reference in new issue
Block a user