test: complete phase4 PDA shipping prerequisites
This commit is contained in:
@@ -987,11 +987,15 @@ export class AcceptanceRun {
|
||||
}
|
||||
}
|
||||
|
||||
async runPhase4ProducerVariant(label, destinationType, fulfillmentType = 'STANDARD') {
|
||||
async runPhase4ProducerVariant(label, destinationType, fulfillmentType = 'STANDARD', pickupRequired = false) {
|
||||
const matrixMarker = this.marker
|
||||
const variantMarker = `${matrixMarker}-P4-${label}`
|
||||
const contextKeys = ['orderDestinationType', 'orderFulfillmentType', 'phase4ProducerMatrixMarker']
|
||||
const createdKeys = ['phase3Loading', 'phase3LoadingCompletedProducer', 'orchestrationFixtures', 'oceanBooking']
|
||||
const createdKeys = [
|
||||
'phase3Loading', 'phase3LoadingCompletedProducer', 'orchestrationFixtures', 'oceanBooking',
|
||||
'phase3CustomsSupplier', 'phase3Customs', 'serviceCenterFlow', 'portSchedule',
|
||||
'phase3OutboundDispatch', 'phase3CarrierScheduleQuery', 'phase4CarrierPickupReady',
|
||||
]
|
||||
const contextSnapshot = new Map(contextKeys.map((key) => [key, {
|
||||
present: Object.hasOwn(this.context, key), value: this.context[key],
|
||||
}]))
|
||||
@@ -1009,6 +1013,45 @@ export class AcceptanceRun {
|
||||
await this.executeModule(`phase3-loading-phase4-${label}`, () => loading.run(this))
|
||||
const finalize = await import(new URL('./admin-test-env-modules/phase3-loading-finalize.mjs', import.meta.url))
|
||||
await this.executeModule(`phase3-loading-finalize-phase4-${label}`, () => finalize.run(this))
|
||||
const producerKey = this.createdResources.phase3LoadingCompletedProducer?.resourceKey
|
||||
const writeShippingEvidence = (shippingReady, carrierScheduleQueryId = null) => {
|
||||
const matrix = this.createdResources.phase4InboundProducerFixtures
|
||||
const records = [matrix?.containers, matrix?.byDestinationType?.FBA,
|
||||
matrix?.byDestinationType?.OVERSEAS].filter(Array.isArray)
|
||||
for (const values of records) {
|
||||
const target = values.find((item) => item?.resourceKey === producerKey)
|
||||
if (target) Object.assign(target, { shippingReady, carrierScheduleQueryId })
|
||||
}
|
||||
}
|
||||
if (producerKey) writeShippingEvidence(false)
|
||||
if (pickupRequired && !producerKey) {
|
||||
this.assert('phase4-overseas-pda-fixture', `${label}产生者身份完整`, null, false,
|
||||
'phase3LoadingCompletedProducer.resourceKey=missing',
|
||||
{ scenario: 'phase3-phase4-producer-fixture', deploymentBlocker: true })
|
||||
}
|
||||
if (pickupRequired && producerKey) {
|
||||
const customs = await import(new URL('./admin-test-env-modules/phase3-customs.mjs', import.meta.url))
|
||||
await this.executeModule(`phase3-customs-phase4-${label}`, () => customs.run(this))
|
||||
const serviceCenter = await import(new URL('./admin-test-env-modules/service-center-flow.mjs', import.meta.url))
|
||||
await this.executeModule(`service-center-flow-phase4-${label}`, () => serviceCenter.run(this))
|
||||
const portSchedules = await import(new URL('./admin-test-env-modules/phase3-port-schedules.mjs', import.meta.url))
|
||||
await this.executeModule(`phase3-port-schedules-phase4-${label}`, () => portSchedules.run(this))
|
||||
const outbound = await import(new URL('./admin-test-env-modules/phase3-outbound-dispatch.mjs', import.meta.url))
|
||||
await this.executeModule(`phase3-outbound-dispatch-phase4-${label}`, () => outbound.run(this))
|
||||
const carrierQueries = await import(new URL('./admin-test-env-modules/phase3-carrier-schedule-queries.mjs', import.meta.url))
|
||||
await this.executeModule(`phase3-carrier-schedule-queries-phase4-${label}`, () => carrierQueries.run(this))
|
||||
const carrierNodes = await import(new URL('./admin-test-env-modules/phase4-carrier-nodes.mjs', import.meta.url))
|
||||
await this.executeModule(`phase4-carrier-pickup-ready-phase4-${label}`,
|
||||
() => carrierNodes.runUntilPickupReady(this))
|
||||
const pickup = this.createdResources.phase4CarrierPickupReady
|
||||
const shippingReady = pickup?.marker === variantMarker && pickup?.ready === true
|
||||
&& Boolean(pickup?.queryId)
|
||||
writeShippingEvidence(shippingReady, shippingReady ? String(pickup.queryId) : null)
|
||||
this.assert('phase4-overseas-pda-fixture', `${label}通过真实出仓与船节点进入PICKUP_READY`, null,
|
||||
shippingReady,
|
||||
`resourceKey=${producerKey}, queryId=${pickup?.queryId || 'missing'}, ready=${pickup?.ready === true}`,
|
||||
{ scenario: 'phase3-phase4-producer-fixture', deploymentBlocker: true })
|
||||
}
|
||||
} finally {
|
||||
if (restoreFixture) restoreFixture()
|
||||
this.marker = matrixMarker
|
||||
@@ -1026,21 +1069,32 @@ export class AcceptanceRun {
|
||||
async ensurePhase4PdaProducerMatrix() {
|
||||
const readiness = () => this.createdResources.phase4InboundProducerFixtures?.readiness || {}
|
||||
if (Number(readiness().dropshipContainerCount || 0) < 1) {
|
||||
await this.runPhase4ProducerVariant('DROPSHIP-PRIMARY', 'FBA', 'ONE_CLICK_DROPSHIP')
|
||||
await this.runPhase4ProducerVariant('DROPSHIP-PRIMARY', 'FBA', 'ONE_CLICK_DROPSHIP', true)
|
||||
}
|
||||
if (Number(readiness().fbaContainerCount || 0) < 2) {
|
||||
await this.runPhase4ProducerVariant('FBA-STANDARD', 'FBA')
|
||||
await this.runPhase4ProducerVariant('FBA-STANDARD', 'FBA', 'STANDARD', false)
|
||||
}
|
||||
if (Number(readiness().overseasContainerCount || 0) < 1) {
|
||||
await this.runPhase4ProducerVariant('OVERSEAS-PRIMARY', 'OVERSEAS')
|
||||
await this.runPhase4ProducerVariant('OVERSEAS-PRIMARY', 'OVERSEAS', 'STANDARD', true)
|
||||
}
|
||||
if (Number(readiness().distinctContainerCount || 0) < 4) {
|
||||
await this.runPhase4ProducerVariant('SECONDARY', 'FBA')
|
||||
await this.runPhase4ProducerVariant('SECONDARY', 'FBA', 'STANDARD', false)
|
||||
}
|
||||
const matrix = this.createdResources.phase4InboundProducerFixtures
|
||||
const containers = Array.isArray(matrix?.containers) ? matrix.containers : []
|
||||
const dropshipReady = containers.find((item) => item?.fulfillmentType === 'ONE_CLICK_DROPSHIP')
|
||||
const overseasReady = containers.find((item) => item?.destinationType === 'OVERSEAS')
|
||||
const awaitingVariants = containers.filter((item) => ['FBA-STANDARD', 'SECONDARY']
|
||||
.some((label) => String(item?.resourceKey || '').includes(`-P4-${label}:`)))
|
||||
const shippingMatrixReady = dropshipReady?.shippingReady === true
|
||||
&& Boolean(dropshipReady?.carrierScheduleQueryId)
|
||||
&& overseasReady?.shippingReady === true && Boolean(overseasReady?.carrierScheduleQueryId)
|
||||
&& awaitingVariants.length >= 1
|
||||
&& awaitingVariants.every((item) => item.shippingReady === false
|
||||
&& item.carrierScheduleQueryId == null)
|
||||
this.assert('phase4-overseas-pda-fixture', '本轮三期跨区生产矩阵已就绪', null,
|
||||
matrix?.marker === this.marker && matrix?.readiness?.readyForPhase4Pda === true,
|
||||
`marker=${matrix?.marker || 'missing'}, FBA=${matrix?.readiness?.fbaContainerCount ?? 0}, OVERSEAS=${matrix?.readiness?.overseasContainerCount ?? 0}, DROPSHIP=${matrix?.readiness?.dropshipContainerCount ?? 0}, containers=${matrix?.readiness?.distinctContainerCount ?? 0}`,
|
||||
matrix?.marker === this.marker && matrix?.readiness?.readyForPhase4Pda === true && shippingMatrixReady,
|
||||
`marker=${matrix?.marker || 'missing'}, FBA=${matrix?.readiness?.fbaContainerCount ?? 0}, OVERSEAS=${matrix?.readiness?.overseasContainerCount ?? 0}, DROPSHIP=${matrix?.readiness?.dropshipContainerCount ?? 0}, containers=${matrix?.readiness?.distinctContainerCount ?? 0}, shippingReady=${containers.filter((item) => item?.shippingReady === true).length}, awaiting=${awaitingVariants.length}`,
|
||||
{ scenario: 'phase3-phase4-producer-fixture', deploymentBlocker: true })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user