Files
baiyue-firstleg/scripts/client-quick-order-test-env-acceptance.contract.test.mjs
T

34 lines
2.0 KiB
JavaScript
Raw Normal View History

2026-09-04 10:51:25 +08:00
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
const source = await readFile(new URL('./client-quick-order-test-env-acceptance.mjs', import.meta.url), 'utf8')
test('quick-order HTTP acceptance uses the same endpoint and skeletal cargo payload as Client', () => {
assert.match(source, /\/api\/merchant\/v1\/orders\/first-leg\/batch/)
2026-09-04 11:35:19 +08:00
assert.match(source, /cargoes: Array\.from\(\{ length: cargoCount \}/)
assert.match(source, /cargoName: '', packageType: 'CARTON', packageCount: index \+ 1, grossWeightKg: 0, volumeCbm: 0/)
2026-09-04 10:51:25 +08:00
assert.match(source, /destinationType: 'FBA'/)
assert.match(source, /destinationType: 'OVERSEAS'/)
assert.match(source, /destinationType: 'PRIVATE'/)
assert.match(source, /addresses\?addressType=PRIVATE_DESTINATION/)
2026-09-04 11:35:19 +08:00
assert.match(source, /privateDestinationAddressId: String\(address\.id\)/)
2026-09-04 10:51:25 +08:00
})
2026-09-04 11:35:19 +08:00
test('quick-order HTTP acceptance verifies expanded row, cargo, isolation, retry, and idempotency behavior', () => {
assert.match(source, /expected succeeded=5/)
assert.match(source, /cargo count mismatch/)
assert.match(source, /unowned private address must fail closed with A0404/)
assert.match(source, /duplicate clientRowId must fail independently with A0409/)
2026-09-04 10:51:25 +08:00
assert.match(source, /draft must belong to the authenticated enterprise/)
assert.match(source, /same idempotency key replays the same quick-order drafts/)
assert.match(source, /idempotent replay returned different order IDs/)
2026-09-04 11:35:19 +08:00
assert.match(source, /same row id and idempotency key reject a changed payload/)
assert.match(source, /a corrected failed row succeeds under a fresh batch key/)
assert.match(source, /--random-count <1-50>/)
assert.match(source, /create \$\{randomCount\} randomized quick-order drafts/)
assert.match(source, /verify all \$\{randomCount\} randomized drafts/)
assert.match(source, /replay all \$\{randomCount\} randomized drafts idempotently/)
assert.match(source, /randomInt\(1, 6\)/)
2026-09-04 10:51:25 +08:00
})