This commit is contained in:
2026-10-12 18:01:55 +08:00
parent 785b4bca51
commit 298681e121
8 changed files with 237 additions and 46 deletions
+29
View File
@@ -24,6 +24,35 @@ test('normal SKU input is always visible in SKU tab and never requests the new l
assert.match(source, /matches.length > 1/)
assert.match(source, /scanRelabelSku/)
})
test('return SKU follows ordinary single scan and requires explicit choice when the same SKU spans boxes', async () => {
const calls = []
let value
const subject = new Function('PortalHeader', 'RelabelPalletWork', 'ScanTargetInput', 'ReturnRelabelPackWork', 'scanRelabelSku', 'warehouseIdempotencyKey', 'releaseWarehouseKey', 'uni', body)(
{}, {}, {}, {}, async (no, payload) => { calls.push(payload); return value.current },
() => ({ value: 'KEY', signature: 'SIG' }), () => {}, { showModal: options => options.complete() }
)
value = context()
Object.assign(value, { busy: false, quickSku: '', skuChoices: [], verifiedReturnCarton: '', returnCartonCode: '',
async run(action, work) { await work() }, applyCurrent(task) { this.current = task },
setError(error) { throw error }
})
for (const name of ['submitSku', 'commitSku']) value[name] = subject.methods[name].bind(value)
value.current.relabelNo = 'RL'; value.current.version = 3
value.current.items = [{ itemId: '1', returnCartonId: 'R1', cartonMark: 'BOX-A', operationType: 'SKU_LABEL', expectedPackages: 1, relabelledPackages: 0, skippedPackages: 0, exceptionPackages: 0, skuItems: [{ skuCode: 'OLD', newSkuCode: 'NEW', quantity: 20 }] }]
await value.submitSku('OLD')
assert.deepEqual(calls, [{ itemId: '1', cartonMark: 'BOX-A', newSkuCode: 'NEW', quantity: 20, skuIndex: 0, oldSku: 'OLD', expectedVersion: 3, idempotencyKey: 'KEY' }])
calls.length = 0
value.current.items.push({ ...value.current.items[0], itemId: '2', returnCartonId: 'R2', cartonMark: 'BOX-B' })
await value.submitSku('OLD')
assert.equal(calls.length, 0)
assert.equal(value.skuChoices.length, 2)
await value.commitSku(value.skuChoices[1])
assert.equal(calls.length, 1)
assert.equal(calls[0].itemId, '2')
assert.equal(calls[0].cartonMark, 'BOX-B')
assert.doesNotMatch(source.split('<script>')[0], /name="quickTarget"|placeholder="必填:本来源该 SKU 实际件数"/)
})
test('pending list removes one confirmed row at a time without persistent empty or last-scan banners', () => {
const value = context()
assert.equal(value.pendingSkuRows.length, 2)