test(firstleg): resolve trucking fixtures from active catalogs

This commit is contained in:
2026-09-01 10:21:37 +08:00
parent 3d7990250f
commit 0613d1095e
2 changed files with 68 additions and 14 deletions
@@ -2,7 +2,34 @@ import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { inspectOceanBookingIdentity, platformWarehouseIdentity, truckAppointmentPayload } from './truck-appointments.mjs'
import { activeCustomerIdentity, inspectOceanBookingIdentity, platformWarehouseIdentity, truckAppointmentPayload } from './truck-appointments.mjs'
test('booking prerequisite resolves an ACTIVE platform customer without fixture state', () => {
assert.deepEqual(activeCustomerIdentity({ id: '21', tenantName: '现有客户' }),
{ customerId: '21', customerName: '现有客户' })
assert.deepEqual(activeCustomerIdentity({ tenantId: 22, customerName: '备用客户' }),
{ customerId: '22', customerName: '备用客户' })
assert.equal(activeCustomerIdentity({ id: '23' }), null)
const source = readFileSync(new URL('truck-appointments.mjs', import.meta.url), 'utf8')
assert.match(source, /\/api\/platform\/v1\/iam\/tenants\?page=1&size=100&status=ACTIVE/)
assert.match(source, /fixtureCustomerId[\s\S]*\|\| candidates\[0\]/)
})
test('channel catalog accepts the formal array response shape', () => {
const source = readFileSync(new URL('truck-appointments.mjs', import.meta.url), 'utf8')
assert.match(source, /const channelRows = records\(data\(channelsResponse\)\); const channel = channelRows\[0\]/)
assert.doesNotMatch(source, /\(data\(channelsResponse\) \|\| \[\]\)\[0\]/)
})
test('ACTIVE platform warehouses are scanned through bounded complete pagination', () => {
const source = readFileSync(new URL('truck-appointments.mjs', import.meta.url), 'utf8')
assert.match(source, /for \(let page = 1; page <= 100; page\+\+\)/)
assert.match(source, /warehouse-admin\?tenantId=0&status=ACTIVE&page=\$\{page\}&size=100/)
assert.match(source, /const total = Number\(warehousePage\?\.total \?\? warehouseRows\.length\)/)
assert.match(source, /page \* 100 >= total/)
assert.match(source, /完整分页平台仓并解析有效海运渠道/)
assert.doesNotMatch(source, /193000000000200001|193000000000200002/)
})
test('platform warehouse scope is fixed to zero without requiring response tenantId', () => {
assert.deepEqual(platformWarehouseIdentity({ warehouseId: '41', warehouseName: '宁波仓' }),
@@ -10,7 +37,8 @@ test('platform warehouse scope is fixed to zero without requiring response tenan
assert.deepEqual(platformWarehouseIdentity({ id: 42, warehouseName: '义乌仓' }),
{ warehouseId: '42', platformTenantId: '0' })
const source = readFileSync(new URL('truck-appointments.mjs', import.meta.url), 'utf8')
assert.doesNotMatch(source, /item\?\.tenantId|item\.tenantId/)
assert.match(source, /platformWarehouseIdentity\(item\)[\s\S]*platformTenantId: '0'/)
assert.doesNotMatch(source, /platformWarehouseIdentity\(item\)[^{]*\{[^}]*tenantId/)
})
test('booking identity is marker scoped and contains no customer snapshot', () => {