test(acceptance): reuse fixed customers and align native fulfillment flows

This commit is contained in:
2026-10-23 04:48:02 +08:00
parent b92f7fe991
commit 139f6b1932
51 changed files with 1076 additions and 228 deletions
@@ -6,10 +6,28 @@ import { fileURLToPath } from 'node:url'
import { requestedOrderDestinationType } from './orders.mjs'
import { collectPhase4InboundProducerFixture } from './phase3-loading-finalize.mjs'
import { AcceptanceRun } from '../admin-test-env-acceptance.mjs'
const here = dirname(fileURLToPath(import.meta.url))
const read = (name) => readFileSync(resolve(here, name), 'utf8')
test('转运异仓资源不足在造单前阻断,并恢复外层批次和路线', async () => {
let created = false
const originalRoute = { randomIndex: 3 }
const run = { marker: 'MATRIX', phase4ProducerAttempts: new Map(),
options: { fixedCustomerId: '101', fixedPdaActors: [{ warehouseId: '201' }], modules: ['phase4-overseas-client-services'] },
context: { waitSplitRoute: originalRoute }, createdResources: { phase3Loading: { marker: 'OUTER' } },
request: async method => { assert.equal(method, 'GET'); return { http: 200, body: { code: '200', data: { total: '0', records: [] } } } },
apiSuccess: (_module, _name, response) => response.body.data,
preparePhase3LoadingFixture: async () => { created = true; throw Error('unexpected order creation') },
}
await assert.rejects(AcceptanceRun.prototype.runPhase4ProducerVariant.call(run, 'DROPSHIP-PRIMARY', 'FBA', 'ONE_CLICK_DROPSHIP', true), /未创建来源订单/)
assert.equal(created, false)
assert.equal(run.marker, 'MATRIX')
assert.equal(run.context.waitSplitRoute, originalRoute)
assert.deepEqual(run.createdResources.phase3Loading, { marker: 'OUTER' })
})
test('order fixture defaults to FBA and preserves explicit OVERSEAS or PRIVATE routes', () => {
assert.equal(requestedOrderDestinationType({ context: {} }), 'FBA')
assert.equal(requestedOrderDestinationType({ context: { orderDestinationType: 'overseas' } }), 'OVERSEAS')
@@ -95,7 +113,7 @@ test('measurement and loading pass destination identity into the LOADED producer
assert.match(finalize, /phase4InboundProducerFixtures = collectPhase4InboundProducerFixture/)
const entry = read('../admin-test-env-acceptance.mjs')
assert.match(entry, /runPhase4ProducerVariant\('DROPSHIP-PRIMARY', 'FBA', 'ONE_CLICK_DROPSHIP', true\)/)
assert.match(entry, /packageCounts: \[4\], palletCount: 2/)
assert.match(entry, /packageCounts: \[5\], palletCount: 2/)
assert.match(entry, /sealedSourcePalletNos: Array\.isArray\(fixture\.sealedSourcePalletNos\)/)
assert.match(entry, /orderFulfillmentType/)
assert.match(entry, /fulfillmentType: fixtureOrder\.fulfillmentType \|\| 'STANDARD'/)
@@ -125,7 +143,7 @@ test('measurement and loading pass destination identity into the LOADED producer
assert.match(pda, /FBA与OVERSEAS箱码resolve均为纯查询且零状态写入/)
})
test('only PDA-operated variants traverse real outbound and carrier nodes before overseas receiving', () => {
test('all receiving and appointment sources use native outbound; waiting source stays below pickup readiness', () => {
const entry = read('../admin-test-env-acceptance.mjs')
assert.match(entry, /runPhase4ProducerVariant\('OVERSEAS-PRIMARY', 'OVERSEAS', 'ONE_CLICK_DROPSHIP', true\)/)
assert.match(entry, /runPhase4ProducerVariant\('FBA-STANDARD', 'FBA', 'STANDARD', true\)/)
@@ -138,7 +156,10 @@ test('only PDA-operated variants traverse real outbound and carrier nodes before
assert.match(entry, /const hasSecondaryProducer =/)
assert.match(entry, /if \(!hasSecondaryProducer\(\)\)/)
assert.doesNotMatch(entry, /if \(Number\(readiness\(\)\.distinctContainerCount \|\| 0\) < 4\)/)
const start = entry.indexOf('if (pickupRequired && producerKey)')
assert.match(entry, /const shippingRequired = pickupRequired \|\| label === 'SECONDARY'/)
assert.match(entry, /if \(!pickupRequired\)/)
assert.match(entry, /writeShippingEvidence\(false, ready \? String\(source.queryId\) : null\)/)
const start = entry.indexOf('if (shippingRequired && producerKey)')
const end = entry.indexOf('} finally {', start)
const pickupChain = entry.slice(start, end)
const ordered = [