优化
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
import { findPricedOrderRoute } from './orders.mjs'
|
||||
import { findPricedOrderRoute, findPricedOrderRouteAcrossOrigins } from './orders.mjs'
|
||||
|
||||
const source = readFileSync(new URL('orders.mjs', import.meta.url), 'utf8')
|
||||
|
||||
@@ -13,7 +13,30 @@ test('orders fixture verifies the complete pricing tuple before selecting an FBA
|
||||
assert.match(source, new RegExp(`${field}:`))
|
||||
}
|
||||
assert.match(source, /estimateMatches\(response, candidate\)/)
|
||||
assert.doesNotMatch(source, /const destination = records\(fbaPage\)\[0\]/)
|
||||
assert.doesNotMatch(source, /records\(domesticPage\)\[0\]/)
|
||||
assert.match(source, /findPricedOrderRouteAcrossOrigins/)
|
||||
assert.match(source, /warehouse\?\.status === 'ACTIVE'/)
|
||||
})
|
||||
|
||||
test('pricing selection skips an ACTIVE domestic warehouse with an empty channel catalog', async () => {
|
||||
const channelCalls = []
|
||||
const result = await findPricedOrderRouteAcrossOrigins({
|
||||
receivings: [{ id: 'unpriced', status: 'ACTIVE' }, { id: 'priced', status: 'ACTIVE' }],
|
||||
destinations: [{ id: 'abe3', warehouseCode: 'ABE3', warehouseName: 'ABE3' }],
|
||||
loadChannels: async (receiving) => {
|
||||
channelCalls.push(receiving.id)
|
||||
return receiving.id === 'unpriced'
|
||||
? { http: 200, body: { code: '200', data: [] }, requestId: 'channels-empty', traceId: 'trace-empty' }
|
||||
: { http: 200, body: { code: '200', data: [{ priceBookVersionId: '19', channelCode: 'EXX_RAIL_NY', pricingTaxModes: ['TAX_INCLUDED'] }] } }
|
||||
},
|
||||
estimate: async (request) => ({ http: 200, body: { code: '200', data: {
|
||||
priceBookVersionId: '19', channelCode: request.channelCode, pricingTaxMode: request.pricingTaxMode,
|
||||
} } }),
|
||||
})
|
||||
assert.deepEqual(channelCalls, ['unpriced', 'priced'])
|
||||
assert.equal(result.receiving.id, 'priced')
|
||||
assert.equal(result.priced.destination.warehouseCode, 'ABE3')
|
||||
assert.equal(result.originFailures[0].requestId, 'channels-empty')
|
||||
})
|
||||
|
||||
test('order payload reuses the tax mode from the successful estimate', () => {
|
||||
|
||||
Reference in New Issue
Block a user