Files
baiyue-firstleg/scripts/admin-test-env-modules/phase3-loading-marker-contract.test.mjs
T

27 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-08-24 21:00:22 +08:00
import assert from 'node:assert/strict'
import test from 'node:test'
import { markerSuffix } from './phase3-loading.mjs'
test('phase3 loading fixture identifiers are deterministic and distinct across marker variants', () => {
const base = 'ADMIN-API-20260824123024536'
const primary = markerSuffix(`${base}-P4-OVERSEAS-PRIMARY`)
const secondary = markerSuffix(`${base}-P4-SECONDARY`)
assert.equal(primary, markerSuffix(`${base}-P4-OVERSEAS-PRIMARY`))
assert.notEqual(primary, secondary)
assert.match(primary, /^\d{8}-[0-9A-F]{8}$/)
assert.ok(`P3B-${primary}`.length <= 64)
})
2026-09-04 15:19:45 +08:00
test('phase3 loading uses the collision-safe marker suffix for generated business identifiers', async () => {
const source = await import('node:fs/promises').then((fs) => fs.readFile(
new URL('./phase3-loading.mjs', import.meta.url), 'utf8'))
2026-09-04 15:19:45 +08:00
assert.match(source, /const suffix = markerSuffix\(context\.marker\)/)
assert.match(source, /billOfLadingNo: `P3BL-\$\{suffix\}`/)
assert.match(source, /vesselName: `P3VESSEL-\$\{suffix\}`/)
assert.doesNotMatch(source, /suffix = context\.marker\.replace\(\/\\D\/g/)
assert.match(source, /增量后旧 inventory token 明确 A0409 并要求刷新/)
assert.match(source, /增量旧 token 冲突后 plan\/task\/items 零写入/)
})