test(acceptance): reuse fixed customers and align native fulfillment flows
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { mkdir, writeFile } from 'node:fs/promises'
|
||||
const MODULE = 'phase4-overseas-business'
|
||||
const OPTIONS = { scenario: 'us-truck-fulfillment', deploymentBlocker: true }
|
||||
const version = value => /^(0|[1-9]\d*)$/.test(String(value)) && Number.isSafeInteger(Number(value)) ? Number(value) : NaN
|
||||
|
||||
/** 沿用本轮独立卡车原单,以正式履约命令完成实收、分配和运输。 */
|
||||
export async function verifyUsTruckFulfillment(context, proof, { checkpoint = context.checkpoint } = {}) {
|
||||
@@ -47,7 +48,7 @@ export async function verifyUsTruckFulfillment(context, proof, { checkpoint = co
|
||||
}
|
||||
const identity = detail => check('卡车原单客户和版本有效', detail?.summary?.orderNo === proof.orderNo
|
||||
&& String(detail.summary.customerId) === String(proof.customerId)
|
||||
&& Number.isSafeInteger(detail.summary.version) && detail.summary.version >= 0)
|
||||
&& Number.isSafeInteger(version(detail.summary.version)))
|
||||
try {
|
||||
let current = await request('GET', '')
|
||||
identity(current)
|
||||
@@ -68,12 +69,12 @@ export async function verifyUsTruckFulfillment(context, proof, { checkpoint = co
|
||||
for (const [action, state, allocationIndex] of stages) {
|
||||
if (action === 'allocate-pallets' && allocationIndex === 1) {
|
||||
await request('POST', '/prepare-dispatch', {
|
||||
version: current.summary.version, idempotencyKey: `${context.marker}-truck-prepare-dispatch-partial`, remark: context.marker,
|
||||
version: version(current.summary.version), idempotencyKey: `${context.marker}-truck-prepare-dispatch-partial`, remark: context.marker,
|
||||
}, 409)
|
||||
const unchanged = await request('GET', '')
|
||||
check('卡车部分分配禁止待派车且原单完全不变', JSON.stringify(unchanged) === JSON.stringify(current))
|
||||
}
|
||||
const beforeVersion = current.summary.version
|
||||
const beforeVersion = version(current.summary.version)
|
||||
const body = { version: beforeVersion, idempotencyKey: `${context.marker}-truck-${action}`, remark: context.marker }
|
||||
if (action === 'receive-pallets') Object.assign(body, { actualPalletCount: palletCount, packageCount: packages, palletPackageCounts: packageCounts })
|
||||
if (action === 'allocate-pallets') {
|
||||
@@ -90,7 +91,7 @@ export async function verifyUsTruckFulfillment(context, proof, { checkpoint = co
|
||||
}
|
||||
const next = await request('POST', `/${action}`, body)
|
||||
identity(next)
|
||||
check(`卡车${action}状态和版本正确`, next.summary.status === state && next.summary.version === beforeVersion + 1)
|
||||
check(`卡车${action}状态和版本正确`, next.summary.status === state && version(next.summary.version) === beforeVersion + 1)
|
||||
check('卡车原单实收托盘及箱数守恒', next.pallets?.length === palletCount && Number(next.summary.receivedPalletCount) === palletCount
|
||||
&& new Set(next.pallets.map(row => String(row.id))).size === palletCount
|
||||
&& next.pallets.every((row, index) => Number(row.packageCount) === packageCounts[index]
|
||||
|
||||
Reference in New Issue
Block a user