test(acceptance): reuse fixed customers and align native fulfillment flows
This commit is contained in:
@@ -365,6 +365,24 @@ test('F40 selects actual source warehouse irrespective of authority list order a
|
||||
assert.doesNotMatch(source, /resolveSharedWarehouse|19300000000020000[34]/)
|
||||
})
|
||||
|
||||
for (const fault of ['', 'changed-total', 'repeated-page', 'missing-page']) test(`F40 fully pages sources before proving unique receiving warehouse: ${fault || 'target on page two'}`, async () => {
|
||||
const f = warehouseSelectionFixture(), original = f.context.request
|
||||
f.context.request = async (method, path) => {
|
||||
if (path.includes('/warehouse-admin?')) return original(method, path)
|
||||
f.calls.push({ method, path })
|
||||
const url = new URL(path, 'https://offline.invalid'), page = Number(url.searchParams.get('page'))
|
||||
const target = f.orders.filter(row => row.containerNo === url.searchParams.get('containerNo'))
|
||||
const unrelated = Array.from({ length: 200 }, (_, n) => ({ id: `OTHER-${n}`, customerId: 'OTHER' }))
|
||||
const records = page === 1 || fault === 'repeated-page' ? unrelated : fault === 'missing-page' ? [] : target
|
||||
return { http: 200, body: { code: 200, data: { records, total: fault === 'changed-total' && page === 2 ? 202 : 201 } } }
|
||||
}
|
||||
if (fault) await assert.rejects(resolveF40ReceivingWarehouse(f.context, f.producers), /分页/)
|
||||
else {
|
||||
assert.equal((await resolveF40ReceivingWarehouse(f.context, f.producers)).id, 'actual-warehouse')
|
||||
assert.equal(f.calls.filter(row => row.path.includes('page=2')).length, 2)
|
||||
}
|
||||
})
|
||||
|
||||
test('F40 warehouse resolution rejects wrong customer, booking, inbound identity, duplicates and missing assignment', async () => {
|
||||
for (const mutate of [
|
||||
f => { f.orders[0].customerId = 'foreign' },
|
||||
@@ -569,6 +587,7 @@ test('early F40 failures become FAILED with only a safe stage and preserve the o
|
||||
|
||||
function nativeFragmentFixture() {
|
||||
const context = fixture(), events = [], calls = []
|
||||
context.createdResources.phase4OverseasPda = { generatedPlanIds: ['81', '82'] }
|
||||
const producer = { tenantId: '90', inboundCode: 'IN-F40', sourceInboundId: '901', sourceOrderId: '100',
|
||||
rootOrderId: '100', containerBookingId: '902' }
|
||||
const rootProof = { fragments: [producer], currentStage: 'DISPATCH_AND_SIGNATURE_1' }
|
||||
@@ -584,7 +603,9 @@ function nativeFragmentFixture() {
|
||||
let data
|
||||
if (method === 'GET' && path.includes('/candidates?')) {
|
||||
assert.equal(new URL(path, 'https://offline.invalid').searchParams.get('warehouseId'), '80')
|
||||
assert.equal(new URL(path, 'https://offline.invalid').searchParams.has('sourceStage'), false)
|
||||
assert.equal(new URL(path, 'https://offline.invalid').searchParams.get('sourceStage'), 'RECEIVED')
|
||||
assert.equal(new URL(path, 'https://offline.invalid').searchParams.get('planIds'), '81,82')
|
||||
assert.equal(new URL(path, 'https://offline.invalid').searchParams.get('size'), '50')
|
||||
data = { complete: true, candidates: [nativeF40Candidate()] }
|
||||
} else if (method === 'POST' && path.endsWith('/dispatches')) {
|
||||
events.push('create')
|
||||
|
||||
Reference in New Issue
Block a user