优化
This commit is contained in:
@@ -23,6 +23,22 @@ function setup(confirm, saved = new Map(), scope = 'operator:warehouse') {
|
||||
return instance
|
||||
}
|
||||
|
||||
test('SKU lookup displays all pending order lines while retaining scanned SKU for pallet generation', () => {
|
||||
const source = readFileSync(new URL('../src/pages/return-receipt/return-receipt.vue', import.meta.url), 'utf8')
|
||||
const script = source.match(/<script[^>]*>([\s\S]*?)<\/script>/)[1]
|
||||
const component = vm.runInNewContext(script.replace(/^\s*import .*$/mg, '').replace('export default', 'globalThis.component ='), { PortalHeader: {}, ScanTargetInput: {} })
|
||||
const lines = [{ skuCode: 'SKU-A', expectedQuantity: 6 }, { skuCode: 'SKU-B', expectedQuantity: 4 }]
|
||||
const instance = { current: { expectedItems: lines }, selectedSku: 'SKU-A' }
|
||||
instance.selectedItems = component.computed.selectedItems.call(instance)
|
||||
assert.equal(instance.selectedItems.length, 2)
|
||||
assert.equal(instance.selectedItems[1].skuCode, 'SKU-B')
|
||||
assert.equal(component.computed.activeSkuCode.call(instance), 'SKU-A')
|
||||
instance.selectedSku = ''
|
||||
assert.equal(component.computed.activeSkuCode.call(instance), 'SKU-A')
|
||||
instance.selectedSku = 'SKU-FROM-PREVIOUS-ORDER'
|
||||
assert.equal(component.computed.activeSkuCode.call(instance), 'SKU-A')
|
||||
})
|
||||
|
||||
test('PALLET page submits the required palletCode through the actual confirmation method', async () => {
|
||||
const calls = []
|
||||
const page = setup(async payload => { calls.push(JSON.parse(JSON.stringify(payload))); return { palletCode: payload.palletCode } })
|
||||
@@ -41,6 +57,19 @@ test('PALLET page submits the required palletCode through the actual confirmatio
|
||||
assert.equal(page.current, null)
|
||||
})
|
||||
|
||||
test('partial receipt continues the same order with fresh pallet measurements', async () => {
|
||||
const page = setup(async () => ({}))
|
||||
page.finishReceipt([{ fullyMatched: false }])
|
||||
assert.equal(page.result.continuationReturnNo, 'RT-TEST')
|
||||
let reopened
|
||||
page.openOrderValue = async returnNo => { reopened = returnNo; page.current = { returnNo } }
|
||||
await page.nextReceipt()
|
||||
assert.equal(reopened, 'RT-TEST')
|
||||
assert.equal(page.result, null)
|
||||
assert.equal(page.palletLength, '')
|
||||
assert.equal(page.palletWeight, '')
|
||||
})
|
||||
|
||||
test('PALLET response failure keeps the draft and same idempotency key for retry', async () => {
|
||||
const calls = []
|
||||
const page = setup(async payload => { calls.push(JSON.parse(JSON.stringify(payload))); throw new Error('Response lost') })
|
||||
@@ -52,3 +81,32 @@ test('PALLET response failure keeps the draft and same idempotency key for retry
|
||||
assert.equal(calls.length, 2)
|
||||
assert.equal(calls[0].idempotencyKey, calls[1].idempotencyKey)
|
||||
})
|
||||
|
||||
test('continue signing returns to SKU scanning and accepts a fresh scan', () => {
|
||||
const page = setup(async () => ({}))
|
||||
page.finishReceipt([{ fullyMatched: false }])
|
||||
page.lookupCode = 'PREVIOUS-SKU'
|
||||
page.selectedSku = 'PREVIOUS-SKU'
|
||||
page.palletCheck = { palletCode: 'PLT-TEST' }
|
||||
page.photoFileIds = ['previous-photo']
|
||||
page.busy = true
|
||||
page.continueScanning()
|
||||
assert.ok(page.result)
|
||||
page.busy = false
|
||||
page.continueScanning()
|
||||
assert.equal(page.result, null)
|
||||
assert.equal(page.current, null)
|
||||
assert.equal(page.candidates, null)
|
||||
assert.equal(page.activeTarget, 'lookup')
|
||||
assert.equal(page.entryMode, 'SKU')
|
||||
assert.equal(page.lookupCode, '')
|
||||
assert.equal(page.selectedSku, '')
|
||||
assert.equal(page.palletCheck, null)
|
||||
assert.equal(page.palletLength, '')
|
||||
assert.equal(page.photoFileIds.length, 0)
|
||||
let scanned
|
||||
page.lookup = value => { scanned = value }
|
||||
page.handleScan('NEXT-SKU')
|
||||
assert.equal(scanned, 'NEXT-SKU')
|
||||
assert.equal(page.lookupCode, 'NEXT-SKU')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user