This commit is contained in:
2026-08-17 17:49:03 +08:00
parent c71db4b481
commit 7c66097672
21 changed files with 1227 additions and 14 deletions
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import { PRODUCT_CATALOG, buildOrderPayload, diversifyRoutes, parseArguments, randomOrderOptions, validateCount } from './create-pending-review-orders.mjs'
import { PRODUCT_CATALOG, buildOrderPayload, diversifyRoutes, parseArguments, randomOrderOptions, selectSameChannelRoutes, validateCount } from './create-pending-review-orders.mjs'
const source = readFileSync(new URL('./create-pending-review-orders.mjs', import.meta.url), 'utf8')
@@ -101,3 +101,21 @@ test('interleaves different logistics combinations before repeating one', () =>
const secondKey = `${diversified[1].channel.channelCode}|${diversified[1].pricingTaxMode}`
assert.notEqual(firstKey, secondKey)
})
test('selects routes from exactly one logistics channel', () => {
const route = (receivingId, channelCode, pricingTaxMode, destinationCode) => ({
receiving: { id: receivingId }, channel: { channelCode }, pricingTaxMode,
destination: { warehouseCode: destinationCode },
})
const selected = selectSameChannelRoutes([
route('1', 'SEA-A', 'TAX_INCLUDED', 'A1'),
route('1', 'SEA-A', 'TAX_INCLUDED', 'A2'),
route('1', 'SEA-B', 'TAX_EXCLUDED', 'B1'),
])
assert.equal(selected.length, 2)
assert.equal(new Set(selected.map((item) => `${item.receiving.id}|${item.channel.channelCode}|${item.pricingTaxMode}`)).size, 1)
})
test('parses same-channel as a boolean flag', () => {
assert.deepEqual(parseArguments(['--count', '10', '--same-channel']), { count: '10', 'same-channel': true })
})