60 lines
3.0 KiB
JavaScript
60 lines
3.0 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const source = await readFile(fileURLToPath(new URL('./phase4-overseas-client-services.mjs', import.meta.url)), 'utf8')
|
|
|
|
test('client services module uses only stable merchant self-service paths', () => {
|
|
for (const path of [
|
|
'/api/merchant/v1/last-leg/orders',
|
|
'/api/merchant/v1/last-leg/relabel-applications',
|
|
'/api/merchant/v1/last-leg/warehouse-transfers',
|
|
'/api/merchant/v1/last-leg/cargo-discards',
|
|
'inventory-candidates',
|
|
]) assert.ok(source.includes(path), `missing ${path}`)
|
|
for (const forbidden of ['/api/pda/', '/api/platform/v1/last-leg/dispatches', '/outbound', '/delivery', '/dispatch', '/depart']) {
|
|
assert.equal(source.includes(forbidden), false, `must exclude ${forbidden}`)
|
|
}
|
|
})
|
|
|
|
test('module never borrows historical order or inventory candidates', () => {
|
|
assert.match(source, /fixture\?\.marker !== context\.marker/)
|
|
assert.match(source, /pda\?\.marker !== context\.marker/)
|
|
assert.match(source, /pda\?\.finalStatus !== 'COMPLETED'/)
|
|
assert.match(source, /completedContainers/)
|
|
assert.match(source, /markerOrderIds\.has\(id\(value\?\.orderId\)\)/)
|
|
assert.match(source, /禁止借历史一件代发库存/)
|
|
assert.doesNotMatch(source, /candidates\[0\]/)
|
|
})
|
|
|
|
test('relabel transfer and discard cover create replay conflict list detail and legal initial states', () => {
|
|
assert.match(source, /chargeAmount: 0\.01/)
|
|
assert.match(source, /cartonMark:/)
|
|
assert.match(source, /fbaCartonMark:/)
|
|
for (const token of [
|
|
'客户创建贴标申请', '客户贴标申请幂等重放', '贴标同幂等键异载荷返回A0409',
|
|
'客户查询自身贴标申请列表', '客户查询自身贴标申请详情', 'PENDING_PROCESSING',
|
|
'客户创建仓储转运申请', '客户仓储转运申请幂等重放', '转运同幂等键异载荷返回A0409',
|
|
'客户查询自身仓储转运列表', '客户查询自身仓储转运详情',
|
|
'客户创建货物废弃申请', '客户货物废弃申请幂等重放',
|
|
'客户查询自身货物废弃列表', '客户查询自身货物废弃详情', 'PENDING_REVIEW',
|
|
]) assert.ok(source.includes(token), `missing ${token}`)
|
|
})
|
|
|
|
test('customer isolation is exercised with merchant token, forged customerId and platform denial', () => {
|
|
assert.match(source, /merchantQualificationFixture/)
|
|
assert.match(source, /overseasAccessToken/)
|
|
assert.match(source, /customerId: 0/)
|
|
assert.match(source, /平台海外Token不能冒充客户访问/)
|
|
assert.match(source, /response\?\.http === 403.*codeOf\(response\) === 'A0403'/s)
|
|
})
|
|
|
|
test('module records marker-owned resources without forbidden fulfillment cleanup', () => {
|
|
assert.match(source, /createdResources\.phase4OverseasClientServices/)
|
|
assert.match(source, /relabelNo = relabelNo/)
|
|
assert.match(source, /transferNo = transferNo/)
|
|
assert.match(source, /discardNo = discardNo/)
|
|
assert.match(source, /no outbound, dispatch, PDA or delivery action is invoked/)
|
|
})
|