优化
This commit is contained in:
@@ -70,3 +70,49 @@ test('switching tickets carries only validated open pallet and scanner cannot ra
|
||||
await state.selectPallet('DP-261019-0002')
|
||||
assert.equal(state.currentPallet.palletNo, pallet.palletNo)
|
||||
})
|
||||
|
||||
test('reopening a task drops a pallet sealed since the draft was saved without mutating business facts', async () => {
|
||||
const cleared = []
|
||||
const { state, pallet, calls } = harness({ clearDropshipPalletizingDraft: (identity) => cleared.push(identity) })
|
||||
pallet.status = 'SEALED'
|
||||
state.selectedPalletNo = pallet.palletNo; state.palletCode = pallet.palletNo; state.selectedPalletId = pallet.palletId
|
||||
await state.loadTask({ restorePallet: true })
|
||||
assert.equal(state.currentPallet, null)
|
||||
assert.equal(state.selectedPalletNo, '')
|
||||
assert.equal(state.selectedPalletId, '')
|
||||
assert.equal(state.palletCode, '')
|
||||
assert.equal(cleared.length, 1)
|
||||
assert.equal(cleared[0].taskId, '10')
|
||||
assert.deepEqual(calls.map(call => call[0]), ['get'])
|
||||
})
|
||||
|
||||
test('restoring open cross customer pallet still works and explicit sealed scan remains inspectable', async () => {
|
||||
const { state, pallet } = harness()
|
||||
state.selectedPalletNo = pallet.palletNo
|
||||
await state.loadTask({ restorePallet: true })
|
||||
assert.equal(state.currentPallet.palletNo, pallet.palletNo)
|
||||
pallet.status = 'SEALED'
|
||||
await state.selectPallet(pallet.palletNo)
|
||||
assert.equal(state.currentPallet.status, 'SEALED')
|
||||
assert.equal(state.canSubmitCarton, false)
|
||||
})
|
||||
|
||||
test('task list stops carrying a pallet sealed while another ticket was being worked', async () => {
|
||||
const taskSource = await readFile(new URL('../pages/dropship-tasks/dropship-tasks.vue', import.meta.url), 'utf8')
|
||||
const taskScript = taskSource.match(/<script>([\s\S]*?)<\/script>/)[1].replace(/^\s*import .*$/gm, '').replace('export default', 'globalThis.page =')
|
||||
let status = 'OPEN'
|
||||
const navigations = []
|
||||
const context = { PortalHeader: {}, ScanTargetInput: {}, session: { currentUser: { warehouseId: '100' } },
|
||||
resolveDropshipWorkspacePallet: async () => ({ pallet: { status } }),
|
||||
listDropshipPalletizationTasks: async () => [], formatApiError: error => error.message,
|
||||
uni: { navigateTo: value => navigations.push(value.url) } }
|
||||
vm.runInNewContext(taskScript, context)
|
||||
const state = Object.assign(context.page.data(), context.page.methods, { palletNo: 'DP-261019-0014' })
|
||||
const task = { taskId: '20', warehouseId: '100' }
|
||||
await state.loadTasks(); state.openTask(task)
|
||||
assert.match(navigations[0], /palletNo=DP-261019-0014/)
|
||||
status = 'SEALED'
|
||||
await state.loadTasks(); state.openTask(task)
|
||||
assert.equal(state.palletNo, '')
|
||||
assert.ok(!navigations[1].includes('DP-261019-0014'))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user