test: keep overseas acceptance fixtures independent

This commit is contained in:
2026-09-09 19:16:18 +08:00
parent 30b9db9628
commit 90a0b009da
4 changed files with 29 additions and 7 deletions
@@ -15,8 +15,8 @@ function query(path, values) {
}
function key(context, operation) { return `${context.marker}:P4-INBOUND:${operation}`.slice(0, 255) }
async function request(context, method, name, path, body) {
const response = await context.requestOverseas(method, path, body)
async function request(context, method, name, path, body, headers = {}) {
const response = await context.requestOverseas(method, path, body, headers)
context.addStep(MODULE, name, response, ok(response), trace(response), OPTIONS)
return ok(response) ? response.body?.data : null
}
@@ -40,9 +40,20 @@ async function inboundAdminLifecycle(context) {
`orderId=${id(order?.id) || 'missing'}, containerNo=${producer.containerNo}`, OPTIONS)
if (!order?.id) return
const convertBody = { orderId: id(order.id), customerId }
const plan = await request(context, 'POST', '尾程入仓单转换为入仓计划', `${PLAN_BASE}/convert`, convertBody)
const replay = await request(context, 'POST', '重复转换返回同一入仓计划', `${PLAN_BASE}/convert`, convertBody)
const bookingId = id(producer.containerBookingId)
const preview = await request(context, 'GET', '预览第二柜待生成入仓计划', query(`${PLAN_BASE}/container-preview`, {
sourceContainerBookingId: bookingId,
}))
const convertBody = { sourceContainerBookingId: bookingId,
snapshotVersion: Number(preview?.snapshotVersion), snapshotHash: preview?.snapshotHash }
const convertHeaders = { 'Idempotency-Key': key(context, 'convert-container') }
const plans = await request(context, 'POST', '尾程入仓单转换为入仓计划',
`${PLAN_BASE}/convert-container`, convertBody, convertHeaders)
const replayedPlans = await request(context, 'POST', '重复转换返回同一入仓计划',
`${PLAN_BASE}/convert-container`, convertBody, convertHeaders)
const plan = (plans || []).find((item) => (item?.lines || []).some((line) => id(line?.orderId) === id(order.id)))
|| plans?.[0]
const replay = (replayedPlans || []).find((item) => item?.planNo === plan?.planNo) || replayedPlans?.[0]
context.assert(MODULE, '入仓计划转换天然幂等', null,
Boolean(plan?.planNo) && replay?.planNo === plan.planNo,
`first=${plan?.planNo || 'missing'}, replay=${replay?.planNo || 'missing'}`, OPTIONS)