test(acceptance): reuse fixed customers and align native fulfillment flows

This commit is contained in:
2026-10-23 04:48:02 +08:00
parent b92f7fe991
commit 139f6b1932
51 changed files with 1076 additions and 228 deletions
@@ -1,6 +1,6 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { receiveWarehouseTransfer } from './warehouse-transfer-receipt.mjs'
import { findReusableTransferReceiptTarget, receiveWarehouseTransfer } from './warehouse-transfer-receipt.mjs'
// 收货替身使用独立目标仓资源,覆盖资源不足、串单、重复入库和结算未完成。
function fixture(fault = '') {
@@ -56,6 +56,23 @@ test('原转运复用异仓托盘收货并核对唯一入库和结算终态', as
assert.equal(f.calls.length, count)
})
test('造单前只读选取异仓目的仓,翻过同仓和未绑定目的仓的托盘且不改主档', async () => {
const f = fixture()
const request = async (method, path) => {
assert.equal(method, 'GET')
if (path.includes('/pallets?') && path.includes('page=1&')) return { total: '201', records: Array.from({ length: 200 }, (_, i) => ({
id: String(1000 + i), customerId: '0', warehouseId: i % 2 ? '201' : '202', status: 'IDLE', locationId: '701',
fbaWarehouseCode: i % 2 ? 'FBA-OTHER' : null })) }
if (path.includes('/pallets?')) return { total: '201', records: [{ id: '601', customerId: '0', warehouseId: '202', status: 'IDLE', locationId: '701', fbaWarehouseCode: 'FBA-1' }] }
return (await f.context.request(method, path)).body.data
}
const target = await findReusableTransferReceiptTarget({ sourceWarehouseId: '201', request,
check: (name, ok) => assert.ok(ok, name) })
assert.equal(target.pallet.fbaWarehouseCode, 'FBA-1')
assert.equal(target.warehouse.id, '202')
assert.equal(f.calls.some(c => c.method !== 'GET'), false)
})
for (const fault of ['no resource', 'occupied', 'location blocked', 'network', 'target drift', 'foreign customer', 'double receipt', 'replay drift', 'unsettled', 'disk']) {
test(`转运收货遇到 ${fault} 明确失败且不补造资源`, async () => {
const f = fixture(fault)