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') const oceanBookingFixture = readFileSync(new URL('./ocean-bookings.mjs', import.meta.url), 'utf8') 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) }) test('HTTP ocean booking acceptance selects an ACTIVE BOOKING supplier without a geographic scope', () => { assert.match(oceanBookingFixture, /category=BOOKING&status=ACTIVE/) assert.match(oceanBookingFixture, /bookingAgentId: bookingAgent\.supplierId/) assert.match(oceanBookingFixture, /订舱持久化启用订舱供应商快照/) assert.doesNotMatch(oceanBookingFixture, /category=BOOKING[^'\n]*scope=/) })