2026-08-25 00:24:43 +08:00
|
|
|
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', () => {
|
2026-09-09 19:16:18 +08:00
|
|
|
for (const value of ['/container-preview', '/convert-container', '/pallets/supplement', '/fba-appointments/batch',
|
2026-08-25 00:24:43 +08:00
|
|
|
'/fba-appointments/${encodeURIComponent(appointmentNo)}']) assert.ok(source.includes(value), value)
|
2026-09-09 19:16:18 +08:00
|
|
|
assert.equal(source.includes("`${PLAN_BASE}/convert`"), false)
|
|
|
|
|
assert.match(source, /snapshotVersion/)
|
|
|
|
|
assert.match(source, /snapshotHash/)
|
|
|
|
|
assert.match(source, /'Idempotency-Key'/)
|
2026-08-25 00:24:43 +08:00
|
|
|
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?:\/\//)
|
|
|
|
|
})
|