This commit is contained in:
2026-08-17 16:45:43 +08:00
parent 592da4d7e2
commit c71db4b481
6 changed files with 308 additions and 17 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, validateCount } from './create-pending-review-orders.mjs'
import { PRODUCT_CATALOG, buildOrderPayload, diversifyRoutes, parseArguments, randomOrderOptions, validateCount } from './create-pending-review-orders.mjs'
const source = readFileSync(new URL('./create-pending-review-orders.mjs', import.meta.url), 'utf8')
@@ -50,6 +50,11 @@ test('builds an order payload owned by the fixed profile', () => {
},
product: PRODUCT_CATALOG[0],
packageCount: 7,
options: {
tradeTerm: 'EXW', pickupMethod: 'SELF_TRUCK', taxMode: 'TAX_REFUND',
customsInspection: true, expectedShipDays: 15,
senderLocation: { province: '浙江省', city: '义乌市', district: '稠城街道', postalCode: '322000' },
},
productImageFileId: '33',
})
assert.equal(payload.receivingWarehouseId, '11')
@@ -58,6 +63,11 @@ test('builds an order payload owned by the fixed profile', () => {
assert.equal(payload.customerName, '固定测试客户')
assert.equal(payload.cargoes.length, 1)
assert.equal(payload.cargoes[0].productImageFileId, '33')
assert.equal(payload.tradeTerm, 'EXW')
assert.equal(payload.pickupMethod, 'SELF_TRUCK')
assert.equal(payload.taxMode, 'TAX_REFUND')
assert.equal(payload.customsInspection, true)
assert.equal(payload.sender, null)
assert.equal(payload.cargoes[0].cargoName, PRODUCT_CATALOG[0].cargoName)
assert.equal(payload.cargoes[0].packageCount, 7)
assert.equal(payload.cargoes[0].totalQuantity, PRODUCT_CATALOG[0].unitsPerPackage * 7)
@@ -65,6 +75,17 @@ test('builds an order payload owned by the fixed profile', () => {
assert.equal(payload.cargoes[0].declaredValue, PRODUCT_CATALOG[0].unitDeclaredValue * PRODUCT_CATALOG[0].unitsPerPackage * 7)
})
test('randomizes only supported basic-order fields', () => {
for (let index = 0; index < 100; index += 1) {
const options = randomOrderOptions()
assert.ok(['FOB', 'EXW', 'CIF', 'DDP'].includes(options.tradeTerm))
assert.ok(['SELF_EXPRESS', 'PICKUP', 'SELF_TRUCK'].includes(options.pickupMethod))
assert.ok(['BUY_DECLARATION', 'TAX_REFUND'].includes(options.taxMode))
assert.equal(typeof options.customsInspection, 'boolean')
assert.ok(options.expectedShipDays >= 7 && options.expectedShipDays <= 60)
}
})
test('interleaves different logistics combinations before repeating one', () => {
const route = (receivingId, channelCode, pricingTaxMode, destinationCode) => ({
receiving: { id: receivingId }, channel: { channelCode }, pricingTaxMode,