test: wait for customer dimension initialization
This commit is contained in:
@@ -15,6 +15,9 @@ test('默认全量验收先准备已审核商户再运行订单链路', () => {
|
|||||||
test('商户夹具通过正式 File 和 IAM 审核流程建立下单资格', () => {
|
test('商户夹具通过正式 File 和 IAM 审核流程建立下单资格', () => {
|
||||||
assert.match(fixture, /files\/qualifications\/\$\{encodeURIComponent\(tenantId\)\}\/required-package/)
|
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\)\}\/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, /iam\/reviews\/\$\{encodeURIComponent\(review\.id\)\}\/approve/)
|
||||||
assert.match(fixture, /item\.status === 'APPROVED'/)
|
assert.match(fixture, /item\.status === 'APPROVED'/)
|
||||||
assert.match(fixture, /MERCHANT_TEST_USERNAME/)
|
assert.match(fixture, /MERCHANT_TEST_USERNAME/)
|
||||||
|
|||||||
@@ -9,6 +9,23 @@ function id(value) {
|
|||||||
return value === undefined || value === null ? '' : String(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) {
|
export async function run(context) {
|
||||||
const suffix = context.marker.replace(/[^0-9A-Z]/gi, '').slice(-10).padStart(10, '0')
|
const suffix = context.marker.replace(/[^0-9A-Z]/gi, '').slice(-10).padStart(10, '0')
|
||||||
const phone = await context.findAvailablePhone(MODULE)
|
const phone = await context.findAvailablePhone(MODULE)
|
||||||
@@ -63,6 +80,8 @@ export async function run(context) {
|
|||||||
`tenantId=${tenantId}, reviewId=${id(review?.id) || 'missing'}`, { deploymentBlocker: true })
|
`tenantId=${tenantId}, reviewId=${id(review?.id) || 'missing'}`, { deploymentBlocker: true })
|
||||||
if (!review?.id) throw new Error('未找到隔离下单客户的待审核单')
|
if (!review?.id) throw new Error('未找到隔离下单客户的待审核单')
|
||||||
|
|
||||||
|
await waitForDimensionInitialization(context, tenantId)
|
||||||
|
|
||||||
const approveResponse = await context.request('POST',
|
const approveResponse = await context.request('POST',
|
||||||
`/api/platform/v1/iam/reviews/${encodeURIComponent(review.id)}/approve`,
|
`/api/platform/v1/iam/reviews/${encodeURIComponent(review.id)}/approve`,
|
||||||
{ comment: `${context.marker} 全量验收正式资质审核通过` })
|
{ comment: `${context.marker} 全量验收正式资质审核通过` })
|
||||||
|
|||||||
Reference in New Issue
Block a user