fix: complete October 22 workflow feedback and request failure recovery
This commit is contained in:
@@ -4,7 +4,33 @@ import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { buildContainerCostBody, buildSupplierBody, normalizeFinanceFixtureSources, run,
|
||||
supplierCategoryForFeeItem, loadSupplier } from './finance-full-fixtures.mjs'
|
||||
supplierCategoryForFeeItem, loadSupplier, ensureCustomerChargeRule } from './finance-full-fixtures.mjs'
|
||||
|
||||
for (const mode of ['single', 'default', 'missing', 'wrong mode', 'foreign customer', 'ambiguous', 'two defaults']) {
|
||||
test(`fixed customer charge rules are read-only and fail closed: ${mode}`, async () => {
|
||||
const good = { id: '701', customerId: '456', status: 'ACTIVE', businessType: 'FBA', taxMode: 'TAX_EXCLUDED', chargeMode: 'CBM', defaultRule: false }
|
||||
let rules = [good]
|
||||
if (mode === 'default') rules = [{ ...good, defaultRule: true }, { ...good, id: '702', chargeMode: 'KG' }]
|
||||
if (mode === 'missing') rules = []
|
||||
if (mode === 'wrong mode') rules = [{ ...good, chargeMode: 'KG' }]
|
||||
if (mode === 'foreign customer') rules = [{ ...good, customerId: '999' }]
|
||||
if (mode === 'ambiguous') rules = [good, { ...good, id: '702', chargeMode: 'KG' }]
|
||||
if (mode === 'two defaults') rules = [{ ...good, defaultRule: true }, { ...good, id: '702', defaultRule: true }]
|
||||
const calls = [], checks = [], before = structuredClone(rules)
|
||||
const context = { options: { fixedCustomerId: '456' },
|
||||
async request(method, path) { calls.push({ method, path }); assert.equal(method, 'GET');
|
||||
return { body: { data: path.includes('/inbounds/') ? { summary: { businessType: 'FBA' } } : rules } } },
|
||||
apiSuccess(_m, _n, response) { return response.body.data },
|
||||
assert(_m, _n, _r, passed) { checks.push(passed) },
|
||||
}
|
||||
const invoke = () => ensureCustomerChargeRule(context, { tenantId: '456', inboundId: '100' }, { pricingTaxMode: 'TAX_EXCLUDED', chargeUnit: 'CBM' })
|
||||
if (['single', 'default'].includes(mode)) assert.equal((await invoke()).id, '701')
|
||||
else await assert.rejects(invoke(), /禁止自动创建或切换/)
|
||||
assert.deepEqual(rules, before)
|
||||
assert.equal(calls.length, 2)
|
||||
assert.equal(checks.at(-1), ['single', 'default'].includes(mode))
|
||||
})
|
||||
}
|
||||
|
||||
test('fixed customer supplier selection paginates and never creates a fallback', async () => {
|
||||
const calls = [], failures = []
|
||||
|
||||
Reference in New Issue
Block a user