Files
baiyue-firstleg/scripts/admin-test-env-modules/it-test-wait-split-bulk-contract.test.mjs
T

61 lines
3.5 KiB
JavaScript
Raw Normal View History

2026-08-27 09:21:01 +08:00
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const acceptance = readFileSync(new URL('../admin-test-env-acceptance.mjs', import.meta.url), 'utf8')
const orders = readFileSync(new URL('./orders.mjs', import.meta.url), 'utf8')
const measurement = readFileSync(new URL('./inbound-measurement.mjs', import.meta.url), 'utf8')
const runner = readFileSync(new URL('../it-test-wait-split-bulk.mjs', import.meta.url), 'utf8')
2026-08-27 11:38:53 +08:00
const warehouseLocationResources = readFileSync(new URL('../../warehouse/src/main/java/com/baiyue/warehouse/service/LocationResourceService.java', import.meta.url), 'utf8')
2026-08-27 09:21:01 +08:00
2026-09-01 11:38:42 +08:00
test('Admin 通用单票支持到1000箱且八千票专项入口限制为300箱', () => {
2026-08-27 09:21:01 +08:00
assert.match(acceptance, /--wait-split-package-count <n>/)
assert.match(acceptance, /wait-split-package-count必须是1-1000的整数或0/)
assert.match(acceptance, /packageCounts\.push\(remaining\)/)
assert.match(acceptance, /Math\.ceil\(totalPackageCount \/ 30\)/)
assert.match(orders, /packageCounts\[index\] \|\| packageCountPerSku/)
assert.match(measurement, /detailPackageCounts\.reduce\(\(sum, count\) => sum \+ count, 0\)/)
assert.match(measurement, /detailPackageCounts\.slice\(0, detailIndex\)/)
2026-09-01 11:38:42 +08:00
assert.match(runner, /boxMax > 300/)
2026-08-27 09:21:01 +08:00
})
test('随机线路只固定义乌仓并从客户真实可计价候选选择', () => {
assert.match(acceptance, /route-mode <mode>/)
assert.match(acceptance, /random线路必须固定起运仓名称/)
assert.match(orders, /Client 查询固定起运仓随机渠道池/)
assert.match(orders, /findPricedOrderRoute\(\{/)
assert.match(orders, /Client 登录企业与指定客户名称一致/)
assert.doesNotMatch(runner, /channel-name|channel-code/)
})
test('称重只随机复用固定托盘且不创建新托盘', () => {
2026-08-27 11:09:51 +08:00
assert.match(measurement, /REUSABLE_PALLET_CODES = Object\.freeze\(\['TP-001', 'YW-TP-002'\]\)/)
assert.match(measurement, /context\.request\('GET',[\s\S]*\/api\/platform\/v1\/pallets\?page=1&size=20/)
assert.match(measurement, /randomlyReusePalletIds\(candidates, palletCount/)
assert.match(measurement, /随机复用原有称重托盘/)
assert.match(measurement, /固定称重托盘主数据完整/)
assert.doesNotMatch(measurement, /context\.request\('POST', '\/api\/platform\/v1\/pallets/)
assert.doesNotMatch(acceptance, /createPhase3FreshMeasurementPallet/)
2026-08-27 11:09:51 +08:00
})
2026-08-27 11:38:53 +08:00
test('称重脚本不新增库位且容量不足由仓库服务复用 A0 公共位', () => {
assert.doesNotMatch(measurement, /context\.request\('POST', '\/api\/platform\/v1\/locations/)
assert.doesNotMatch(measurement, /创建测量占用库位/)
assert.match(measurement, /普通位不足会复用唯一的 A0 共享溢出位/)
assert.match(warehouseLocationResources, /selected\.size\(\) < quantity[\s\S]*lockOrCreateSharedOverflow/)
})
2026-08-27 09:21:01 +08:00
test('八千票执行器逐票记录且失败后继续', () => {
assert.match(runner, /positiveInteger\(values\.get\('count'\), 8000/)
assert.match(runner, /positiveInteger\(values\.get\('box-max'\), 300/)
assert.match(runner, /randomInt\(boxMin, boxMax \+ 1\)/)
assert.match(runner, /Math\.ceil\(packageCount \/ 30\)/)
assert.match(runner, /for \(let offset = 0; offset < count; offset \+= 1\)/)
assert.match(runner, /event: 'planned'/)
assert.match(runner, /event: 'result'/)
assert.match(runner, /options\.markerNamespace = workerId/)
assert.match(runner, /failureDirectory/)
assert.match(runner, /summary\.failed \+= 1/)
assert.match(runner, /summary\.attempted % batchSize === 0/)
})