优化
This commit is contained in:
@@ -51,6 +51,11 @@ function expectedCodes() {
|
||||
...Array.from({ length: 110 }, (_, index) => `FEE_TYPE_${String(index + 1).padStart(3, '0')}`),
|
||||
].sort()
|
||||
}
|
||||
/** 正式基线按受控编码识别;其他业务合法扩展不计入112条基线。 */
|
||||
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('全量验收费用-')
|
||||
@@ -91,16 +96,16 @@ export async function run(context) {
|
||||
const initialPageResponse = await context.request('GET', query({ page: 1, size: 20 }))
|
||||
const initialPage = context.apiSuccess(MODULE, '费用项目查看权限与分页查询', initialPageResponse,
|
||||
'page=1,size=20', OPTIONS)
|
||||
context.assert(MODULE, '正式目录112条且默认20条对应6页', initialPageResponse,
|
||||
records(initialPage).length === 20 && Number(initialPage?.total) === BASELINE_COUNT
|
||||
&& Number(initialPage?.pages) === 6 && Number(initialPage?.page) === 1,
|
||||
const initial = await listAll(context)
|
||||
context.assert(MODULE, '全部目录默认20条分页与完整列表一致', initialPageResponse,
|
||||
records(initialPage).length === Math.min(20, initial.rows.length) && Number(initialPage?.total) === initial.rows.length
|
||||
&& Number(initialPage?.pages) === Math.ceil(initial.rows.length / 20) && Number(initialPage?.page) === 1,
|
||||
`records=${records(initialPage).length}, total=${initialPage?.total ?? 'n/a'}, pages=${initialPage?.pages ?? 'n/a'}`, OPTIONS)
|
||||
context.assert(MODULE, '费用项目查询不传 accountId 仍成功', initialPageResponse,
|
||||
success(initialPageResponse) && !String(initialPageResponse.path || initialPageResponse.request?.path || '').includes('accountId'),
|
||||
`path=${initialPageResponse.path || 'missing'}`, OPTIONS)
|
||||
|
||||
const initial = await listAll(context)
|
||||
const initialRows = initial.rows
|
||||
const initialRows = formalFeeItems(initial.rows)
|
||||
const domestic = initialRows.filter((row) => row.tradeScope === 'DOMESTIC')
|
||||
const international = initialRows.filter((row) => row.tradeScope === 'INTERNATIONAL')
|
||||
const actualCodes = initialRows.map((row) => row.feeCode).sort()
|
||||
@@ -126,7 +131,8 @@ export async function run(context) {
|
||||
const response = await context.request('GET', query({ tradeScope: scope, page: 1, size: 200 }))
|
||||
const page = context.apiSuccess(MODULE, `按 ${scope} 贸易范围筛选`, response, '', OPTIONS)
|
||||
context.assert(MODULE, `${scope} 筛选数量和范围正确`, response,
|
||||
Number(page?.total) === expected && records(page).every((row) => row.tradeScope === scope),
|
||||
Number(page?.total) === initial.rows.filter(row => row.tradeScope === scope).length
|
||||
&& formalFeeItems(records(page)).length === expected && records(page).every((row) => row.tradeScope === scope),
|
||||
`total=${page?.total ?? 'n/a'}, records=${records(page).length}`, OPTIONS)
|
||||
}
|
||||
|
||||
@@ -142,8 +148,9 @@ export async function run(context) {
|
||||
|
||||
const activeResponse = await context.request('GET', query({ status: 'ACTIVE', page: 1, size: 200 }))
|
||||
const activePage = context.apiSuccess(MODULE, '按 ACTIVE 状态筛选费用项目', activeResponse, '', OPTIONS)
|
||||
context.assert(MODULE, 'ACTIVE 筛选返回112条且无停用记录', activeResponse,
|
||||
Number(activePage?.total) === BASELINE_COUNT && records(activePage).every((row) => row.status === 'ACTIVE'),
|
||||
context.assert(MODULE, 'ACTIVE 筛选覆盖112条正式项目且无停用记录', activeResponse,
|
||||
Number(activePage?.total) === initial.rows.filter(row => row.status === 'ACTIVE').length
|
||||
&& formalFeeItems(records(activePage)).length === BASELINE_COUNT && records(activePage).every((row) => row.status === 'ACTIVE'),
|
||||
`total=${activePage?.total ?? 'n/a'}`, OPTIONS)
|
||||
|
||||
const merchantLoginResponse = await context.request('POST', '/api/auth/login', {
|
||||
@@ -273,8 +280,10 @@ export async function run(context) {
|
||||
`feeItemId=${feeItemId}`, OPTIONS)
|
||||
}
|
||||
const final = await listAll(context)
|
||||
context.assert(MODULE, '清理后恢复112条正式基线且无临时编码或名称', final.response,
|
||||
final.rows.length === BASELINE_COUNT && !final.rows.some((row) => row.feeCode === createPayload.feeCode
|
||||
context.assert(MODULE, '清理后保留原目录与112条正式基线且无本轮临时项目', final.response,
|
||||
formalFeeItems(final.rows).length === BASELINE_COUNT
|
||||
&& final.rows.map(row => row.feeCode).sort().join(',') === initial.rows.map(row => row.feeCode).sort().join(',')
|
||||
&& !final.rows.some((row) => row.feeCode === createPayload.feeCode
|
||||
|| String(row.feeTypeName).includes(suffix)),
|
||||
`rows=${final.rows.length}, temporary=${final.rows.filter((row) => row.feeCode === createPayload.feeCode).length}`, OPTIONS)
|
||||
context.createdResources.feeItems = {
|
||||
|
||||
Reference in New Issue
Block a user