fix: complete October 22 workflow feedback and request failure recovery

This commit is contained in:
2026-10-22 23:06:00 +08:00
parent f701456de1
commit a16a85e14a
85 changed files with 1518 additions and 277 deletions
+14 -23
View File
@@ -56,10 +56,6 @@ export function formalFeeItems(rows) {
const codes = new Set(expectedCodes())
return rows.filter(row => codes.has(row.feeCode))
}
export function isAcceptanceFeeItem(row) {
return /^ACPT_\d+$/.test(String(row?.feeCode || ''))
&& String(row?.feeTypeName || '').startsWith('全量验收费用-')
}
function fixture(context) {
const candidates = [context.createdResources?.orders, context.createdResources?.testInbound,
context.createdResources?.inboundMeasurement, context.context?.testInbound]
@@ -73,26 +69,7 @@ async function listAll(context) {
return { response, page, rows: records(page) }
}
async function cleanupStaleAcceptanceItems(context) {
const listed = await listAll(context)
const stale = listed.rows.filter(isAcceptanceFeeItem)
const failed = []
for (const row of stale) {
const response = await context.request('DELETE', `${BASE}/${encodeURIComponent(id(row.id))}`)
if (!cleanupSucceeded(response)) failed.push({ row, response })
}
const response = failed[0]?.response || listed.response
context.assert(MODULE, '前置清理历史验收临时费用项目', response, failed.length === 0,
failed.length === 0
? `stale=${stale.length}, cleaned=${stale.length}`
: `failed=${failed.map(({ row, response: failure }) => `${row.feeCode}:${failure.body?.code || failure.http}`).join(',')}`,
OPTIONS)
return failed.length === 0
}
export async function run(context) {
if (!await cleanupStaleAcceptanceItems(context)) return
const initialPageResponse = await context.request('GET', query({ page: 1, size: 20 }))
const initialPage = context.apiSuccess(MODULE, '费用项目查看权限与分页查询', initialPageResponse,
'page=1,size=20', OPTIONS)
@@ -158,12 +135,26 @@ export async function run(context) {
}, '')
const merchantLogin = success(merchantLoginResponse) ? merchantLoginResponse.body?.data : null
const merchantToken = merchantLogin?.accessToken
try {
const forbiddenResponse = merchantToken
? await context.request('GET', query({ page: 1, size: 20 }), undefined, merchantToken)
: merchantLoginResponse
context.assert(MODULE, '无费用项目平台权限的客户账号被拒绝', forbiddenResponse,
Boolean(merchantToken) && forbidden(forbiddenResponse),
`HTTP=${forbiddenResponse.http}, code=${forbiddenResponse.body?.code ?? 'missing'}`, OPTIONS)
} finally {
if (merchantToken && merchantLogin.refreshToken) {
const logout = await context.request('POST', '/api/auth/logout', { refreshToken: merchantLogin.refreshToken }, merchantToken)
context.assert(MODULE, '退出费用目录权限核验会话', logout, success(logout), '', OPTIONS)
}
}
if (context.options?.fixedCustomerId) {
context.createdResources.feeItems = { marker: context.marker, mode: 'READ_ONLY', baselineCount: initialRows.length }
context.addCoverageGap(MODULE, 'fixed-fee-item-lifecycle', '费用项目增删改生命周期',
'固定客户模式只读核对现有费用目录,不创建、修改或删除公共主档及历史测试项目', 'not-implemented', { blocking: false })
return
}
const suffix = context.marker.replace(/\D/g, '').slice(-12)
const createPayload = payload(suffix)