完成单机TEST统一入口与可靠投递回归收尾

This commit is contained in:
2026-09-29 19:48:34 +08:00
parent 64a70c9f28
commit 6c0a026cc4
89 changed files with 968 additions and 983 deletions
@@ -31,12 +31,12 @@ async function domesticGet(context, name, path) {
return { response, data: context.apiSuccess(MODULE, name, response, trace(response), OPTIONS) }
}
async function overseasGet(context, name, path) {
const response = await context.requestOverseas('GET', path)
const response = await context.request('GET', path)
assertEnvelope(context, name, response)
return { response, data: context.apiSuccess(MODULE, name, response, trace(response), OPTIONS) }
}
async function overseasMutation(context, method, name, path, body) {
const response = await context.requestOverseas(method, path, body)
const response = await context.request(method, path, body)
const passed = response?.http === 200 && String(response?.body?.code) === '200'
context.addStep(MODULE, name, response, passed, trace(response), OPTIONS)
return { response, data: passed ? response.body?.data : null }
@@ -48,7 +48,7 @@ async function domesticMutation(context, method, name, path, body) {
return { response, data: passed ? response.body?.data : null }
}
async function overseasCsv(context, name, path) {
const response = await context.requestOverseasBinary('GET', path)
const response = await context.requestBinary('GET', path)
context.addStep(MODULE, name, response,
response?.http === 200 && Number(response?.bytes?.length) > 0 && String(response?.contentType || '').toLowerCase().includes('csv'),
`bytes=${response?.bytes?.length ?? 0}, contentType=${response?.contentType || 'missing'}, requestId=${response?.requestId || 'missing'}, traceId=${response?.traceId || 'missing'}`, OPTIONS)
@@ -164,7 +164,7 @@ export async function run(context) {
const warehouseId = id(warehouse.id)
context.createdResources.phase4OverseasWarehouse.customerId = customerId
context.createdResources.phase4OverseasWarehouse.warehouseId = warehouseId
const locations = await overseasGet(context, '查询公共库位列表', query(`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations`, { page: 1, size: 20 }))
const locations = await overseasGet(context, '查询公共库位列表', query(`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/locations`, { page: 1, size: 20 }))
assertPage(context, '公共库位列表', locations)
const location = records(locations.data)[0]
if (location) {
@@ -172,12 +172,12 @@ export async function run(context) {
longId(location.id) && id(location.warehouseId) === warehouseId && id(location.customerId) === '0'
&& nonBlank(location.locationCode) && nonBlank(location.status),
`id=${id(location.id) || 'missing'}, customerId=${id(location.customerId) || 'missing'}, status=${location.status || 'missing'}; ${trace(locations.response)}`, OPTIONS)
const detail = await overseasGet(context, '查询公共库位详情', `/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(id(location.id))}`)
const detail = await overseasGet(context, '查询公共库位详情', `/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(id(location.id))}`)
context.assert(MODULE, '公共库位详情对应列表记录', detail.response,
id(detail.data?.id) === id(location.id) && id(detail.data?.warehouseId) === warehouseId && id(detail.data?.customerId) === '0',
`listId=${id(location.id)}, detailId=${id(detail.data?.id) || 'missing'}; ${trace(detail.response)}`, OPTIONS)
}
const pallets = await overseasGet(context, '查询公共托盘列表', query(`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`, { page: 1, size: 20 }))
const pallets = await overseasGet(context, '查询公共托盘列表', query(`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets`, { page: 1, size: 20 }))
assertPage(context, '公共托盘列表', pallets)
const pallet = records(pallets.data)[0]
if (pallet) {
@@ -185,7 +185,7 @@ export async function run(context) {
longId(pallet.id) && id(pallet.warehouseId) === warehouseId && id(pallet.customerId) === '0'
&& nonBlank(pallet.palletCode) && ['IDLE', 'OCCUPIED', 'SCRAPPED'].includes(pallet.status),
`id=${id(pallet.id) || 'missing'}, customerId=${id(pallet.customerId) || 'missing'}, status=${pallet.status || 'missing'}; ${trace(pallets.response)}`, OPTIONS)
const detail = await overseasGet(context, '查询公共托盘详情', `/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(id(pallet.id))}`)
const detail = await overseasGet(context, '查询公共托盘详情', `/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(id(pallet.id))}`)
context.assert(MODULE, '公共托盘详情对应列表记录', detail.response,
id(detail.data?.id) === id(pallet.id) && id(detail.data?.warehouseId) === warehouseId && id(detail.data?.customerId) === '0',
`listId=${id(pallet.id)}, detailId=${id(detail.data?.id) || 'missing'}; ${trace(detail.response)}`, OPTIONS)
@@ -209,7 +209,7 @@ async function verifyLocationLifecycle(context, warehouseId) {
let locationId = ''
try {
const created = await overseasMutation(context, 'POST', '创建本轮公共库位',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations`, {
`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/locations`, {
locationCode, locationType: 'STORAGE', maxLoadKg: 1000,
status: 'ACTIVE', remark: context.marker,
})
@@ -218,7 +218,7 @@ async function verifyLocationLifecycle(context, warehouseId) {
context.assert(MODULE, '公共库位创建返回长ID', created.response, longId(locationId),
`locationId=${locationId || 'missing'}, marker=${context.marker}; ${trace(created.response)}`, OPTIONS)
if (!locationId) return
const detailPath = `/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`
const detailPath = `/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`
const detail = await overseasGet(context, '查询本轮公共库位详情', detailPath)
context.assert(MODULE, '本轮公共库位创建事实正确', detail.response,
id(detail.data?.id) === locationId && id(detail.data?.customerId) === '0'
@@ -237,9 +237,8 @@ async function verifyLocationLifecycle(context, warehouseId) {
} finally {
if (locationId) {
const removed = await overseasMutation(context, 'DELETE', '删除本轮公共库位',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`)
const deletedDetail = await context.requestOverseas('GET',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`)
`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`)
const deletedDetail = await context.request('GET', `/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/locations/${encodeURIComponent(locationId)}`)
const deleted = voidMutationSucceeded(removed) && businessNotFound(deletedDetail)
context.createdResources.phase4OverseasWarehouse.locationTerminalStatus = deleted ? 'DELETED' : null
context.assert(MODULE, '本轮公共库位已删除且回查不存在', deletedDetail, deleted,
@@ -287,7 +286,7 @@ async function verifyPalletLifecycle(context, warehouseId) {
let palletId = ''
try {
const created = await overseasMutation(context, 'POST', '创建本轮公共托盘',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets`, {
`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets`, {
palletCode, palletType: '木托盘', capacityCbm: 2, unitPrice: 0, status: 'IDLE', remark: context.marker,
})
palletId = id(created.data)
@@ -296,7 +295,7 @@ async function verifyPalletLifecycle(context, warehouseId) {
`palletId=${palletId || 'missing'}, marker=${context.marker}; ${trace(created.response)}`, OPTIONS)
if (!palletId) return
const detailPath = `/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`
const detailPath = `/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`
const detail = await overseasGet(context, '查询本轮公共托盘详情', detailPath)
context.assert(MODULE, '本轮公共托盘创建事实正确', detail.response,
id(detail.data?.id) === palletId && id(detail.data?.warehouseId) === warehouseId
@@ -314,7 +313,7 @@ async function verifyPalletLifecycle(context, warehouseId) {
id(after.data?.id) === palletId && Number(after.data?.capacityCbm) === 2.5
&& Number(after.data?.unitPrice) === 1 && after.data?.remark === `${context.marker}-edited`,
`capacity=${after.data?.capacityCbm ?? 'missing'}, unitPrice=${after.data?.unitPrice ?? 'missing'}, remark=${after.data?.remark || 'missing'}; ${trace(after.response)}`, OPTIONS)
const stale = await context.requestOverseas('PUT', detailPath, {
const stale = await context.request('PUT', detailPath, {
palletCode, palletType: '木托盘', capacityCbm: 9, unitPrice: 9, status: 'IDLE',
remark: 'STALE-DO-NOT-APPLY', version: Number(detail.data?.version),
})
@@ -323,17 +322,17 @@ async function verifyPalletLifecycle(context, warehouseId) {
} finally {
if (palletId) {
const retired = await overseasMutation(context, 'PUT', '报废本轮公共托盘',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`, {
`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`, {
palletCode, palletType: '木托盘', capacityCbm: 2.5, unitPrice: 1, status: 'SCRAPPED',
remark: `${context.marker}-acceptance-retired`, version: Number((await overseasGet(context,
'读取公共托盘报废前最新版本',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`)).data?.version),
`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`)).data?.version),
})
context.createdResources.phase4OverseasWarehouse.terminalStatus = voidMutationSucceeded(retired) ? 'SCRAPPED' : null
context.assert(MODULE, '本轮公共托盘已报废收口', retired.response, voidMutationSucceeded(retired),
`palletId=${palletId}, terminalStatus=${context.createdResources.phase4OverseasWarehouse.terminalStatus || 'missing'}; ${trace(retired.response)}`, OPTIONS)
const retiredDetail = await overseasGet(context, '回查本轮公共托盘报废状态',
`/api/platform/v1/warehouse-admin/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`)
`/api/platform/v1/overseas-warehouse-resources/${encodeURIComponent(warehouseId)}/pallets/${encodeURIComponent(palletId)}`)
context.assert(MODULE, '本轮公共托盘终态为已报废', retiredDetail.response,
id(retiredDetail.data?.id) === palletId && retiredDetail.data?.status === 'SCRAPPED',
`palletId=${id(retiredDetail.data?.id) || 'missing'}, status=${retiredDetail.data?.status || 'missing'}; ${trace(retiredDetail.response)}`, OPTIONS)