This commit is contained in:
2026-08-04 21:01:34 +08:00
parent 161bf580c7
commit 2313fd238c
12 changed files with 716 additions and 24 deletions
@@ -0,0 +1,29 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const source = readFileSync(new URL('./inboundBilling.ts', import.meta.url), 'utf8')
const typesSource = readFileSync(new URL('../types/inboundBilling.ts', import.meta.url), 'utf8')
test('queries the merchant order inbound-billing endpoint without tenant parameters', () => {
assert.match(source, /url: `\/merchant\/v1\/first-leg\/orders\/\$\{orderId\}\/inbound-billing`/)
assert.match(source, /method: 'GET'/)
assert.doesNotMatch(source, /tenantId|method: '(?:POST|PUT|PATCH|DELETE)'/)
})
test('sanitizes the platform-shaped response into a merchant whitelist', () => {
assert.match(source, /function sanitizeInboundBilling/)
assert.match(source, /summary: sanitizeSummary\(response\.inbound\.summary\)/)
assert.match(source, /palletLocations: response\.inbound\.palletLocations\.map\(sanitizePalletLocation\)/)
assert.match(source, /latestFee: sanitizeFee\(response\.latestFee\)/)
assert.doesNotMatch(source, /\.\.\.response|\.\.\.summary|\.\.\.fee/)
assert.doesNotMatch(source, /internalNotes|statusHistory|files/)
})
test('keeps all backend Long identifiers as strings', () => {
for (const field of ['id', 'orderId', 'warehouseId', 'palletId', 'locationId', 'feeId', 'inboundId', 'chargeRuleId', 'carrierRateId', 'customerId', 'carrierId']) {
assert.match(typesSource, new RegExp(`${field}: string`))
}
assert.doesNotMatch(typesSource, /(?:id|Id): number/)
assert.doesNotMatch(typesSource, /internalNotes|statusHistory|files/)
})