import assert from 'node:assert/strict' import fs from 'node:fs' import path from 'node:path' import test from 'node:test' import { fileURLToPath } from 'node:url' const here = path.dirname(fileURLToPath(import.meta.url)) const source = fs.readFileSync(path.join(here, 'phase4-overseas-inbound-operations.mjs'), 'utf8') test('module covers the frozen Admin inbound-plan write surface', () => { for (const value of ['/container-preview', '/convert-container', '/pallets/supplement', '/fba-appointments/batch', '/fba-appointments/${encodeURIComponent(appointmentNo)}']) assert.ok(source.includes(value), value) assert.equal(source.includes("`${PLAN_BASE}/convert`"), false) assert.match(source, /snapshotVersion/) assert.match(source, /snapshotHash/) assert.match(source, /'Idempotency-Key'/) assert.match(source, /重复转换返回同一入仓计划/) assert.match(source, /FBA预约同单号异载荷返回A0409/) assert.match(source, /appointmentStatus: 'CANCELLED'/) }) test('module covers reversible inventory commands with idempotency and ledger proof', () => { for (const endpoint of ['/hold', '/release', '/adjust', '/ledger']) assert.ok(source.includes(endpoint), endpoint) assert.match(source, /PDA完成柜形成的库存/) assert.match(source, /库存冻结同键异载荷返回A0409/) assert.match(source, /盘点调整同键异载荷返回A0409/) assert.match(source, /库存数量恢复基线/) assert.match(source, /types\.filter\(\(type\) => type === 'ADJUST'\)\.length === 2/) }) test('module stays inside inbound and inventory scope', () => { for (const forbidden of ['/api/pda/', '/outbound', '/delivery', '/dispatch', '/ship', '/pick']) { assert.equal(source.toLowerCase().includes(forbidden), false, forbidden) } assert.doesNotMatch(source, /\bfetch\s*\(|process\.env|https?:\/\//) })