Files
baiyue-firstleg/scripts/admin-test-env-modules/phase3-evidence-stage-contract.test.mjs
T

26 lines
1.6 KiB
JavaScript
Raw Normal View History

2026-08-15 09:49:13 +08:00
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const source = readFileSync(new URL('./phase3-evidence-gate.mjs', import.meta.url), 'utf8')
test('evidence gate requires stable PDA identity and server LOADING before any evidence request', () => {
for (const field of ['taskId', 'inboundId', 'loadingPlanId', 'containerBookingId', 'warehouseId']) {
assert.match(source, new RegExp(`${field}`), `${field} must be part of the preflight identity`)
}
2026-08-15 10:35:54 +08:00
assert.match(source, /pda-loading\/tasks\/\$\{encodeURIComponent\(taskId\)\}\?warehouseId=/)
assert.doesNotMatch(source, /pda-loading\/tasks\?loadingPlanId=/)
2026-08-15 09:49:13 +08:00
assert.match(source, /task\?\.id\) === taskId/)
assert.match(source, /task\?\.loadingPlanId\) === loadingPlanId/)
assert.match(source, /task\?\.containerBookingId\) === containerBookingId/)
assert.match(source, /taskItem\?\.inboundId\) === inboundId/)
2026-08-15 11:05:58 +08:00
assert.match(source, /\['LOADING', 'LOADED'\]\.includes\(inbound\?\.summary\?\.processStatus\)/)
assert.match(source, /if \(!evidenceReadable\)[\s\S]*return/)
2026-08-15 09:49:13 +08:00
assert.match(source, /AWAITING_REVIEW 不作为证据开放条件/)
const gate = source.slice(source.indexOf('const taskResponse'), source.indexOf('const path ='))
assert.doesNotMatch(gate, /loading\/evidence/)
assert.match(source, /const path = `\/api\/platform\/v1\/first-leg\/pda-loading\/tasks\/\$\{encodeURIComponent\(taskId\)\}\/evidence\?warehouseId=/)
assert.doesNotMatch(source, /api\/platform\/v1\/inbounds\/\$\{inboundId\}\/loading\/evidence/)
assert.doesNotMatch(source, /loading\/evidence\?tenantId=/)
2026-08-15 09:49:13 +08:00
})