test: wait for customer dimension initialization

This commit is contained in:
2026-08-25 17:17:32 +08:00
parent 3ab1a9d173
commit 4e8c15dbfa
2 changed files with 22 additions and 0 deletions
@@ -15,6 +15,9 @@ test('默认全量验收先准备已审核商户再运行订单链路', () => {
test('商户夹具通过正式 File 和 IAM 审核流程建立下单资格', () => {
assert.match(fixture, /files\/qualifications\/\$\{encodeURIComponent\(tenantId\)\}\/required-package/)
assert.match(fixture, /iam\/tenants\/\$\{encodeURIComponent\(tenantId\)\}\/submit-review/)
assert.match(fixture, /iam\/tenants\/\$\{encodeURIComponent\(tenantId\)\}\/dimension-initialization/)
assert.match(fixture, /status === 'READY'/)
assert.match(fixture, /setTimeout\(resolve, 500\)/)
assert.match(fixture, /iam\/reviews\/\$\{encodeURIComponent\(review\.id\)\}\/approve/)
assert.match(fixture, /item\.status === 'APPROVED'/)
assert.match(fixture, /MERCHANT_TEST_USERNAME/)
@@ -9,6 +9,23 @@ function id(value) {
return value === undefined || value === null ? '' : String(value)
}
async function waitForDimensionInitialization(context, tenantId) {
let response = null
let status = 'PENDING'
let attempt = 0
for (; attempt < 30; attempt += 1) {
response = await context.request('GET',
`/api/platform/v1/iam/tenants/${encodeURIComponent(tenantId)}/dimension-initialization`)
status = response.http === 200 && String(response.body?.code) === '200'
? response.body?.data?.status : 'REQUEST_FAILED'
if (status === 'READY' || status === 'FAILED') break
await new Promise((resolve) => setTimeout(resolve, 500))
}
context.assert(MODULE, '客户默认尺寸后台初始化已就绪', response, status === 'READY',
`tenantId=${tenantId}, status=${status}, attempts=${attempt + 1}`, { deploymentBlocker: true })
if (status !== 'READY') throw new Error(`客户默认尺寸初始化未就绪: ${status}`)
}
export async function run(context) {
const suffix = context.marker.replace(/[^0-9A-Z]/gi, '').slice(-10).padStart(10, '0')
const phone = await context.findAvailablePhone(MODULE)
@@ -63,6 +80,8 @@ export async function run(context) {
`tenantId=${tenantId}, reviewId=${id(review?.id) || 'missing'}`, { deploymentBlocker: true })
if (!review?.id) throw new Error('未找到隔离下单客户的待审核单')
await waitForDimensionInitialization(context, tenantId)
const approveResponse = await context.request('POST',
`/api/platform/v1/iam/reviews/${encodeURIComponent(review.id)}/approve`,
{ comment: `${context.marker} 全量验收正式资质审核通过` })