test(admin): unwrap container workbench details
This commit is contained in:
@@ -22,6 +22,7 @@ function failure(response) {
|
||||
|| (response?.http === 200 && codeOf(response) !== '200')
|
||||
}
|
||||
function records(page) { return Array.isArray(page?.records) ? page.records : [] }
|
||||
function containerRecord(value) { return value?.container || value }
|
||||
|
||||
async function waitForCompletedTask(context, taskId, warehouseId, attempts = 45) {
|
||||
let response = null
|
||||
@@ -260,7 +261,7 @@ export async function run(context) {
|
||||
}
|
||||
|
||||
const containerDetailResponse = await context.request('GET', `${DOMESTIC_CONTAINERS}/${containerId}`)
|
||||
const containerDetail = context.apiSuccess(MODULE, '回查货柜详情', containerDetailResponse, '', OPTIONS)
|
||||
const containerDetail = containerRecord(context.apiSuccess(MODULE, '回查货柜详情', containerDetailResponse, '', OPTIONS))
|
||||
context.assert(MODULE, '货柜详情保留候选货物路线约束', containerDetailResponse,
|
||||
(!containerDetail?.destinationWarehouseCode || !candidate.destinationWarehouseCode
|
||||
|| containerDetail.destinationWarehouseCode === candidate.destinationWarehouseCode)
|
||||
@@ -400,7 +401,7 @@ export async function run(context) {
|
||||
if (!unlinkedTaskAbsent) return
|
||||
|
||||
const simulationBeforeLinkResponse = await context.request('GET', `${DOMESTIC_CONTAINERS}/${containerId}`)
|
||||
const simulationBeforeLink = context.apiSuccess(MODULE, '预装确认前读取模拟柜最新版本', simulationBeforeLinkResponse, '', OPTIONS)
|
||||
const simulationBeforeLink = containerRecord(context.apiSuccess(MODULE, '预装确认前读取模拟柜最新版本', simulationBeforeLinkResponse, '', OPTIONS))
|
||||
if (!Number.isInteger(Number(simulationBeforeLink?.version))) return
|
||||
|
||||
const bookingCreate = await request(context, 'POST', '/api/platform/v1/ocean-bookings',
|
||||
@@ -474,7 +475,7 @@ export async function run(context) {
|
||||
const activeContainersResponse = await context.request('GET',
|
||||
`${DOMESTIC_CONTAINERS}?page=1&size=50&keyword=${encodeURIComponent(realContainerNo)}`)
|
||||
const activeContainers = context.apiSuccess(MODULE, '关联后按真实柜号回查正常货柜列表', activeContainersResponse, '', OPTIONS)
|
||||
const activeRealRows = records(activeContainers).filter((item) => item.containerNo === realContainerNo)
|
||||
const activeRealRows = records(activeContainers).map(containerRecord).filter((item) => item.containerNo === realContainerNo)
|
||||
context.assert(MODULE, '关联后列表仅保留模拟柜原地补全的一条 ACTIVE 操作身份', activeContainersResponse,
|
||||
activeRealRows.length === 1 && id(activeRealRows[0]?.id) === containerId,
|
||||
`activeIds=${activeRealRows.map((item) => id(item?.id)).join('|') || 'none'}`, OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user