import assert from 'node:assert/strict' import { readFileSync } from 'node:fs' import { test } from 'node:test' const productionFixtures = [ 'manual-state-loading-pda.mjs', 'ocean-booking-fixture.mjs', 'ocean-bookings.mjs', 'phase3-carrier-schedule-queries.mjs', 'phase3-container-loading.mjs', 'phase3-loading.mjs', 'phase3-order-splitting.mjs', 'phase3-port-schedules.mjs', ] function source(name) { return readFileSync(new URL(name, import.meta.url), 'utf8') } test('HTTP fixtures use the canonical primary and mismatch container specifications', () => { const primarySources = productionFixtures.map(source).join('\n') const containerFlow = source('phase3-container-loading.mjs') assert.match(primarySources, /containerType: '40HC'[\s\S]*?capacityCbm: 76[\s\S]*?maxWeightKg: 28000/) assert.match(containerFlow, /containerType: '20GP'[\s\S]*?capacityCbm: 33[\s\S]*?maxWeightKg: 28000/) }) test('HTTP fixtures do not reintroduce retired aliases or arbitrary specifications', () => { for (const name of productionFixtures) { const fixture = source(name) assert.doesNotMatch(fixture, /40HQ|45HQ/, name) assert.doesNotMatch(fixture, /capacityCbm:\s*(?:100|68|28)(?:\D|$)/, name) assert.doesNotMatch(fixture, /maxWeightKg:\s*(?:100000|22000)(?:\D|$)/, name) } }) test('the frozen catalog is complete and unambiguous', () => { // Keep every future fixture producer constrained to the same product catalog as Admin and Firstleg. const catalog = Object.freeze({ '20GP': Object.freeze({ capacityCbm: 33, maxWeightKg: 28000 }), '40GP': Object.freeze({ capacityCbm: 67, maxWeightKg: 28000 }), '40HC': Object.freeze({ capacityCbm: 76, maxWeightKg: 28000 }), '40NR': Object.freeze({ capacityCbm: 67, maxWeightKg: 28000 }), '45HC': Object.freeze({ capacityCbm: 86, maxWeightKg: 28000 }), }) assert.deepEqual(Object.keys(catalog), ['20GP', '40GP', '40HC', '40NR', '45HC']) assert.equal(new Set(Object.keys(catalog)).size, 5) })