feat: add dropship palletization workflow
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
|
||||
const source = await readFile(new URL('../utils/dropship-palletizing-state.js', import.meta.url), 'utf8')
|
||||
const state = await import(`data:text/javascript;base64,${Buffer.from(source).toString('base64')}`)
|
||||
|
||||
test('pallet first selects the pallet and later carton resolution carries it', () => {
|
||||
let scanState = state.createDropshipScanState()
|
||||
let plan = state.planDropshipScan(scanState, 'dp-260908-0001')
|
||||
assert.equal(plan.intent, state.DROPSHIP_SCAN_INTENT.SELECT_PALLET)
|
||||
scanState = state.releaseDropshipScan(plan.state)
|
||||
plan = state.planDropshipScan(scanState, 'box-001')
|
||||
assert.deepEqual({ intent: plan.intent, boxCode: plan.boxCode, palletNo: plan.palletNo }, { intent: state.DROPSHIP_SCAN_INTENT.RESOLVE_CARTON, boxCode: 'BOX-001', palletNo: 'DP-260908-0001' })
|
||||
})
|
||||
|
||||
test('boxes first requests batch binding when a pallet is scanned with pending cartons', () => {
|
||||
const plan = state.planDropshipScan(state.createDropshipScanState(), 'DP-260908-0002', { unboundCartons: 3 })
|
||||
assert.equal(plan.intent, state.DROPSHIP_SCAN_INTENT.BIND_PENDING)
|
||||
assert.equal(plan.palletNo, 'DP-260908-0002')
|
||||
})
|
||||
|
||||
test('offline, empty, and immediate repeated scans are blocked before API intent', () => {
|
||||
assert.equal(state.planDropshipScan(state.createDropshipScanState({ online: false }), 'BOX-001').intent, state.DROPSHIP_SCAN_INTENT.BLOCKED)
|
||||
assert.equal(state.planDropshipScan(state.createDropshipScanState(), ' ').intent, state.DROPSHIP_SCAN_INTENT.INVALID)
|
||||
const first = state.planDropshipScan(state.createDropshipScanState(), 'BOX-001')
|
||||
assert.equal(state.planDropshipScan(first.state, 'BOX-001').intent, state.DROPSHIP_SCAN_INTENT.DUPLICATE)
|
||||
})
|
||||
Reference in New Issue
Block a user