补齐固定旧版的浏览器逐笔写入对照并记录账务差异
This commit is contained in:
1 parent
e77588b337
commit
7d2007955f
39 files changed
+3653
-41
No files matched your search
@@ -362,7 +362,7 @@ const OLD_FIELDS = {
|
||||
laborMode: 'select',
|
||||
pocket: 'select',
|
||||
};
|
||||
const oldUi = {
|
||||
export const oldUi = {
|
||||
label: '旧界面',
|
||||
async open(page, base) {
|
||||
await page.goto(base + '/');
|
||||
@@ -495,7 +495,7 @@ async function chooseNew(page, scope, field, label) {
|
||||
async function radioNew(scope, field, label) {
|
||||
await scope.locator(`[data-field="${field}"] .ant-radio-button-wrapper`, { hasText: label }).first().click();
|
||||
}
|
||||
const newUi = {
|
||||
export const newUi = {
|
||||
label: '新界面',
|
||||
async open(page, base) {
|
||||
await page.goto(base + '/next/');
|
||||
@@ -696,45 +696,47 @@ function normalized(dump) {
|
||||
return out;
|
||||
}
|
||||
|
||||
const results = [];
|
||||
const browser = await chromium.launch({ headless: !headed });
|
||||
try {
|
||||
for (const scenario of scenarios) {
|
||||
if (only && !scenario.name.includes(only)) continue;
|
||||
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);
|
||||
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(
|
||||
t => [t, newSide.dump.tables[t]?.rows.length ?? 0],
|
||||
),
|
||||
);
|
||||
result.problems = [...oldSide.problems, ...newSide.problems];
|
||||
if (oldSide.total !== newSide.total)
|
||||
result.problems.push(`成交合计不同:旧 ${oldSide.total},新 ${newSide.total}`);
|
||||
if (newSide.shown.total !== newSide.total)
|
||||
result.problems.push(`新界面开单后显示合计 ${newSide.shown.total} 与表单合计 ${newSide.total} 不同`);
|
||||
if (!oldSide.shown.paper || oldSide.shown.paper !== newSide.shown.paper)
|
||||
result.problems.push(`纸单号不同:旧 ${oldSide.shown.paper},新 ${newSide.shown.paper}`);
|
||||
if (diff.diffs.length) result.problems.push(report('数据库', diff, 20));
|
||||
result.ok = result.problems.length === 0;
|
||||
result.detail = `合计 ${newSide.total} · 纸单号 ${newSide.shown.paper} · 行数 ${JSON.stringify(counts)}`;
|
||||
} catch (error) {
|
||||
result.problems = [`运行中断:${error.message.split('\n').slice(0, 3).join(' ')}`];
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
const results = [];
|
||||
const browser = await chromium.launch({ headless: !headed });
|
||||
try {
|
||||
for (const scenario of scenarios) {
|
||||
if (only && !scenario.name.includes(only)) continue;
|
||||
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);
|
||||
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(
|
||||
t => [t, newSide.dump.tables[t]?.rows.length ?? 0],
|
||||
),
|
||||
);
|
||||
result.problems = [...oldSide.problems, ...newSide.problems];
|
||||
if (oldSide.total !== newSide.total)
|
||||
result.problems.push(`成交合计不同:旧 ${oldSide.total},新 ${newSide.total}`);
|
||||
if (newSide.shown.total !== newSide.total)
|
||||
result.problems.push(`新界面开单后显示合计 ${newSide.shown.total} 与表单合计 ${newSide.total} 不同`);
|
||||
if (!oldSide.shown.paper || oldSide.shown.paper !== newSide.shown.paper)
|
||||
result.problems.push(`纸单号不同:旧 ${oldSide.shown.paper},新 ${newSide.shown.paper}`);
|
||||
if (diff.diffs.length) result.problems.push(report('数据库', diff, 20));
|
||||
result.ok = result.problems.length === 0;
|
||||
result.detail = `合计 ${newSide.total} · 纸单号 ${newSide.shown.paper} · 行数 ${JSON.stringify(counts)}`;
|
||||
} catch (error) {
|
||||
result.problems = [`运行中断:${error.message.split('\n').slice(0, 3).join(' ')}`];
|
||||
}
|
||||
results.push(result);
|
||||
console.log(` ${result.ok ? '✓ 一致' : '✗ 不一致'} ${result.detail || ''}`);
|
||||
for (const p of result.problems) console.log(' ' + p.replace(/\n/g, '\n '));
|
||||
}
|
||||
results.push(result);
|
||||
console.log(` ${result.ok ? '✓ 一致' : '✗ 不一致'} ${result.detail || ''}`);
|
||||
for (const p of result.problems) console.log(' ' + p.replace(/\n/g, '\n '));
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
const failed = results.filter(r => !r.ok);
|
||||
console.log(
|
||||
`\nparity ${failed.length ? 'FAIL' : 'PASS'}:${results.length - failed.length}/${results.length} 个场景新旧界面结果一致(截图在 e2e/out/parity/)`,
|
||||
);
|
||||
process.exitCode = failed.length ? 1 : 0;
|
||||
}
|
||||
const failed = results.filter(r => !r.ok);
|
||||
console.log(
|
||||
`\nparity ${failed.length ? 'FAIL' : 'PASS'}:${results.length - failed.length}/${results.length} 个场景新旧界面结果一致(截图在 e2e/out/parity/)`,
|
||||
);
|
||||
process.exitCode = failed.length ? 1 : 0;
|
||||
Reference in new issue
Block a user