修复四项新版开单和恢复差异,核验三项已确认行为
This commit is contained in:
1 parent
fdaa6afad5
commit
c29ea45ec4
25 files changed
+617
-171
No files matched your search
@@ -28,6 +28,12 @@ export default async function recoveryQuote(ctx) {
|
||||
await owner.locator('[data-action=recovery-mode][data-mode=exchange]').click();
|
||||
const form = owner.locator('#recovery-form');
|
||||
const field = name => form.locator('[name="' + name + '"]');
|
||||
let original;
|
||||
function captureQuote(request) {
|
||||
if (new URL(request.url()).pathname === '/api/recoveries/quote' && request.method() === 'POST')
|
||||
original = request.postDataJSON();
|
||||
}
|
||||
owner.on('request', captureQuote);
|
||||
await ctx.step('置换试算列出个人和公共料各自的用量、成本与前后余额', async () => {
|
||||
await field('customer').fill('核对两种扣料来源');
|
||||
await form.locator('[name=customer_type][value=new]').check();
|
||||
@@ -55,4 +61,65 @@ export default async function recoveryQuote(ctx) {
|
||||
'实际置换料池试算:' + shown,
|
||||
);
|
||||
});
|
||||
owner.off('request', captureQuote);
|
||||
const status = owner.locator('#recovery-quote-status');
|
||||
const note = owner.locator('#recovery-material-note');
|
||||
await ctx.step('余额读取失败时继续展示扣料来源和已核对的结算', async () => {
|
||||
const balanceUrl = ctx.base + '/api/material-pools/quote';
|
||||
const unavailable = route => route.fulfill({ status: 503, json: { error: '对照余额暂不可用' } });
|
||||
await owner.route(balanceUrl, unavailable);
|
||||
try {
|
||||
await field('new_quantity').fill('3.200');
|
||||
await note.getByText(/个人与公共余量暂未读到,请刷新核对/).waitFor();
|
||||
await status.getByText(/结算已核对/).waitFor();
|
||||
const shown = await note.innerText();
|
||||
assert.ok(shown.includes('个人回收料 0.400g · ¥320.00') && shown.includes('公共料 0.800g · ¥720.00'), shown);
|
||||
} finally {
|
||||
await owner.unroute(balanceUrl, unavailable);
|
||||
}
|
||||
});
|
||||
await ctx.step('分来源成本合计与服务端总额不符时提示重新核对', async () => {
|
||||
const quoteUrl = ctx.base + '/api/recoveries/quote';
|
||||
const inconsistent = async route => {
|
||||
const res = await route.fetch();
|
||||
try {
|
||||
const reply = await res.json();
|
||||
assert.ok(Number.isSafeInteger(reply.materialCost));
|
||||
await route.fulfill({ json: { ...reply, materialCost: reply.materialCost + 1 } });
|
||||
} finally {
|
||||
await res.dispose();
|
||||
}
|
||||
};
|
||||
await owner.route(quoteUrl, inconsistent);
|
||||
try {
|
||||
await field('new_quantity').fill('3.500');
|
||||
await status.getByText(/置换用料来源与当前归属不一致,请重新核对/).waitFor();
|
||||
} finally {
|
||||
await owner.unroute(quoteUrl, inconsistent);
|
||||
}
|
||||
});
|
||||
await session.post('owner', '/api/stock', {
|
||||
date: day,
|
||||
kind: 'increase',
|
||||
grams: '3',
|
||||
pocket: '现货',
|
||||
note: '原置换的出货库存',
|
||||
});
|
||||
const historical = await session.post('owner', '/api/recoveries', { ...original, verified: true });
|
||||
assert.deepEqual(session.problems, []);
|
||||
await section(owner, ctx, 'recoveries');
|
||||
await owner
|
||||
.locator('[data-action=recovery-open][data-id="' + historical.id + '"]')
|
||||
.first()
|
||||
.click();
|
||||
await owner.locator('#recovery-dialog[open] [data-action=recovery-edit-open]').click();
|
||||
await ctx.step('修改已有置换单时排除原单耗用并列出扣料前后结余', async () => {
|
||||
await field('change_reason').fill('复核原料池');
|
||||
await field('new_quantity').fill('3.200');
|
||||
await note.getByText(/原单耗用已排除/).waitFor();
|
||||
const shown = await note.innerText();
|
||||
assert.ok(shown.includes('个人回收料 0.400g · ¥320.00') && shown.includes('公共料 0.800g · ¥720.00'), shown);
|
||||
assert.ok(shown.includes('本次前可用:个人 0.400g,公共 8.000g'), shown);
|
||||
assert.ok(shown.includes('本次后余:个人回收料 0.000g,公共料 7.200g'), shown);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user