修正四期全量验收夹具
This commit is contained in:
@@ -6,6 +6,16 @@ const TRUCK = '/api/platform/v1/truck-appointments'
|
||||
function id(value) { return value == null ? '' : String(value) }
|
||||
function codeOf(response) { return response?.body?.code == null ? 'missing' : String(response.body.code) }
|
||||
|
||||
async function requestWithTransientRetry(context, method, path, body) {
|
||||
let response = null
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
response = await context.request(method, path, body)
|
||||
if (response?.http !== 0) return response
|
||||
if (attempt < 3) await new Promise((resolve) => setTimeout(resolve, 500 * attempt))
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
async function actionRequest(context, path, endpoint, version) {
|
||||
try {
|
||||
const response = await fetch(`${context.options.gateway}${path}/${endpoint}`, {
|
||||
@@ -64,7 +74,7 @@ export async function run(context) {
|
||||
context.assert(MODULE, '已放舱订舱可直接创建订舱级拖车预约', oceanResponse,
|
||||
id(booking?.id) === id(ocean.id) && booking?.status === 'RELEASED',
|
||||
`oceanBookingId=${id(booking?.id) || 'missing'}, status=${booking?.status || 'missing'}`, OPTIONS)
|
||||
const carrierResponse = await context.request('GET',
|
||||
const carrierResponse = await requestWithTransientRetry(context, 'GET',
|
||||
'/api/platform/v1/suppliers?tenantId=0&category=TRUCKING&status=ACTIVE&page=1&size=20')
|
||||
const carrierPage = context.apiSuccess(MODULE, '读取 ACTIVE TRUCKING 承运商事实源', carrierResponse, '', OPTIONS)
|
||||
const carrier = carrierPage?.records?.find?.((item) => item?.id && item?.name)
|
||||
|
||||
Reference in New Issue
Block a user