test: follow complete relabel lifecycle

This commit is contained in:
2026-09-11 01:18:01 +08:00
parent 7dff9b57ed
commit 3209b2e647
4 changed files with 37 additions and 3 deletions
@@ -4,6 +4,7 @@ const OPTIONS = { scenario: SCENARIO, deploymentBlocker: true }
const PNG = Uint8Array.from(Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=', 'base64'))
function id(value) { return value == null ? '' : String(value) }
function longId(value) { return /^\d+$/.test(String(value || '')) && String(value) !== '0' }
function nonBlank(value) { return typeof value === 'string' && value.trim() !== '' }
function success(response) { return response?.http === 200 && String(response?.body?.code) === '200' }
function conflict(response) {
@@ -511,9 +512,24 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
idempotencyKey: key(context, 'RELABEL-APPROVE'), remark: `${context.marker}-approved` }
const approved = await request(context, token, 'POST', 'P5复核批准换标完成', reviewPath, approveBody)
const approveReplay = await request(context, token, 'POST', 'P5批准同键重放', reviewPath, approveBody)
context.assert(MODULE, 'P5最终任务和申请均COMPLETED', approveReplay.response,
approved.data?.taskStatus === 'COMPLETED' && approved.data?.applicationStatus === 'COMPLETED'
&& approveReplay.data?.taskStatus === 'COMPLETED', trace(approveReplay.response), OPTIONS)
context.assert(MODULE, 'P5仓库复核完成并进入客户确认', approveReplay.response,
approved.data?.taskStatus === 'COMPLETED'
&& approved.data?.applicationStatus === 'CUSTOMER_CONFIRM_PENDING'
&& approveReplay.data?.taskStatus === 'COMPLETED'
&& approveReplay.data?.applicationStatus === 'CUSTOMER_CONFIRM_PENDING', trace(approveReplay.response), OPTIONS)
const customerConfirm = await context.requestOverseas('POST',
`${relabelBase}/${encodeURIComponent(relabelNo)}/confirm-completion`, {
idempotencyKey: key(context, 'RELABEL-CUSTOMER-CONFIRM'), remark: `${context.marker}-customer-confirm`,
}, {}, merchantToken)
context.addStep(MODULE, 'P5客户确认换标完成进入待出库', customerConfirm,
success(customerConfirm) && customerConfirm.body?.data?.application?.status === 'READY_FOR_OUTBOUND',
trace(customerConfirm), OPTIONS)
const terminal = await context.requestOverseas('PUT',
`${relabelBase}/${encodeURIComponent(relabelNo)}/status`, {
status: 'COMPLETED', remark: `${context.marker}-fulfillment-complete`,
})
context.addStep(MODULE, 'P5待出库换标单完成履约', terminal,
success(terminal) && terminal.body?.data?.application?.status === 'COMPLETED', trace(terminal), OPTIONS)
const settled = await poll(async () => context.requestOverseas('GET', `${relabelBase}/${encodeURIComponent(relabelNo)}`),
(response) => success(response) && response.body?.data?.application?.walletStatus === 'SETTLED')
context.addStep(MODULE, 'P5换标完成后钱包结算收敛', settled.result,