修复四项新版开单和恢复差异,核验三项已确认行为
This commit is contained in:
1 parent
fdaa6afad5
commit
c29ea45ec4
25 files changed
+617
-171
No files matched your search
@@ -0,0 +1,78 @@
|
||||
// 已确认的 D2 / D7 只生成预期请求副本。实际抓包和每个时点的原始账本均由 runner 保留。
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
const poolStep = '撤销退回现货选择并切换日期后按料池实际开单';
|
||||
const cancelStockStep = '取消退回现货选择后按原输入开单';
|
||||
const issueSteps = {
|
||||
issue: new Set(['多件公式识别后实际开单', '毫克克重与含前导零的分位金额实际开单', cancelStockStep, '整批退回现货沿用原工费再次销售']),
|
||||
'issue-reopen': new Set(['首笔普通两件商品完成销售', '新标签页从首页录入第二笔销售']),
|
||||
'issue-pool-date': new Set([poolStep]),
|
||||
};
|
||||
|
||||
// 固定旧页面把部分可见控件值额外平铺在行上。每项须能从同一个请求的业务字段还原。
|
||||
function duplicateInputs(line) {
|
||||
const pool = line.costMaterial.mode === 'pool';
|
||||
const inputs = {
|
||||
'cost-materialSource': pool ? 'pool' : 'manual',
|
||||
'cost-materialPoolId': line.materialPoolDraft.poolId,
|
||||
'cost-materialMode': pool ? 'total' : line.costMaterial.mode,
|
||||
'cost-materialRate': pool ? (line.materialPool.averageRate / 100).toFixed(2) : line.costMaterial.rate,
|
||||
'cost-material': line.costParts.material,
|
||||
'cost-materialPayer': line.costPayers.material,
|
||||
'cost-laborMode': line.costLabor.mode,
|
||||
'cost-laborRate': line.costLabor.rate ?? '',
|
||||
'cost-labor': line.costParts.labor,
|
||||
'cost-laborPayer': line.costPayers.labor,
|
||||
'cost-accessories': line.costParts.accessories,
|
||||
'cost-other': line.costParts.other,
|
||||
};
|
||||
if (pool) {
|
||||
assert.equal(line.costPayers.material, 'owner', '本组两个单料池样本由麦麦垫付');
|
||||
inputs['cost-materialPoolPayer'] = '麦麦';
|
||||
}
|
||||
if (!line.returnedStockId) inputs.returnedStockId = '';
|
||||
return inputs;
|
||||
}
|
||||
|
||||
export function assertIssueInputs(version, payload) {
|
||||
for (const line of payload.lines) {
|
||||
for (const [key, expected] of Object.entries(duplicateInputs(line))) {
|
||||
if (version === 'old') assert.equal(line[key], expected, '旧页面控件须与实际业务输入一致 ' + key);
|
||||
else assert.ok(!Object.hasOwn(line, key), '新版应仅提交业务输入 ' + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function expectedIssueResult(group, oldResult, explicitPoolResult) {
|
||||
if (!Object.hasOwn(issueSteps, group)) return oldResult;
|
||||
let reference = oldResult;
|
||||
if (group === 'issue-pool-date') {
|
||||
// 使用同一固定旧版本、相同初始账本的另一笔真实 UI 写入,仅将用户选中的料池改为订单日期。
|
||||
// 该请求的写后数据库、步骤后数据库及终态均是完整的旧版账本,不能屏蔽其金额、版本或流水字段。
|
||||
assert.ok(explicitPoolResult, '缺少旧版实际选用订单日期的账本');
|
||||
assert.deepEqual(Object.keys(explicitPoolResult.steps), [poolStep]);
|
||||
assert.deepEqual(explicitPoolResult.steps[poolStep].before, oldResult.steps[poolStep].before, '两个独立旧账本起点不一致');
|
||||
reference = explicitPoolResult;
|
||||
}
|
||||
const expected = structuredClone(reference);
|
||||
for (const label of issueSteps[group]) {
|
||||
const capture = expected.steps[label];
|
||||
if (!capture) continue; // 未执行的用例由 runner 的 failures 和步骤比较报告。
|
||||
assert.equal(capture.requests.length, 1, label);
|
||||
const [request] = capture.requests;
|
||||
assert.equal(request.endpoint, '/api/orders/issue', label);
|
||||
assert.equal(request.status, 200, label);
|
||||
assertIssueInputs('old', request.payload);
|
||||
for (const line of request.payload.lines) {
|
||||
for (const key of Object.keys(duplicateInputs(line))) delete line[key];
|
||||
}
|
||||
if (label === cancelStockStep || label === poolStep) {
|
||||
assert.equal(request.payload.lines.length, 1, label);
|
||||
const draft = request.payload.lines[0].materialPoolDraft;
|
||||
assert.equal(draft.defaultDate, false, label);
|
||||
assert.equal(draft.poolId, request.payload.date, label);
|
||||
draft.defaultDate = true;
|
||||
}
|
||||
}
|
||||
return expected;
|
||||
}
|
||||
Reference in new issue
Block a user