This commit is contained in:
2026-09-03 18:13:00 +08:00
parent 880f923462
commit ca288dec72
8 changed files with 50 additions and 25 deletions
@@ -244,7 +244,7 @@ async function createSecondCustomer(context) {
const fixture = context.context?.merchantQualificationFixture
if (!fixture?.tenantId || !fixture?.username || !fixture?.password || fixture.marker !== context.marker) return null
const loginResponse = await context.request('POST', '/api/auth/login',
{ username: fixture.username, password: fixture.password }, '')
{ loginId: fixture.username, password: fixture.password }, '')
const login = context.apiSuccess(MODULE, '第二隔离客户登录', loginResponse, diagnostic(loginResponse), OPTIONS)
return { customerId: id(fixture.tenantId), token: login?.accessToken }
} finally {
@@ -8,6 +8,8 @@ const CONTAINER_STATUSES = ['WAIT_LOADING', 'EDITING', 'LOADING', 'COMPLETED']
const PRELOAD_STATUSES = ['EDITING', 'LOADING']
const PDA_STATUSES = ['UNASSIGNED', 'IN_PROGRESS', 'AWAITING_REVIEW', 'COMPLETED']
import { resolveOceanBookingAgent } from './ocean-booking-fixture.mjs'
function id(value) { return value == null ? '' : String(value) }
function records(value) { return Array.isArray(value?.records) ? value.records : [] }
function suffix(context, label) {
@@ -128,14 +130,11 @@ async function createConfirmedContainer(context, source, label) {
const value = suffix(context, label)
const containerNo = iso6346ContainerNumber(`${context.marker}-manual-${label}`)
const summary = source.detail.summary
const agentResponse = await context.request('GET',
'/api/platform/v1/suppliers?tenantId=0&category=BOOKING&status=ACTIVE&page=1&size=20')
const agentPage = context.apiSuccess(MODULE, `${label} 读取 ACTIVE 订舱代理`, agentResponse, '', OPTIONS)
const agent = agentPage?.records?.find?.((item) => item?.id && item?.name)
if (!agent) throw new Error(`${label} 未取得 ACTIVE 订舱代理`)
const { ensureMatsonCarrierPartner } = await import('./carrier-partner-fixture.mjs')
const carrier = await ensureMatsonCarrierPartner(context, MODULE, OPTIONS)
if (!carrier?.id) throw new Error(`${label} 未取得 ACTIVE 船公司`)
const agent = await resolveOceanBookingAgent(context, MODULE, carrier.carrierCode, OPTIONS)
if (!agent) throw new Error(`${label} 未取得当前船公司关联的 ACTIVE 订舱代理`)
const draft = {
customerId: source.tenantId, customerName: summary.customerName || 'IT 测试客户',
channelCode: summary.channelCode, warehouseId: source.warehouseId,
@@ -85,3 +85,9 @@ test('all production booking fixtures use DRAFT release and the shared requireme
assert.match(source, /containerRequirements/, name)
}
})
test('manual PDA state fixture resolves an agent bound to the selected carrier', () => {
const source = read('manual-state-loading-pda.mjs')
assert.match(source, /resolveOceanBookingAgent\(context, MODULE, carrier\.carrierCode, OPTIONS\)/)
assert.doesNotMatch(source, /suppliers\?tenantId=0&category=BOOKING/)
})
@@ -284,7 +284,7 @@ export async function run(context) {
|| !Number.isInteger(Number(carryingSlice?.packageCount)) || Number(carryingSlice.packageCount) <= 0) return
const loginResponse = await request(context, 'POST', '/api/auth/login', {
username: MERCHANT_USERNAME, password: MERCHANT_PASSWORD,
loginId: MERCHANT_USERNAME, password: MERCHANT_PASSWORD,
}, '')
const merchantLogin = context.apiSuccess(MODULE, '客户账号登录用于真实报关文件协同', loginResponse,
`username=${MERCHANT_USERNAME}`, OPTIONS)
@@ -694,7 +694,7 @@ export async function run(context) {
`taskVersion=${unchangedAfterInvalid?.version ?? 'missing'}, items=${taskItemsSignature(unchangedAfterInvalid)}, operations=${afterInvalidOperations?.length ?? 'missing'}`, OPTIONS)
const merchantLogin = await context.request('POST', '/api/auth/login', {
username: MERCHANT_USERNAME, password: MERCHANT_PASSWORD,
loginId: MERCHANT_USERNAME, password: MERCHANT_PASSWORD,
}, '')
const merchantToken = merchantLogin.http === 200 && codeOf(merchantLogin) === '200'
? merchantLogin.body?.data?.accessToken : null