完成单机TEST统一入口与可靠投递回归收尾

This commit is contained in:
2026-09-29 19:48:34 +08:00
parent 64a70c9f28
commit 6c0a026cc4
89 changed files with 968 additions and 983 deletions
@@ -28,7 +28,7 @@ function query(path, values) {
function future(days) { return new Date(Date.now() + days * 86_400_000).toISOString().slice(0, 19) }
async function merchant(context, token, method, name, path, body) {
const response = await context.requestOverseas(method, path, body, {}, token)
const response = await context.request(method, path, body, token, {})
const data = context.apiSuccess(MODULE, name, response, trace(response), OPTIONS)
return { response, data }
}
@@ -51,9 +51,9 @@ async function loginMerchant(context) {
loginId: fixture.username, password: fixture.password,
}, '')
const auth = context.apiSuccess(MODULE, '客户工作台账号登录', response, trace(response), OPTIONS)
context.assert(MODULE, '客户登录返回海外访问Token', response, nonBlank(auth?.overseasAccessToken),
`tokenPresent=${Boolean(auth?.overseasAccessToken)}; ${trace(response)}`, OPTIONS)
return nonBlank(auth?.overseasAccessToken) ? auth.overseasAccessToken : null
context.assert(MODULE, '客户登录返回海外访问Token', response, nonBlank(auth?.accessToken),
`tokenPresent=${Boolean(auth?.accessToken)}; ${trace(response)}`, OPTIONS)
return nonBlank(auth?.accessToken) ? auth.accessToken : null
}
async function currentOrders(context, token) {
@@ -136,7 +136,7 @@ async function verifyRelabel(context, token, order) {
const replay = await merchant(context, token, 'POST', '客户贴标申请幂等重放', RELABEL, body)
context.assert(MODULE, '贴标重放复用同一申请', replay.response,
id(replay.data?.application?.relabelNo) === relabelNo, trace(replay.response), OPTIONS)
const hashConflict = await context.requestOverseas('POST', RELABEL, { ...body, remark: `${context.marker}-DIFFERENT` }, {}, token)
const hashConflict = await context.request('POST', RELABEL, { ...body, remark: `${context.marker}-DIFFERENT` }, token, {})
context.addStep(MODULE, '贴标同幂等键异载荷返回A0409', hashConflict, conflict(hashConflict), trace(hashConflict), OPTIONS)
const page = await merchant(context, token, 'GET', '客户查询自身贴标申请列表',
query(RELABEL, { page: 1, size: 20, relabelNo, customerId: 0 }))
@@ -189,8 +189,7 @@ async function verifyTransfer(context, token, orders) {
// reconcile from the authoritative detail before asserting the state.
let submitted = null
for (let attempt = 1; attempt <= 3; attempt += 1) {
const response = await context.requestOverseas('POST',
`${TRANSFER}/${encodeURIComponent(transferNo)}/submit`, undefined, {}, token)
const response = await context.request('POST', `${TRANSFER}/${encodeURIComponent(transferNo)}/submit`, undefined, token, {})
if (response?.http === 0 && attempt < 3) {
await new Promise(resolve => setTimeout(resolve, 800 * attempt))
continue
@@ -214,7 +213,7 @@ async function verifyTransfer(context, token, orders) {
const replay = await merchant(context, token, 'POST', '客户仓储转运申请幂等重放', TRANSFER, body)
context.assert(MODULE, '转运重放复用同一申请', replay.response,
id(replay.data?.transferNo) === transferNo, trace(replay.response), OPTIONS)
const hashConflict = await context.requestOverseas('POST', TRANSFER, { ...body, remark: `${context.marker}-DIFFERENT` }, {}, token)
const hashConflict = await context.request('POST', TRANSFER, { ...body, remark: `${context.marker}-DIFFERENT` }, token, {})
context.addStep(MODULE, '转运同幂等键异载荷返回A0409', hashConflict, conflict(hashConflict), trace(hashConflict), OPTIONS)
const page = await merchant(context, token, 'GET', '客户查询自身仓储转运列表',
query(TRANSFER, { page: 1, size: 20, transferNo, customerId: 0 }))
@@ -231,7 +230,7 @@ async function verifyTransfer(context, token, orders) {
}
async function verifyDiscard(context, token, markerOrders) {
const response = await context.requestOverseas('GET', `${DISCARD}/inventory-candidates`, undefined, {}, token)
const response = await context.request('GET', `${DISCARD}/inventory-candidates`, undefined, token, {})
const candidates = context.apiSuccess(MODULE, '客户查询货物废弃库存候选', response, trace(response), OPTIONS)
const markerOrderIds = new Set(markerOrders.map((value) => id(value.row?.id)))
const candidate = Array.isArray(candidates) ? candidates.find((value) => markerOrderIds.has(id(value?.orderId))
@@ -281,8 +280,8 @@ export async function run(context) {
if (!token) return
for (const [name, path] of [['贴标', RELABEL], ['仓储转运', TRANSFER], ['货物废弃', DISCARD]]) {
const denied = await context.requestOverseas('GET', query(path, { page: 1, size: 1 }))
context.addStep(MODULE, `平台海外Token不能冒充客户访问${name}`, denied, forbidden(denied), trace(denied), OPTIONS)
const denied = await context.request('GET', query(path, { page: 1, size: 1 }))
context.addStep(MODULE, `平台统一Token不能冒充客户访问${name}`, denied, forbidden(denied), trace(denied), OPTIONS)
}
const orders = await currentOrders(context, token)