丢弃过期托盘校验响应并防止错误实收
This commit is contained in:
@@ -91,6 +91,79 @@ test('an incompatible pallet never reports success and a corrected scan can be v
|
||||
assert.equal(successes, 1)
|
||||
})
|
||||
|
||||
test('late pallet validation cannot replace edited input and only the corrected pallet can be received', async t => {
|
||||
store.resetReceivingSession(); store.setCurrentReceiving(sessionValue())
|
||||
store.receiving.resolvedCarton = { inboundCode: 'IN-A', cartonMark: 'IN-A#22-1', destinationType: 'FBA' }
|
||||
const pending = defer(), receipts = [], calls = [], toasts = []; let successes = 0
|
||||
const { vm } = page({ toReceivingError, playSuccessSound: () => successes++,
|
||||
resolveCurrentPallet: (palletCode, inboundCode) => {
|
||||
calls.push({ palletCode, inboundCode })
|
||||
return palletCode === 'PALLET-A' ? pending.promise : Promise.resolve({ palletCode, compatible: true, version: 2, currentReceivedPackages: 3 })
|
||||
},
|
||||
receiveCurrentBulk: async payload => { receipts.push(payload); return {} },
|
||||
getCurrentReceiving: async () => sessionValue(),
|
||||
})
|
||||
t.after(() => vm.suspendReceiving())
|
||||
vm.showToast = (message, type) => toasts.push({ message, type }); vm.applyCurrentReceiving = async () => {}
|
||||
const validation = vm.resolvePallet('PALLET-A')
|
||||
vm.palletInput = 'PALLET-B'
|
||||
pending.resolve({ palletCode: 'PALLET-A', compatible: true, version: 1, currentReceivedPackages: 3 })
|
||||
await validation
|
||||
assert.equal(vm.palletInput, 'PALLET-B')
|
||||
assert.equal(vm.resolvedPallet, null)
|
||||
assert.equal(vm.packageCount, '')
|
||||
assert.equal(vm.canSubmitReceipt, false)
|
||||
assert.equal(vm.busy, false)
|
||||
assert.equal(successes, 0)
|
||||
assert.deepEqual(toasts, [])
|
||||
await vm.submitReceipt(); assert.equal(receipts.length, 0)
|
||||
await vm.resolvePallet('PALLET-B')
|
||||
assert.equal(vm.canSubmitReceipt, true)
|
||||
assert.equal(successes, 1)
|
||||
await vm.submitReceipt()
|
||||
assert.deepEqual(calls, [{ palletCode: 'PALLET-A', inboundCode: 'IN-A' }, { palletCode: 'PALLET-B', inboundCode: 'IN-A' }])
|
||||
assert.deepEqual(receipts.map(({ palletCode }) => palletCode), ['PALLET-B'])
|
||||
})
|
||||
|
||||
test('obsolete pallet failures cannot replace current input or feedback', async t => {
|
||||
store.resetReceivingSession(); store.setCurrentReceiving(sessionValue())
|
||||
store.receiving.resolvedCarton = { inboundCode: 'IN-A', cartonMark: 'IN-A#22-1', destinationType: 'FBA' }
|
||||
const pending = defer(), toasts = []; let failures = 0
|
||||
const { vm } = page({ toReceivingError, resolveCurrentPallet: () => pending.promise, playErrorSound: () => failures++ })
|
||||
t.after(() => vm.suspendReceiving()); vm.showToast = (message, type) => toasts.push({ message, type })
|
||||
const validation = vm.resolvePallet('PALLET-A')
|
||||
vm.palletInput = 'PALLET-B'
|
||||
pending.reject(Object.assign(new Error('Pallet code is not part of the current FBA destination group'), { code: 'A0404' }))
|
||||
await validation
|
||||
assert.equal(vm.palletInput, 'PALLET-B'); assert.equal(vm.error, null)
|
||||
assert.equal(vm.resolvedPallet, null); assert.equal(vm.canSubmitReceipt, false)
|
||||
assert.equal(vm.busy, false); assert.equal(failures, 0); assert.deepEqual(toasts, [])
|
||||
})
|
||||
|
||||
test('late pallet validation cannot cross a receiving context or page lifetime', async t => {
|
||||
for (const [name, change] of [
|
||||
['carton', () => { store.receiving.resolvedCarton = { inboundCode: 'IN-B', cartonMark: 'IN-B#1', destinationType: 'FBA' } }],
|
||||
['container', () => store.setCurrentReceiving(sessionValue({ containerNo: 'CAB-B' }))],
|
||||
['operator', ({ deps }) => { deps.session.currentUser = { id: 'another-operator', warehouseId: '900' } }],
|
||||
['warehouse', ({ deps }) => { deps.session.currentUser.warehouseId = '901' }],
|
||||
['hide and return', ({ vm, definition }) => { definition.onHide.call(vm); definition.onShow.call(vm) }],
|
||||
]) await t.test(name, async t => {
|
||||
store.resetReceivingSession(); store.setCurrentReceiving(sessionValue())
|
||||
store.receiving.resolvedCarton = { inboundCode: 'IN-A', cartonMark: 'IN-A#22-1', destinationType: 'FBA' }
|
||||
const pending = defer(), toasts = []; let successes = 0
|
||||
const context = page({ toReceivingError, resolveCurrentPallet: () => pending.promise, playSuccessSound: () => successes++ })
|
||||
const { vm } = context
|
||||
t.after(() => vm.suspendReceiving()); vm.bootstrap = async () => {}; vm.showToast = (message, type) => toasts.push({ message, type })
|
||||
const validation = vm.resolvePallet('PALLET-A')
|
||||
change(context)
|
||||
pending.resolve({ palletCode: 'PALLET-A', compatible: true, version: 1, currentReceivedPackages: 3 })
|
||||
await validation
|
||||
assert.equal(vm.resolvedPallet, null); assert.equal(vm.packageCount, '')
|
||||
assert.equal(vm.canSubmitReceipt, false); assert.equal(vm.busy, false)
|
||||
assert.equal(successes, 0); assert.deepEqual(toasts, [])
|
||||
})
|
||||
})
|
||||
|
||||
test('signed photo changes, account/customer/cabinet changes and image failure cannot inherit stale previews', async () => {
|
||||
store.resetReceivingSession(); let calls = 0
|
||||
const { vm, deps } = page({ downloadCurrentUnloadPhoto: async () => `local:${++calls}`, downloadCurrentDomesticLoadingPhoto: async () => '' })
|
||||
|
||||
Reference in New Issue
Block a user