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

25 lines
1.2 KiB
JavaScript

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)
})
test('phase3 loading uses the collision-safe marker suffix for inventory mutation locations', async () => {
const source = await import('node:fs/promises').then((fs) => fs.readFile(
new URL('./phase3-loading.mjs', import.meta.url), 'utf8'))
assert.match(source, /const mutationSuffix = markerSuffix\(context\.marker\)/)
assert.doesNotMatch(source, /mutationSuffix = context\.marker\.replace\(\/\\D\/g/)
assert.match(source, /if \(!targetLocationId\)[\s\S]+库存变化fixture创建失败后停止旧snapshot提交[\s\S]+return/)
assert.match(source, /if \(!reboundValid\)[\s\S]+库存换绑未成功后停止旧snapshot提交[\s\S]+return/)
})