优化
This commit is contained in:
@@ -7,6 +7,13 @@ import { parseArguments } from '../admin-test-env-acceptance.mjs'
|
||||
|
||||
const source = await readFile(fileURLToPath(new URL('./phase4-overseas-client-services.mjs', import.meta.url)), 'utf8')
|
||||
|
||||
test('discard proof follows reserved approval and keeps actual PDA confirmation separate', () => {
|
||||
assert.match(source, /Approval retains the existing reservation without deducting stock/)
|
||||
assert.match(source, /Actual PDA confirmation deducts the confirmed quantity/)
|
||||
assert.doesNotMatch(source, /require approval-transaction deduction/)
|
||||
assert.match(source, /completed-confirm recovery\/replay/)
|
||||
})
|
||||
|
||||
test('client services module uses only stable merchant self-service paths', () => {
|
||||
for (const path of [
|
||||
'/api/merchant/v1/last-leg/orders',
|
||||
@@ -77,14 +84,14 @@ test('focused client services keeps the marker-owned merchant fixture when reusa
|
||||
assert.ok(fixture >= 0 && fixture < clientServices)
|
||||
})
|
||||
|
||||
test('discard follows formal approval deduction and keeps physical ledger evidence pending', () => {
|
||||
assert.match(source, /正式废弃合同要求审批事务扣减一箱/)
|
||||
test('discard approval retains reservation and keeps actual confirmation evidence pending', () => {
|
||||
assert.match(source, /批准只保留锁箱且库存数量流水不变/)
|
||||
assert.match(source, /废弃拒绝释放原箱且全部库存数量流水不变/)
|
||||
assert.match(source, /APPROVAL_HTTP_VERIFIED_CARTON_SQL_PENDING/)
|
||||
assert.doesNotMatch(source, /INSERT INTO|UPDATE ll_|fleet-trip|\/api\/pda\//)
|
||||
})
|
||||
|
||||
for (const fault of ['', 'pending deducts', 'reject does not release', 'approve does not deduct', 'create conflict mutates']) {
|
||||
for (const fault of ['', 'pending deducts', 'reject does not release', 'approve deducts', 'create conflict mutates']) {
|
||||
test(`discard approval stock boundaries: ${fault || 'formal approval contract'}`, async () => {
|
||||
let state = 'PENDING_REVIEW', approved = false, conflictSeen = false
|
||||
const baseline = { balances: [{customerId:'123',overseasWarehouseId:'42',availablePackages:'4'}], ledger:[],
|
||||
@@ -103,7 +110,7 @@ for (const fault of ['', 'pending deducts', 'reject does not release', 'approve
|
||||
if(body.remark.endsWith('-DIFFERENT')) {conflictSeen=true;return {http:200,body:{code:'A0409'},requestId:'req',traceId:'trace'}}
|
||||
approved=true;state='PENDING_REVIEW';data={summary:{discardNo:'NEW'}}
|
||||
} else if(path.endsWith('/balances')) {
|
||||
const changed=(state==='PENDING_REVIEW' && fault==='pending deducts') || (state==='APPROVED' && fault!=='approve does not deduct') || (conflictSeen && fault==='create conflict mutates')
|
||||
const changed=(state==='PENDING_REVIEW' && fault==='pending deducts') || (state==='APPROVED' && fault==='approve deducts') || (conflictSeen && fault==='create conflict mutates')
|
||||
data={total:'1',records:[{...baseline.balances[0],availablePackages:changed?'3':'4'}]}
|
||||
} else if(path.endsWith('/ledger')) data={total:'0',records:[]}
|
||||
else if(path.endsWith('/inventory-candidates')) data=[{...baseline.source,availablePackages:state==='REJECTED' && fault!=='reject does not release'?'4':'3'}]
|
||||
@@ -111,7 +118,7 @@ for (const fault of ['', 'pending deducts', 'reject does not release', 'approve
|
||||
return {http:200,body:{code:'200',data}}
|
||||
}}
|
||||
await assert.rejects(verifyDiscardApproval(context,'merchant',{idempotencyKey:'key',remark:'fixture'},'OLD',proof),
|
||||
fault ? /仅锁定|释放原箱|审批事务扣减|异载荷拒绝后/ : /CHECKPOINT_PASSED/)
|
||||
fault ? /仅锁定|释放原箱|只保留锁箱|异载荷拒绝后/ : /CHECKPOINT_PASSED/)
|
||||
assert.ok(!calls.some(call=>call.raw.includes('/pda/')))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user