34 lines
2.0 KiB
JavaScript
34 lines
2.0 KiB
JavaScript
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/)
|
|
assert.match(source, /cargoes: Array\.from\(\{ length: cargoCount \}/)
|
|
assert.match(source, /cargoName: '', packageType: 'CARTON', packageCount: index \+ 1, grossWeightKg: 0, volumeCbm: 0/)
|
|
assert.match(source, /destinationType: 'FBA'/)
|
|
assert.match(source, /destinationType: 'OVERSEAS'/)
|
|
assert.match(source, /destinationType: 'PRIVATE'/)
|
|
assert.match(source, /addresses\?addressType=PRIVATE_DESTINATION/)
|
|
assert.match(source, /privateDestinationAddressId: String\(address\.id\)/)
|
|
})
|
|
|
|
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/)
|
|
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/)
|
|
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\)/)
|
|
})
|