2026-08-17 14:46:44 +08:00
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import test from 'node:test'
|
|
|
|
|
|
|
|
|
|
const supplierFixture = readFileSync(new URL('./suppliers.mjs', import.meta.url), 'utf8')
|
|
|
|
|
const financeFixture = readFileSync(new URL('./finance-full-fixtures.mjs', import.meta.url), 'utf8')
|
2026-08-17 19:13:08 +08:00
|
|
|
const oceanBookingFixture = readFileSync(new URL('./ocean-bookings.mjs', import.meta.url), 'utf8')
|
2026-08-17 14:46:44 +08:00
|
|
|
const supplierOpenapi = readFileSync(new URL('../../warehouse/src/main/resources/openapi/supplier-v1.yaml', import.meta.url), 'utf8')
|
|
|
|
|
const firstlegSnapshot = readFileSync(new URL('../../firstleg/src/main/java/com/baiyue/firstleg/service/WarehouseSupplierSnapshotService.java', import.meta.url), 'utf8')
|
|
|
|
|
const firstlegClient = readFileSync(new URL('../../firstleg/src/main/java/com/baiyue/firstleg/client/WarehouseSupplierClient.java', import.meta.url), 'utf8')
|
|
|
|
|
|
|
|
|
|
test('booking supplier fixtures keep ACTIVE and BOOKING but never invent a geographic scope gate', () => {
|
|
|
|
|
assert.match(supplierFixture, /category:'BOOKING'/)
|
|
|
|
|
assert.match(supplierFixture, /status:'ACTIVE'/)
|
|
|
|
|
assert.doesNotMatch(supplierFixture, /scope\s*:/)
|
|
|
|
|
|
|
|
|
|
const supplierBody = financeFixture.slice(financeFixture.indexOf('export function buildSupplierBody'),
|
|
|
|
|
financeFixture.indexOf('async function createOrder'))
|
|
|
|
|
assert.match(supplierBody, /category,/)
|
|
|
|
|
assert.match(supplierBody, /status: 'ACTIVE'/)
|
|
|
|
|
assert.doesNotMatch(supplierBody, /scope|DOMESTIC|INTERNATIONAL/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Warehouse supplier contract filters by active category without scope in query, save or snapshot', () => {
|
|
|
|
|
assert.match(supplierOpenapi, /name: requireActive/)
|
|
|
|
|
assert.match(supplierOpenapi, /name: category/)
|
|
|
|
|
assert.match(supplierOpenapi, /required: \[supplierId, name, category, status\]/)
|
|
|
|
|
assert.doesNotMatch(supplierOpenapi, /\bScope\b|name: scope|\bscope:/)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Firstleg booking supplier snapshot requires ACTIVE BOOKING and has no domestic/international argument', () => {
|
|
|
|
|
assert.match(firstlegSnapshot, /return resolve\(supplierId, suppliedName, "BOOKING"\)/)
|
|
|
|
|
assert.match(firstlegSnapshot, /!"ACTIVE"\.equals\(response\.data\(\)\.status\(\)\)/)
|
|
|
|
|
assert.match(firstlegSnapshot, /!category\.equals\(response\.data\(\)\.category\(\)\)/)
|
|
|
|
|
assert.doesNotMatch(firstlegSnapshot, /"INTERNATIONAL"|"DOMESTIC"|String scope/)
|
|
|
|
|
assert.doesNotMatch(firstlegClient, /String scope|String category,\s*String scope/s)
|
|
|
|
|
})
|
2026-08-17 19:13:08 +08:00
|
|
|
|
|
|
|
|
test('HTTP ocean booking acceptance selects an ACTIVE BOOKING supplier without a geographic scope', () => {
|
|
|
|
|
assert.match(oceanBookingFixture, /category=BOOKING&status=ACTIVE/)
|
2026-08-24 10:33:05 +08:00
|
|
|
assert.match(oceanBookingFixture, /bookingAgentId: id\(agent\.id\), bookingAgentName: agent\.name/)
|
|
|
|
|
assert.match(oceanBookingFixture, /shippingCompanyId: id\(agent\.id\), shippingCompanyName: agent\.name/)
|
|
|
|
|
assert.match(oceanBookingFixture, /使用 ACTIVE BOOKING 订舱代理事实源/)
|
2026-08-17 19:13:08 +08:00
|
|
|
assert.doesNotMatch(oceanBookingFixture, /category=BOOKING[^'\n]*scope=/)
|
|
|
|
|
})
|