Files
baiyue-firstleg/scripts/admin-test-env-modules/inbound-measurement-box-code-contract.test.mjs
T

35 lines
1.7 KiB
JavaScript
Raw Normal View History

2026-08-13 19:00:33 +08:00
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const source = readFileSync(new URL('inbound-measurement.mjs', import.meta.url), 'utf8')
test('measurement acceptance scans the stable box code frozen by first print', () => {
assert.match(source, /const boxCode = `\$\{inboundCode\}#\$\{originalPackageCount\}-1`/)
assert.doesNotMatch(source, /#V\d+#/)
})
test('reprint and Mojia scan share the same frozen box code variable', () => {
assert.match(source, /重复整单打印复用已冻结箱码映射[\s\S]*boxCode=\$\{boxCode\}/)
assert.match(source, /const firstScanResponse = await multipartRequest[\s\S]*boxCode, \.\.\.firstDimensions/)
})
2026-08-17 13:47:20 +08:00
test('measurement submission confirms weight evidence before submit', () => {
assert.match(source, /files\/measurements\/\$\{tenantId\}\/\$\{inboundId\}/)
assert.match(source, /\/weight-results\?\$\{query\(tenantId\)\}/)
assert.match(source, /\/weight-results\/\$\{created\.id\}\/confirm\?\$\{query\(tenantId\)\}/)
assert.match(source, /createConfirmedWeightEvidence[\s\S]*\/measurement\/submit/)
})
test('measurement fixture derives pallet resources from confirmed image count', () => {
2026-08-26 11:10:42 +08:00
assert.match(source, /waitSplitVariant\?\.palletCount \|\| 1/)
assert.match(source, /palletIds: warehouseResourcesReady\.palletIds/)
assert.match(source, /confirmedRows\.length === palletIds\.length/)
2026-08-17 13:47:20 +08:00
assert.doesNotMatch(source, /Math\.ceil\(Number\(totalVolumeCbm\)/)
assert.doesNotMatch(source, /Math\.ceil\(totalVolume \/ DEFAULT_PALLET_CAPACITY_CBM\)/)
})
2026-08-27 09:21:01 +08:00
test('volume ceiling removes binary floating point noise before scaling', () => {
assert.match(source, /Number\.EPSILON \* Math\.max\(1, Math\.abs\(value\)\) \* 4/)
})