fix(scripts): use domestic container detail route

This commit is contained in:
2026-09-08 23:06:07 +08:00
parent f7f4c80806
commit 00990fedcc
6 changed files with 32 additions and 5 deletions
@@ -0,0 +1,20 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const read = (name) => readFileSync(new URL(name, import.meta.url), 'utf8')
test('domestic container fixtures use the current workbench detail route', () => {
const containerLoading = read('./phase3-container-loading.mjs')
assert.ok(containerLoading.includes("context.request('GET', `${CONTAINERS}/domestic/${containerId}`)"))
assert.ok(!containerLoading.includes("context.request('GET', `${CONTAINERS}/${containerId}`)"))
const loading = read('./phase3-loading.mjs')
assert.ok(loading.includes("context.request('GET', `/api/platform/v1/containers/domestic/${containerBookingId}`)"))
assert.ok(!loading.includes("context.request('GET', `/api/platform/v1/containers/${containerBookingId}`)"))
const crossRegion = read('./phase4-cross-region-events.mjs')
const fixtureId = 'encodeURIComponent(id(phase3.containerBookingId))'
assert.ok(crossRegion.includes(`/api/platform/v1/containers/domestic/\${${fixtureId}}`))
assert.ok(!crossRegion.includes(`/api/platform/v1/containers/\${${fixtureId}}`))
})
@@ -36,6 +36,8 @@ test('port link mutates the simulation through the frozen four-field request', (
}) })
test('HTTP fixture keeps simulation and plan identities and creates allocation at link', () => { test('HTTP fixture keeps simulation and plan identities and creates allocation at link', () => {
assert.ok(fixture.includes("context.request('GET', `${CONTAINERS}/domestic/${containerId}`)"))
assert.ok(!fixture.includes("context.request('GET', `${CONTAINERS}/${containerId}`)"))
assert.match(fixture, /关联前后内部柜次、计划和排货明细身份稳定/) assert.match(fixture, /关联前后内部柜次、计划和排货明细身份稳定/)
assert.match(fixture, /订舱 allocation 原子创建并指向稳定模拟柜身份/) assert.match(fixture, /订舱 allocation 原子创建并指向稳定模拟柜身份/)
assert.match(fixture, /已消费订舱需求拒绝再次关联/) assert.match(fixture, /已消费订舱需求拒绝再次关联/)
@@ -258,7 +258,7 @@ export async function run(context) {
} }
} }
const containerDetailResponse = await context.request('GET', `${CONTAINERS}/${containerId}`) const containerDetailResponse = await context.request('GET', `${CONTAINERS}/domestic/${containerId}`)
const containerDetail = context.apiSuccess(MODULE, '回查货柜详情', containerDetailResponse, '', OPTIONS) const containerDetail = context.apiSuccess(MODULE, '回查货柜详情', containerDetailResponse, '', OPTIONS)
context.assert(MODULE, '货柜详情保留候选货物路线约束', containerDetailResponse, context.assert(MODULE, '货柜详情保留候选货物路线约束', containerDetailResponse,
(!containerDetail?.destinationWarehouseCode || !candidate.destinationWarehouseCode (!containerDetail?.destinationWarehouseCode || !candidate.destinationWarehouseCode
@@ -398,7 +398,7 @@ export async function run(context) {
unlinkedTaskAbsent, responseEvidence(unlinkedTaskResponse), OPTIONS) unlinkedTaskAbsent, responseEvidence(unlinkedTaskResponse), OPTIONS)
if (!unlinkedTaskAbsent) return if (!unlinkedTaskAbsent) return
const simulationBeforeLinkResponse = await context.request('GET', `${CONTAINERS}/${containerId}`) const simulationBeforeLinkResponse = await context.request('GET', `${CONTAINERS}/domestic/${containerId}`)
const simulationBeforeLink = context.apiSuccess(MODULE, '预装确认前读取模拟柜最新版本', simulationBeforeLinkResponse, '', OPTIONS) const simulationBeforeLink = context.apiSuccess(MODULE, '预装确认前读取模拟柜最新版本', simulationBeforeLinkResponse, '', OPTIONS)
if (!Number.isInteger(Number(simulationBeforeLink?.version))) return if (!Number.isInteger(Number(simulationBeforeLink?.version))) return
@@ -589,7 +589,7 @@ export async function run(context) {
`taskId=${taskId || 'missing'}, itemId=${id(pickItem?.id) || 'missing'}`, OPTIONS) `taskId=${taskId || 'missing'}, itemId=${id(pickItem?.id) || 'missing'}`, OPTIONS)
if (!taskId || !pickItem?.id) return if (!taskId || !pickItem?.id) return
const releasedContainerResponse = await context.request('GET', `${CONTAINERS}/${containerId}`) const releasedContainerResponse = await context.request('GET', `${CONTAINERS}/domestic/${containerId}`)
const releasedContainer = context.apiSuccess(MODULE, '任务生成后回查货柜运输版本', releasedContainerResponse, '', OPTIONS) const releasedContainer = context.apiSuccess(MODULE, '任务生成后回查货柜运输版本', releasedContainerResponse, '', OPTIONS)
const stableIdentity = { const stableIdentity = {
@@ -506,7 +506,7 @@ export async function run(context) {
&& Boolean(requirement?.id) && (!bookingConfirmed?.containers || bookingConfirmed.containers.length === 0), && Boolean(requirement?.id) && (!bookingConfirmed?.containers || bookingConfirmed.containers.length === 0),
`bookingId=${bookingId || 'missing'}, status=${bookingConfirmed?.oceanBooking?.status || 'missing'}`, OPTIONS) `bookingId=${bookingId || 'missing'}, status=${bookingConfirmed?.oceanBooking?.status || 'missing'}`, OPTIONS)
if (!bookingId || !requirement?.id || !frozenTransportMatches) return if (!bookingId || !requirement?.id || !frozenTransportMatches) return
const latestContainerResponse = await context.request('GET', `/api/platform/v1/containers/${containerBookingId}`) const latestContainerResponse = await context.request('GET', `/api/platform/v1/containers/domestic/${containerBookingId}`)
const latestContainer = context.apiSuccess(MODULE, '合并前读取模拟柜最新版本', latestContainerResponse, '', OPTIONS) const latestContainer = context.apiSuccess(MODULE, '合并前读取模拟柜最新版本', latestContainerResponse, '', OPTIONS)
const linkResponse = await request(context, 'POST', `/api/platform/v1/containers/${containerBookingId}/ocean-booking-link`, { const linkResponse = await request(context, 'POST', `/api/platform/v1/containers/${containerBookingId}/ocean-booking-link`, {
oceanBookingId: bookingId, requirementId: id(requirement.id), oceanBookingId: bookingId, requirementId: id(requirement.id),
@@ -8,6 +8,11 @@ import { run } from './phase4-cross-region-events.mjs'
const source = readFileSync(new URL('./phase4-cross-region-events.mjs', import.meta.url), 'utf8') const source = readFileSync(new URL('./phase4-cross-region-events.mjs', import.meta.url), 'utf8')
const system = readFileSync(new URL('./system.mjs', import.meta.url), 'utf8') const system = readFileSync(new URL('./system.mjs', import.meta.url), 'utf8')
test('cross-region denial probes the current domestic container detail route', () => {
assert.ok(source.includes('/api/platform/v1/containers/domestic/${encodeURIComponent(id(phase3.containerBookingId))}'))
assert.ok(!source.includes('/api/platform/v1/containers/${encodeURIComponent(id(phase3.containerBookingId))}'))
})
function response(path, data, http = 200, code = '200') { function response(path, data, http = 200, code = '200') {
return { method: 'GET', path, http, body: { code, data }, requestId: 'request-1', traceId: 'trace-1' } return { method: 'GET', path, http, body: { code, data }, requestId: 'request-1', traceId: 'trace-1' }
} }
@@ -51,7 +51,7 @@ export async function run(context) {
} }
const overseasTokenAgainstDomestic = await context.request('GET', const overseasTokenAgainstDomestic = await context.request('GET',
`/api/platform/v1/containers/${encodeURIComponent(id(phase3.containerBookingId))}`, `/api/platform/v1/containers/domestic/${encodeURIComponent(id(phase3.containerBookingId))}`,
undefined, context.overseasToken) undefined, context.overseasToken)
context.assert(MODULE, '海外Token不能访问国内Audience', overseasTokenAgainstDomestic, context.assert(MODULE, '海外Token不能访问国内Audience', overseasTokenAgainstDomestic,
denied(overseasTokenAgainstDomestic) && traced(overseasTokenAgainstDomestic), denied(overseasTokenAgainstDomestic) && traced(overseasTokenAgainstDomestic),