优化
This commit is contained in:
@@ -530,14 +530,11 @@ export class AcceptanceRun {
|
||||
const headers = { Accept: 'application/json', ...extraHeaders }
|
||||
if (token) headers.Authorization = `Bearer ${token}`
|
||||
if (body !== undefined) headers['Content-Type'] = 'application/json; charset=utf-8'
|
||||
const requestBody = path === '/api/auth/login' && body?.username && !body?.loginId
|
||||
? { ...body, loginId: body.username, username: undefined }
|
||||
: body
|
||||
const maxAttempts = ['GET', 'HEAD'].includes(String(method).toUpperCase()) ? 3 : 1
|
||||
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
||||
try {
|
||||
const response = await fetch(`${this.options.gateway}${path}`, {
|
||||
method, headers, body: requestBody === undefined ? undefined : JSON.stringify(requestBody),
|
||||
method, headers, body: body === undefined ? undefined : JSON.stringify(body),
|
||||
signal: AbortSignal.timeout(30_000),
|
||||
})
|
||||
const content = await response.text()
|
||||
@@ -913,8 +910,8 @@ export class AcceptanceRun {
|
||||
|
||||
async findAvailablePhone(module = 'customers') {
|
||||
this.phoneSequence = Number(this.phoneSequence || 0) + 1
|
||||
const markerDigits = this.marker.replace(/\D/g, '').slice(-8).padStart(8, '0')
|
||||
const phone = `18${markerDigits}${String(this.phoneSequence % 10).padStart(1, '0')}`
|
||||
const markerDigits = this.marker.replace(/\D/g, '').slice(-7).padStart(7, '0')
|
||||
const phone = `18${markerDigits}${String(this.phoneSequence % 100).padStart(2, '0')}`
|
||||
this.addStep(module, '生成本轮隔离测试联系电话', null, /^1\d{10}$/.test(phone),
|
||||
`sequence=${this.phoneSequence}`)
|
||||
return phone
|
||||
|
||||
Reference in New Issue
Block a user