fix(pda): stage sealed pallet scans for atomic batch picking

This commit is contained in:
2026-09-09 12:29:46 +08:00
parent 0745e9600c
commit b19cecb54f
10 changed files with 136 additions and 11 deletions
+24
View File
@@ -4,6 +4,30 @@ import { readFile } from 'node:fs/promises'
const read = (path) => readFile(new URL(path, import.meta.url), 'utf8')
test('system pallet action binds through one request and keeps the same operation on retry', async () => {
const page = await read('../pages/dropship-palletizing/dropship-palletizing.vue')
const method = page.slice(page.indexOf('async createPallet()'), page.indexOf('statusLabel(status)'))
const requests = []
const { stableOperationId } = await import('../utils/idempotency.js')
const methods = new Function('createAndBindDropshipPallet', 'stableOperationId', 'playSuccessSound', 'playErrorSound', 'formatApiError', `return ({${method}})`)(async (taskId, payload) => {
requests.push({ taskId, payload })
if (requests.length === 1) throw new Error('network timeout')
return { taskStatus: 'CLAIMED', unbound: [], pallets: [{ palletNo: 'DP-260909-0001', cartons: [{ cartonId: '9007199254740993' }] }] }
}, stableOperationId, () => {}, () => {}, (error) => error.message)
const context = { busy: false, online: true, task: { taskStatus: 'CLAIMED' }, taskId: '10', warehouseId: '100', user: { id: '7' }, unboundCartons: [{ cartonId: '9007199254740993' }], scanState: {}, persistDraft() {}, get pallets() { return this.task.pallets || [] } }
await methods.createPallet.call(context)
assert.equal(context.error, 'network timeout')
assert.equal(context.busy, false)
await methods.createPallet.call(context)
assert.deepEqual(requests[0], requests[1])
assert.equal(context.activePalletNo, 'DP-260909-0001')
assert.equal(context.scanState.activePalletNo, context.activePalletNo)
context.unboundCartons = []
await methods.createPallet.call(context)
assert.equal(requests.length, 2)
assert.match(page, /新建托盘并绑定/)
})
test('dropship palletizing route and workbench entry are registered', async () => {
const [pages, data, home, modulePage] = await Promise.all([read('../pages.json'), read('../data/demo-data.js'), read('../pages/home/home.vue'), read('../pages/module/module.vue')])
assert.match(pages, /pages\/dropship-palletizing\/tasks/)