test: automate overseas wallet and pallet cost closure
This commit is contained in:
@@ -13,7 +13,7 @@ function response(data, code = '200') { return { http: 200, body: { code, messag
|
||||
function voidResponse() { return { http: 200, body: { code: '200', message: 'success' }, requestId: 'request-test', traceId: 'trace-test' } }
|
||||
function page(records = []) { return { records, page: 1, size: 20, total: records.length, pages: records.length ? 1 : 0 } }
|
||||
function contextFixture({ tenants = [{ id: '10001', status: 'ACTIVE' }], warehouseRecords = [{ id: '20001', status: 'ACTIVE', warehouseType: 'OVERSEAS', warehouseCode: 'LAX', warehouseName: '洛杉矶仓' }] } = {}) {
|
||||
const calls = []; const steps = []; const gaps = []; let createdPallet = null; let createdLocation = null; let createdRelabel = null
|
||||
const calls = []; const steps = []; const gaps = []; let createdPallet = null; let createdLocation = null
|
||||
const context = {
|
||||
context: {}, createdResources: {}, marker: 'ACC-PHASE4-TEST', calls, steps, gaps,
|
||||
async request(method, requestPath, body) {
|
||||
@@ -35,15 +35,6 @@ function contextFixture({ tenants = [{ id: '10001', status: 'ACTIVE' }], warehou
|
||||
if (Number(body.version) !== Number(createdPallet.version)) return response(null, 'A0409')
|
||||
createdPallet = { ...createdPallet, ...body, version: createdPallet.version + 1 }; return voidResponse()
|
||||
}
|
||||
if (method === 'POST' && requestPath.startsWith('/api/platform/v1/last-leg/relabel-applications?')) {
|
||||
if (createdRelabel && body.remark !== createdRelabel.remark) return response(null, 'A0409')
|
||||
if (!createdRelabel) createdRelabel = { ...body, relabelNo: 'FBR-TEST', status: 'PENDING_PROCESSING' }
|
||||
return response({ application: createdRelabel, items: body.items, history: [] })
|
||||
}
|
||||
if (method === 'PUT' && requestPath.endsWith('/relabel-applications/FBR-TEST/status')) {
|
||||
createdRelabel = { ...createdRelabel, status: body.status }
|
||||
return response({ application: createdRelabel, items: createdRelabel.items, history: [] })
|
||||
}
|
||||
if (requestPath.startsWith('/api/platform/v1/last-leg/orders?')) return response(page([{ id: '30001', orderNo: 'LL-1', currentStatus: 'PENDING_ASSIGNMENT' }]))
|
||||
if (requestPath.includes('/last-leg/orders/30001?')) return response({ order: { id: '30001' }, cargo: [], statusHistory: [] })
|
||||
if (requestPath.startsWith('/api/platform/v1/last-leg/relabel-applications?')) return response(page([{ id: '40001', relabelNo: 'RL-1', status: 'PENDING_PROCESSING' }]))
|
||||
@@ -80,7 +71,7 @@ test('模块只依赖注入请求,不读取环境或自行联网', () => {
|
||||
assert.doesNotMatch(source, /process\.env|fetch\(|requestBinary/)
|
||||
})
|
||||
|
||||
test('既有仓库场景只写本轮库位托盘与换标生命周期', () => {
|
||||
test('既有仓库场景只写本轮库位与托盘生命周期', () => {
|
||||
const context = contextFixture()
|
||||
return run(context).then(() => {
|
||||
assert.ok(context.calls.length >= 12)
|
||||
@@ -93,8 +84,8 @@ test('既有仓库场景只写本轮库位托盘与换标生命周期', () => {
|
||||
const writes = context.calls.filter((call) => call.method !== 'GET')
|
||||
assert.ok(writes.some((call) => call.method === 'DELETE' && call.path.includes('/locations/72002')))
|
||||
assert.ok(writes.some((call) => call.path.includes('/warehouse-admin/20001/pallets')))
|
||||
assert.ok(writes.some((call) => call.path.includes('/relabel-applications')))
|
||||
assert.ok(writes.every((call) => call.path.includes('/warehouse-admin/20001/') || call.path.includes('/relabel-applications')))
|
||||
assert.equal(writes.some((call) => call.path.includes('/relabel-applications')), false)
|
||||
assert.ok(writes.every((call) => call.path.includes('/warehouse-admin/20001/')))
|
||||
for (const name of ['编辑本轮公共库位', '删除本轮公共库位', '报废本轮公共托盘']) {
|
||||
const step = context.steps.find((item) => item.name === name)
|
||||
assert.ok(step?.passed, name)
|
||||
@@ -123,10 +114,10 @@ test('覆盖冻结的海外只读列表与有记录才查详情', async () => {
|
||||
assert.equal(params.has('page'), false, call.path)
|
||||
assert.equal(params.has('size'), false, call.path)
|
||||
}
|
||||
assert.deepEqual(context.context.phase4OverseasWarehouse, { customerId: '10001', warehouseId: '20001', palletId: '71001', relabelNo: 'FBR-TEST' })
|
||||
assert.deepEqual(context.context.phase4OverseasWarehouse, { customerId: '10001', warehouseId: '20001', palletId: '71001' })
|
||||
assert.deepEqual(context.createdResources.phase4OverseasWarehouse, {
|
||||
marker: 'ACC-PHASE4-TEST', customerId: '10001', warehouseId: '20001', palletId: '71001', terminalStatus: 'SCRAPPED',
|
||||
locationId: '72002', locationTerminalStatus: 'DELETED', relabelNo: 'FBR-TEST', relabelTerminalStatus: 'COMPLETED',
|
||||
locationId: '72002', locationTerminalStatus: 'DELETED',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -158,8 +149,7 @@ test('合同覆盖库存CSV并明确排除暂缓、离仓、PDA与内部路径',
|
||||
assert.match(source, new RegExp(`longId\\(plan\\.${field}\\)`))
|
||||
}
|
||||
assert.match(source, /id\(pallet\.customerId\) === '0'/)
|
||||
assert.match(source, /创建本轮换标单/)
|
||||
assert.match(source, /换标单同幂等键不同请求返回A0409/)
|
||||
assert.doesNotMatch(source, /创建本轮换标单|verifyRelabelLifecycle/)
|
||||
assert.match(source, /创建本轮公共库位/)
|
||||
assert.match(source, /公共托盘旧版本编辑返回冲突/)
|
||||
assert.doesNotMatch(source, /deploymentBlocker|addCoverageGap|coverageGap/)
|
||||
|
||||
Reference in New Issue
Block a user