test: strengthen customs and fulfillment acceptance boundaries

This commit is contained in:
2026-09-30 12:58:15 +08:00
parent 125ca34ba4
commit 80632ba409
13 changed files with 1616 additions and 40 deletions
@@ -1,3 +1,5 @@
import { createHash } from 'node:crypto'
const MODULE = 'merchant-qualification-fixture'
const REQUIRED_TYPES = new Set(['BUSINESS_LICENSE', 'LEGAL_PERSON_ID'])
const QUALIFICATION_IMAGE = Uint8Array.from(Buffer.from(
@@ -9,6 +11,16 @@ function id(value) {
return value === undefined || value === null ? '' : String(value)
}
export function qualificationCreditCode(marker, tenantId) {
const customerId = id(tenantId)
if (!String(marker || '').trim() || !customerId) {
throw new Error('测试资质代码必须使用完整批次标识和本轮真实客户编号')
}
const suffix = createHash('sha256').update(JSON.stringify([String(marker), customerId]))
.digest('hex').slice(0, 10).toUpperCase()
return `91440300${suffix}`
}
async function waitForDimensionInitialization(context, tenantId) {
let response = null
let status = 'PENDING'
@@ -62,7 +74,7 @@ export async function run(context, { publishEnvironment = true } = {}) {
const packageForm = new FormData()
packageForm.append('businessLicense', new File([QUALIFICATION_IMAGE], `business-${suffix}.png`, { type: 'image/png' }))
packageForm.append('legalPersonId', new File([QUALIFICATION_IMAGE], `legal-person-${suffix}.png`, { type: 'image/png' }))
const unifiedSocialCreditCode = `91440300${suffix}`
const unifiedSocialCreditCode = qualificationCreditCode(context.marker, tenantId)
const packageResponse = await context.requestWithBody('POST',
`/api/platform/v1/files/qualifications/${encodeURIComponent(tenantId)}/required-package?unifiedSocialCreditCode=${encodeURIComponent(unifiedSocialCreditCode)}`,
packageForm)