This commit is contained in:
2026-10-21 15:10:44 +08:00
parent 40a03978cd
commit 6fe632f28e
34 changed files with 372 additions and 110 deletions
@@ -13,7 +13,7 @@ test('固定托盘缺失停止造数,不查询其他托盘;补齐后同仓
const query = new URL(path, 'http://offline').searchParams
const code = query.get('palletCode')
assert.ok(code, '固定模式禁止用无编号列表替换缺失资源')
return { records: complete || code === 'TP-001'
return { records: complete
? [{ id: code === 'TP-001' ? '1' : '2', palletCode: code, warehouseId: 'offline-fixed-pallet' }] : [] }
},
apiSuccess(_module, _name, response) { return response },
@@ -31,6 +31,20 @@ test('固定托盘缺失停止造数,不查询其他托盘;补齐后同仓
assert.equal(requests.length, 4, '失败不得缓存为成功')
})
test('指定托盘池仅剩一只时可复用,不要求同时存在两只', async () => {
const context = {
context: {},
async request(_method, path) {
const code = new URL(path, 'http://offline').searchParams.get('palletCode')
assert.ok(['TP-001', 'YW-TP-002'].includes(code))
return { records: code === 'YW-TP-002' ? [{ id: '2', palletCode: code, warehouseId: 'offline-single-pallet' }] : [] }
},
apiSuccess(_module, _name, response) { return response },
assert(_module, _name, _response, passed) { assert.equal(passed, true) },
}
assert.deepEqual(await reusablePallets(context, 'offline-single-pallet'), [{ id: '2', code: 'YW-TP-002' }])
})
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')
@@ -62,7 +76,7 @@ test('称重只随机复用固定托盘且不创建新托盘', () => {
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.match(measurement, /指定称重托盘池至少存在一只可复用托盘/)
assert.doesNotMatch(measurement, /context\.request\('POST', '\/api\/platform\/v1\/pallets/)
assert.doesNotMatch(acceptance, /createPhase3FreshMeasurementPallet/)
})