完成单机TEST统一入口与可靠投递回归收尾
This commit is contained in:
@@ -47,7 +47,7 @@ function blocker(context, name, reason, response = null) {
|
||||
}
|
||||
|
||||
async function request(context, token, method, name, path, body = undefined) {
|
||||
const response = await context.requestOverseas(method, path, body, {}, token)
|
||||
const response = await context.request(method, path, body, token, {})
|
||||
context.addStep(MODULE, name, response, success(response), trace(response), OPTIONS)
|
||||
return { response, data: success(response) ? response.body?.data : null }
|
||||
}
|
||||
@@ -85,7 +85,7 @@ async function fundRelabelWallet(context, customerId) {
|
||||
async function expectConflict(context, token, method, name, path, body) {
|
||||
let response = null
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
response = await context.requestOverseas(method, path, body, {}, token)
|
||||
response = await context.request(method, path, body, token, {})
|
||||
if (response?.http !== 0 || attempt === 3) break
|
||||
await new Promise((resolve) => setTimeout(resolve, 400 * attempt))
|
||||
}
|
||||
@@ -99,8 +99,7 @@ async function resolvePallet(context, token, palletCode, name = '扫码解析托
|
||||
}
|
||||
|
||||
async function resolvePublicLocation(context, fixture, sourceLocationCode) {
|
||||
const response = await context.requestOverseas('GET',
|
||||
`/api/platform/v1/warehouse-admin/${encodeURIComponent(fixture.overseasWarehouseId)}/locations?page=1&size=200`)
|
||||
const response = await context.request('GET', `/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(fixture.overseasWarehouseId)}/locations?page=1&size=200`)
|
||||
const locations = records(response?.body?.data)
|
||||
const location = locations.find((item) => item?.locationType === 'SHARED_OVERFLOW'
|
||||
&& item?.locationCode === 'A0' && item?.status === 'ACTIVE' && item.locationCode !== sourceLocationCode)
|
||||
@@ -389,10 +388,10 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
const inventoryCandidates = []
|
||||
let inventoryCandidatesResponse = null
|
||||
for (const inboundCode of inboundCodes) {
|
||||
inventoryCandidatesResponse = await context.requestOverseas('GET', query(
|
||||
inventoryCandidatesResponse = await context.request('GET', query(
|
||||
'/api/merchant/v1/last-leg/relabel-applications/inventory-candidates', {
|
||||
operationWarehouseId: fixture.overseasWarehouseId, inboundCode,
|
||||
}), undefined, {}, merchantToken)
|
||||
}), undefined, merchantToken, {})
|
||||
context.addStep(MODULE, 'P5读取本轮同柜同目的仓换标候选', inventoryCandidatesResponse,
|
||||
success(inventoryCandidatesResponse), trace(inventoryCandidatesResponse), OPTIONS)
|
||||
if (!success(inventoryCandidatesResponse)) return false
|
||||
@@ -437,8 +436,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
}
|
||||
}),
|
||||
}
|
||||
const createdResponse = await context.requestOverseas('POST',
|
||||
query(relabelBase, { customerId }), createBody)
|
||||
const createdResponse = await context.request('POST', query(relabelBase, { customerId }), createBody)
|
||||
const created = success(createdResponse) ? createdResponse.body?.data : null
|
||||
const relabelNo = id(created?.application?.relabelNo)
|
||||
context.addStep(MODULE, 'P5基于本轮完成库存创建真实换标申请', createdResponse,
|
||||
@@ -449,11 +447,11 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
blocker(context, 'P5真实换标申请', '平台正式换标创建接口未返回申请单号', createdResponse)
|
||||
return false
|
||||
}
|
||||
const reviewed = await request(context, context.overseasToken, 'PUT', 'P5尾程订单审核直接贴标申请',
|
||||
const reviewed = await request(context, context.token, 'PUT', 'P5尾程订单审核直接贴标申请',
|
||||
query(`/api/platform/v1/last-leg/orders/${encodeURIComponent(id(created.application.lastlegOrderId))}/relabel-review`, { customerId }),
|
||||
{ status: 'PENDING_PROCESSING', remark: context.marker })
|
||||
if (!success(reviewed.response) || reviewed.data?.application?.status !== 'PENDING_PROCESSING') return false
|
||||
const funded = await poll(async () => context.requestOverseas('GET', `${relabelBase}/${encodeURIComponent(relabelNo)}`),
|
||||
const funded = await poll(async () => context.request('GET', `${relabelBase}/${encodeURIComponent(relabelNo)}`),
|
||||
(response) => success(response) && response.body?.data?.application?.walletStatus === 'FROZEN')
|
||||
context.addStep(MODULE, 'P5换标费用冻结后开放PDA作业', funded.result,
|
||||
funded.result?.body?.data?.application?.walletStatus === 'FROZEN',
|
||||
@@ -537,7 +535,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
detail = exception.data
|
||||
if (!detail) return false
|
||||
|
||||
const photo = await context.requestOverseasMultipart('POST',
|
||||
const photo = await context.requestMultipart('POST',
|
||||
`${pdaBase}/${encodeURIComponent(relabelNo)}/photos/files`, {
|
||||
name: `${context.marker}-relabel.png`, type: 'image/png', content: PNG,
|
||||
}, token)
|
||||
@@ -557,9 +555,9 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
const reviewPath = `${relabelBase}/${encodeURIComponent(relabelNo)}/rework`
|
||||
const reworkBody = { decision: 'REWORK', expectedVersion: Number(completed.data.version),
|
||||
idempotencyKey: key(context, 'RELABEL-REWORK'), remark: `${context.marker}-rework` }
|
||||
const reworked = await request(context, context.overseasToken, 'POST', 'P5平台复核退回REWORK', reviewPath, reworkBody)
|
||||
const reworked = await request(context, context.token, 'POST', 'P5平台复核退回REWORK', reviewPath, reworkBody)
|
||||
if (!success(reworked.response)) return false
|
||||
const reworkReplay = await request(context, context.overseasToken, 'POST', 'P5 REWORK同键重放', reviewPath, reworkBody)
|
||||
const reworkReplay = await request(context, context.token, 'POST', 'P5 REWORK同键重放', reviewPath, reworkBody)
|
||||
context.assert(MODULE, 'P5 REWORK重放保持AVAILABLE等待重新认领', reworkReplay.response,
|
||||
reworkReplay.data?.taskStatus === 'AVAILABLE' && Number(reworkReplay.data.relabelledPackages) === 0,
|
||||
trace(reworkReplay.response), OPTIONS)
|
||||
@@ -588,7 +586,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
if (!success(redo.response)) return false
|
||||
detail = redo.data
|
||||
}
|
||||
const bindingResponse = await context.requestOverseas('GET', `${relabelBase}/${encodeURIComponent(relabelNo)}`)
|
||||
const bindingResponse = await context.request('GET', `${relabelBase}/${encodeURIComponent(relabelNo)}`)
|
||||
const bindingDetail = success(bindingResponse) ? bindingResponse.body.data : null
|
||||
if (!Array.isArray(bindingDetail?.items) || bindingDetail.items.length !== 3) return false
|
||||
|
||||
@@ -681,7 +679,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
`targets=${new Set(movedFacts.map((fact) => fact.targetPalletId)).size}, targetBMoves=${movedFacts.filter((fact) => fact.targetPalletId === id(printedB.data.palletId)).length}`, OPTIONS)
|
||||
|
||||
for (const fact of movedFacts) {
|
||||
const positionsResponse = await context.requestOverseas('GET', query(
|
||||
const positionsResponse = await context.request('GET', query(
|
||||
`/api/platform/v1/last-leg/inventory/balances/${encodeURIComponent(fact.balanceId)}/positions`,
|
||||
{ customerId }), undefined)
|
||||
const positions = success(positionsResponse) && Array.isArray(positionsResponse.body?.data)
|
||||
@@ -694,7 +692,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
&& targetPosition?.inboundCode === fact.inboundCode,
|
||||
`targetPallet=${fact.targetPalletCode}, inbound=${targetPosition?.inboundOrderNo || 'missing'}; ${trace(positionsResponse)}`, OPTIONS)
|
||||
}
|
||||
const ledgerResponse = await context.requestOverseas('GET', query(
|
||||
const ledgerResponse = await context.request('GET', query(
|
||||
'/api/platform/v1/last-leg/inventory/ledger', {
|
||||
customerId, page: 1, size: 100, businessType: 'RELABEL_PALLET_DISASSEMBLE',
|
||||
occurredFrom: new Date(Date.now() - 10 * 60_000).toISOString().slice(0, 19),
|
||||
@@ -721,8 +719,7 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
trace(finalReplay.response), OPTIONS)
|
||||
const confirmBody = { idempotencyKey: key(context, 'RELABEL-CUSTOMER-CONFIRM'),
|
||||
remark: `${context.marker}-customer-confirmed` }
|
||||
const confirmedResponse = await context.requestOverseas('POST',
|
||||
`${merchantRelabelBase}/${encodeURIComponent(relabelNo)}/confirm-completion`, confirmBody, {}, merchantToken)
|
||||
const confirmedResponse = await context.request('POST', `${merchantRelabelBase}/${encodeURIComponent(relabelNo)}/confirm-completion`, confirmBody, merchantToken, {})
|
||||
const confirmed = success(confirmedResponse) ? confirmedResponse.body?.data : null
|
||||
context.addStep(MODULE, 'P5客户确认换标完成进入待排车', confirmedResponse,
|
||||
confirmed?.application?.status === 'READY_FOR_OUTBOUND'
|
||||
@@ -741,13 +738,12 @@ async function verifyRelabel(context, token, merchantToken, fixture) {
|
||||
export async function settleRelabelFulfillment(context, relabel) {
|
||||
const relabelNo = relabel.relabelNo
|
||||
const relabelBase = '/api/platform/v1/last-leg/relabel-applications'
|
||||
const terminal = await context.requestOverseas('PUT',
|
||||
`${relabelBase}/${encodeURIComponent(relabelNo)}/status`, {
|
||||
const terminal = await context.request('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)}`),
|
||||
const settled = await poll(async () => context.request('GET', `${relabelBase}/${encodeURIComponent(relabelNo)}`),
|
||||
(response) => success(response) && response.body?.data?.application?.walletStatus === 'SETTLED')
|
||||
context.addStep(MODULE, 'P5换标完成后钱包结算收敛', settled.result,
|
||||
settled.result?.body?.data?.application?.walletStatus === 'SETTLED',
|
||||
|
||||
Reference in New Issue
Block a user