import test from 'node:test' import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' const read = (path) => readFile(new URL(path, import.meta.url), 'utf8') const page = await read('../pages/dropship-palletization/dropship-palletization.vue') const api = await read('../api/pda-dropship.js') test('pending cartons bind to pregenerated pallets with stable retry identity', async () => { const { stableOperationId } = await import('../utils/idempotency.js') const payload = { warehouseId: '9007199254740993', palletNo: 'DP-260914-0001', taskVersion: 7 } assert.equal(stableOperationId('dropship-bind', 'u-task', payload), stableOperationId('dropship-bind', 'u-task', { ...payload })) assert.notEqual(stableOperationId('dropship-bind', 'u-task', payload), stableOperationId('dropship-bind', 'u-task', { ...payload, taskVersion: 8 })) assert.match(api, /pallets\/bind-pending/) assert.doesNotMatch(api, /create-and-bind/) assert.match(page, /bindDropshipPendingCartons\(this.taskId, this.warehouseId, code, this.task.version\)/) }) test('palletization uses the test workbench and canonical routes', async () => { const pages = await read('../pages.json') assert.match(pages, /pages\/dropship-tasks\/dropship-tasks/) assert.match(pages, /pages\/dropship-palletization\/dropship-palletization/) assert.doesNotMatch(pages, /dropship-palletizing/) assert.match(await read('../pages/home/home.vue'), /'一件代发': '\/pages\/dropship-tasks\/dropship-tasks'/) }) test('formal palletization preserves both scan orders, moves, sealing and safe unsealing', () => { for (const symbol of ['resolveDropshipCarton', 'countDropshipCarton', 'bindDropshipPendingCartons', 'moveDropshipCarton', 'sealDropshipPallet', 'unsealDropshipPallet', 'planDropshipScan', 'restoreDropshipPalletizingDraft']) assert.ok(page.includes(symbol)) assert.match(page, /移回待绑托/) assert.match(page, /palletSetupReady/) assert.match(page, /pallet\?\.status === 'SEALED'/) assert.match(page, /currentPalletDetails\?\.cartons/) assert.match(page, / { assert.match(page, /v-for="\(line, index\) in skuCounts"/) assert.match(page, /quantity-stepper/) assert.doesNotMatch(page, /printPallet|printAllPallets|打开当前托盘 A4 单|打开全部 A4 托盘单/) }) test('count, move, seal and unseal use the formal contract with versioned retries', () => { for (const path of ['cartons/count', 'pallets/bind-pending', '/move', '/seal', '/unseal']) assert.ok(api.includes(path)) for (const field of ['skuLines', 'actualQuantity', 'discrepancyAction', 'discrepancyRemark']) assert.ok(page.includes(field)) assert.match(api, /expectedVersion: pallet.version/) assert.match(api, /stableOperationId/) assert.doesNotMatch(api, /actualSkuQuantity|create-and-bind/) }) test('a counted carton moved back to pending can be confirmed into the active pallet without recounting', () => { assert.match(page, /isResolvedPendingCarton\(\) \{ return this\.carton\?\.countStatus === 'COUNTED_UNBOUND' \}/) assert.match(page, /canRebindResolvedCarton/) assert.match(page, /确认归入当前托盘/) assert.match(page, /moveDropshipCarton\(this\.taskId, this\.carton\.cartonId, payload\)/) assert.match(page, /line\.actualQuantity \?\? line\.expectedQuantity/) })