This commit is contained in:
2026-09-03 18:13:00 +08:00
parent 880f923462
commit ca288dec72
8 changed files with 50 additions and 25 deletions
+3 -6
View File
@@ -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