优化
This commit is contained in:
@@ -46,7 +46,7 @@ test('schedule interleaves three modes and uses FBA cumulative count rather than
|
||||
})
|
||||
|
||||
function driver({ earlyComplete = false, wrongModeAccepted = false, drift = false, repeatIncrement = false,
|
||||
changedPayloadAccepted = false } = {}) {
|
||||
changedPayloadAccepted = false, foreignPalletAccepted = false } = {}) {
|
||||
const group = fixtures()
|
||||
const expected = new Map(group.map(r => [r.source.inboundCode, 0]))
|
||||
const schedule = mixedReceivingSchedule(group)
|
||||
@@ -60,6 +60,9 @@ function driver({ earlyComplete = false, wrongModeAccepted = false, drift = fals
|
||||
receivedPackages, pendingPackages: 4 - receivedPackages })) })
|
||||
return { group, marker: 'MIXED-TEST', check: (name, _response, passed) => assert.ok(passed, name),
|
||||
request: async (_method, path, body) => {
|
||||
if (path.endsWith('/pallets/resolve')) return { body: {
|
||||
code: foreignPalletAccepted ? '200' : body.inboundCode === 'FBA' ? 'A0404' : 'A0409',
|
||||
} }
|
||||
if (body.idempotencyKey.endsWith('-duplicate')) {
|
||||
return { body: path.endsWith('/carton') ? { code: 'A0409' }
|
||||
: { code: '200', data: { result: 'ALREADY_RECEIVED', acceptedPackages: repeatIncrement ? 1 : 0 } } }
|
||||
@@ -92,6 +95,10 @@ test('mixed receiving executes the whole schedule and completes only after all t
|
||||
test('mixed receiving fails on early-completion acceptance', async () => {
|
||||
await assert.rejects(receiveMixedContainer(driver({ earlyComplete: true })))
|
||||
})
|
||||
|
||||
test('mixed receiving fails if another inbound real reserved pallet is accepted', async () => {
|
||||
await assert.rejects(receiveMixedContainer(driver({ foreignPalletAccepted: true })), /同柜另一票真实预留托盘必须拒绝/)
|
||||
})
|
||||
test('mixed receiving fails if overseas or dropship can bypass pallet/carton receipt rules', async () => {
|
||||
await assert.rejects(receiveMixedContainer(driver({ wrongModeAccepted: true })))
|
||||
})
|
||||
@@ -105,7 +112,7 @@ test('mixed receiving rejects same-key different-payload success', async () => {
|
||||
await assert.rejects(receiveMixedContainer(driver({ changedPayloadAccepted: true })))
|
||||
})
|
||||
|
||||
function shortageDriver({ stockPackages = 3, wrongPalletAccepted = false } = {}) {
|
||||
function shortageDriver({ stockPackages = 3, wrongPalletAccepted = false, postCompleteReceiptAccepted = false } = {}) {
|
||||
const record = { order: { tenantId: 'CUSTOMER' }, source: { inboundCode: 'IN-OVERSEAS' },
|
||||
expectedCartonMarks: [1, 2, 3, 4].map(index => `IN-OVERSEAS#4-${index}`),
|
||||
overseas: { plan: { planNo: 'IP-SHORTAGE', pallets: [{ palletNo: 'PAL-1', warehousePalletId: '900' }] } } }
|
||||
@@ -114,7 +121,12 @@ function shortageDriver({ stockPackages = 3, wrongPalletAccepted = false } = {})
|
||||
const state = { received: 0, status: 'SIGNED', planStatus: 'PENDING_RECONCILIATION', confirmations: 0 }
|
||||
const snapshot = () => ({ status: state.status, receivedPackages: state.received, pendingPackages: 4 - state.received })
|
||||
return { record, marker: 'SHORTAGE-TEST', state, check: (name, _response, passed) => assert.ok(passed, name),
|
||||
request: async (_method, path) => ({ body: { code: path.endsWith('/pallets/resolve') && wrongPalletAccepted ? '200' : 'A0409' } }),
|
||||
request: async (_method, path, body) => {
|
||||
if (/receive-after-(complete|shortage)$/.test(body.idempotencyKey || '')) {
|
||||
return { body: { code: postCompleteReceiptAccepted ? '200' : 'A0404' } }
|
||||
}
|
||||
return { body: { code: path.endsWith('/pallets/resolve') && wrongPalletAccepted ? '200' : 'A0409' } }
|
||||
},
|
||||
call: async (_name, method, path, body) => {
|
||||
if (method === 'GET') return snapshot()
|
||||
if (path.endsWith('/cartons/resolve')) return { inboundCode: record.source.inboundCode, destinationType: 'OVERSEAS' }
|
||||
@@ -157,8 +169,12 @@ test('ordinary overseas shortage fails if stock includes an unreceived carton',
|
||||
await assert.rejects(receiveOverseasShortage(shortageDriver({ stockPackages: 4 })))
|
||||
})
|
||||
|
||||
function completeDriver(stockPackages = 4) {
|
||||
const input = shortageDriver({ stockPackages })
|
||||
test('ordinary overseas shortage fails if a missing carton can be received after confirmation', async () => {
|
||||
await assert.rejects(receiveOverseasShortage(shortageDriver({ postCompleteReceiptAccepted: true })), /短少确认后不能继续收取未入库箱/)
|
||||
})
|
||||
|
||||
function completeDriver(stockPackages = 4, postCompleteReceiptAccepted = false) {
|
||||
const input = shortageDriver({ stockPackages, postCompleteReceiptAccepted })
|
||||
const call = input.call
|
||||
input.call = async (name, method, path, body) => {
|
||||
if (path.endsWith('/complete')) {
|
||||
@@ -184,3 +200,7 @@ test('ordinary overseas full receipt uses normal completion and stocks all four
|
||||
test('ordinary overseas full receipt rejects stock inconsistent with actual received cartons', async () => {
|
||||
await assert.rejects(receiveOverseasComplete(completeDriver(3)))
|
||||
})
|
||||
|
||||
test('ordinary overseas full receipt fails if another receipt is accepted after completion', async () => {
|
||||
await assert.rejects(receiveOverseasComplete(completeDriver(4, true)), /正常完成后新键扫码不能重新收货/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user