Skip to content

Commit c0fce08

Browse files
committed
APIAuto: 解决回归测完场景串联用例后,因为部分接口绑定帐号导致其它未绑定帐号接口查看响应结果停留在上个
1 parent e30251a commit c0fce08

1 file changed

Lines changed: 104 additions & 73 deletions

File tree

  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js

‎APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js/main.js‎

Lines changed: 104 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ https://github.com/Tencent/APIJSON/issues
12651265
otherEnvCookieMap: {},
12661266
allSummary: {},
12671267
currentAccountIndex: 0,
1268+
testAccountIndex: 0,
12681269
currentChainGroupIndex: -1,
12691270
currentDocIndex: -1,
12701271
currentRandomIndex: -1,
@@ -2735,10 +2736,10 @@ https://github.com/Tencent/APIJSON/issues
27352736
const testCases = App.testCases
27362737
const position = index
27372738

2738-
const id = curAccount.id
2739-
const name = curAccount.name
2740-
const account = curAccount.account || curAccount.phone
2741-
const info = JSON.stringify(curAccount)
2739+
const id = curAccount.id || 0
2740+
const name = curAccount.name || ''
2741+
const account = curAccount.account || curAccount.phone || ''
2742+
const info = JSON.stringify(curAccount) || '{}'
27422743

27432744
this.request(true, REQUEST_TYPE_POST, REQUEST_TYPE_JSON, this.server + '/put', {
27442745
Chain: {
@@ -4604,7 +4605,7 @@ https://github.com/Tencent/APIJSON/issues
46044605
this.changeScriptType(App.scriptType)
46054606

46064607
var accountIdStr = String(item != null && item.isLoggedIn ? item.id || 0 : 0)
4607-
var tests = this.isStatisticsEnabled && this.reportId != null && this.reportId > 0 ? this.tests[accountIdStr] : null
4608+
var tests = this.isCrossEnabled && this.isStatisticsEnabled && this.reportId != null && this.reportId > 0 ? this.tests[accountIdStr] : null
46084609
if (JSONObject.isEmpty(tests) != true) {
46094610
this.showCompare4TestCaseList(true)
46104611
if (! this.isTestCaseShow) {
@@ -4673,27 +4674,43 @@ https://github.com/Tencent/APIJSON/issues
46734674
if (callback != null) {
46744675
callback(true, index, err)
46754676
}
4677+
4678+
if (App.isCrossEnabled && App.isStatisticsEnabled && App.reportId != null && App.reportId > 0) {
4679+
if (item != null) {
4680+
item.isLoggedIn = true
4681+
}
4682+
4683+
var accountIdStr = String(item != null && item.isLoggedIn ? item.id || 0 : 0)
4684+
var tests = App.tests[accountIdStr]
4685+
if (JSONObject.isEmpty(tests) != true) {
4686+
App.showCompare4TestCaseList(true)
4687+
if (! App.isTestCaseShow) {
4688+
App.showCompare4RandomList(true, false)
4689+
App.showCompare4RandomList(true, true)
4690+
}
4691+
}
4692+
}
46764693
}
46774694
});
46784695
}
46794696

46804697
}
46814698

4682-
if (this.isStatisticsEnabled && this.reportId != null && this.reportId > 0) {
4683-
if (item != null) {
4684-
item.isLoggedIn = true
4685-
}
4686-
4687-
var accountIdStr = String(item != null && item.isLoggedIn ? item.id || 0 : 0)
4688-
var tests = this.tests[accountIdStr]
4689-
if (JSONObject.isEmpty(tests) != true) {
4690-
this.showCompare4TestCaseList(true)
4691-
if (! this.isTestCaseShow) {
4692-
this.showCompare4RandomList(true, false)
4693-
this.showCompare4RandomList(true, true)
4694-
}
4695-
}
4696-
}
4699+
// if (this.isStatisticsEnabled && this.reportId != null && this.reportId > 0) {
4700+
// if (item != null) {
4701+
// item.isLoggedIn = true
4702+
// }
4703+
//
4704+
// var accountIdStr = String(item != null && item.isLoggedIn ? item.id || 0 : 0)
4705+
// var tests = this.tests[accountIdStr]
4706+
// if (JSONObject.isEmpty(tests) != true) {
4707+
// this.showCompare4TestCaseList(true)
4708+
// if (! this.isTestCaseShow) {
4709+
// this.showCompare4RandomList(true, false)
4710+
// this.showCompare4RandomList(true, true)
4711+
// }
4712+
// }
4713+
// }
46974714
return;
46984715
}
46994716

@@ -4792,16 +4809,16 @@ https://github.com/Tencent/APIJSON/issues
47924809
}
47934810
}
47944811

4795-
// if (! find) {
4796-
// testInfo.isLoggedIn = false
4797-
// accounts.push(testInfo)
4798-
//// this.saveAccounts()
4799-
//
4800-
// var isStatisticsEnabled = this.isStatisticsEnabled
4801-
// this.isStatisticsEnabled = false
4802-
//// this.onClickAccount(accounts.length - 1, testInfo)
4803-
// this.isStatisticsEnabled = isStatisticsEnabled
4804-
// }
4812+
if (! find) {
4813+
testInfo.isLoggedIn = false
4814+
accounts.push(testInfo)
4815+
// this.saveAccounts()
4816+
4817+
var isStatisticsEnabled = this.isStatisticsEnabled
4818+
this.isStatisticsEnabled = false
4819+
// this.onClickAccount(accounts.length - 1, testInfo)
4820+
this.isStatisticsEnabled = isStatisticsEnabled
4821+
}
48054822
map[chain.testAccountId] = true
48064823

48074824
this.currentAccountIndex = lastAccountIndex || 0
@@ -10732,7 +10749,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1073210749
}
1073310750

1073410751
var isCross = this.isCrossEnabled
10735-
var accountIndex = isCross ? -1 : this.currentAccountIndex
10752+
var accountIndex = this.testAccountIndex = isCross ? -1 : this.currentAccountIndex
1073610753

1073710754
var accounts = this.accounts
1073810755
var num = accounts == null ? 0 : accounts.length
@@ -10792,7 +10809,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1079210809

1079310810
if (isCross) {
1079410811
var isCrossDone = accountIndex >= accounts.length
10795-
this.crossProcess = isCrossDone ? '交叉账号:已开启' : ('交叉账号: ' + (accountIndex + 1) + '/' + accounts.length)
10812+
this.crossProcess = isCrossDone ? '交叉账号:已开启' : ('交叉账号: ' + ((this.testAccountIndex || 0) + 1) + '/' + accounts.length)
1079610813
if (isCrossDone) {
1079710814
this.testProcess = (this.isMLEnabled ? '机器学习:已开启' : '机器学习:已关闭')
1079810815
this.testRandomProcess = ''
@@ -10907,16 +10924,16 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1090710924
}
1090810925
}
1090910926

10910-
// if (! find) {
10911-
// testInfo.isLoggedIn = false
10912-
// accounts.push(testInfo)
10913-
//// this.saveAccounts()
10914-
//
10915-
// var isStatisticsEnabled = this.isStatisticsEnabled
10916-
// this.isStatisticsEnabled = false
10917-
//// this.onClickAccount(accounts.length - 1, testInfo)
10918-
// this.isStatisticsEnabled = isStatisticsEnabled
10919-
// }
10927+
if (! find) {
10928+
testInfo.isLoggedIn = false
10929+
accounts.push(testInfo)
10930+
// this.saveAccounts()
10931+
10932+
var isStatisticsEnabled = this.isStatisticsEnabled
10933+
this.isStatisticsEnabled = false
10934+
// this.onClickAccount(accounts.length - 1, testInfo)
10935+
this.isStatisticsEnabled = isStatisticsEnabled
10936+
}
1092010937
map[chain.testAccountId] = true
1092110938
}
1092210939

@@ -11061,24 +11078,29 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1106111078
}
1106211079
const header = hdr
1106311080

11064-
const chain = item.Chain || {}
11065-
const testInfo = chain.testInfo || {}
11066-
const accounts = (chain.testAccountId == null || StringUtil.isEmpty(String(chain.testAccountId)) ? null : this.accounts) || []
11067-
var accountIndex2 = accountIndex
11068-
for (var i = 0; i < accounts.length; i ++) {
11069-
var acc = accounts[i]
11070-
if (acc != null && (acc.id == chain.testAccountId || ( acc.baseUrl = testInfo.baseUrl && (
11071-
(StringUtil.isNotEmpty(item.phone) && acc.phone == testInfo.phone)
11072-
|| (StringUtil.isNotEmpty(item.email) && acc.email == testInfo.email) )
11073-
))) {
11074-
accountIndex2 = this.currentAccountIndex = i
11075-
acc.isLoggedIn = testInfo.isLoggedIn == null || testInfo.isLoggedIn
11076-
break
11077-
}
11081+
const chain = item.Chain
11082+
const testInfo = (chain || {}).testInfo || {}
11083+
if (chain != null) {
11084+
const testAccountId = chain.testAccountId
11085+
const accounts = this.accounts || []
11086+
if (StringUtil.isEmpty(testAccountId, true)) {
11087+
chain.testAccountId = (accounts[accountIndex] || {}).id
11088+
} else {
11089+
for (var i = 0; i < accounts.length; i ++) {
11090+
var acc = accounts[i]
11091+
if (acc != null && (acc.id == testAccountId || ( acc.baseUrl = testInfo.baseUrl && (
11092+
(StringUtil.isNotEmpty(item.phone) && acc.phone == testInfo.phone)
11093+
|| (StringUtil.isNotEmpty(item.email) && acc.email == testInfo.email) )
11094+
))) {
11095+
chain.testAccountId = acc.id
11096+
accountIndex = this.currentAccountIndex = i
11097+
acc.isLoggedIn = testInfo.isLoggedIn == null || testInfo.isLoggedIn
11098+
break
11099+
}
11100+
}
11101+
}
1107811102
}
1107911103

11080-
const accountIndex3 = accountIndex2
11081-
1108211104
const caseScript = {
1108311105
pre: (item['Script:pre'] || {}),
1108411106
post: (item['Script:post'] || {})
@@ -11095,6 +11117,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1109511117

1109611118
var random = item.Random || {}
1109711119
this.parseRandom(req, random.config, random.id, true, false, false, function(randomName, constConfig, constJson) {
11120+
App.currentAccountIndex = accountIndex
1109811121
App.request(false, method, type, isEnvCompare ? otherEnvUrl : curEnvUrl, constJson, header, function (url, res, err) {
1109911122
try {
1110011123
App.onResponse(url, res, err)
@@ -11120,7 +11143,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1112011143
tr[standardKey] = isMLEnabled ? JSON.stringify(JSONResponse.updateFullStandard({}, rsp, isMLEnabled)) : rspStr // res.data
1112111144
item.TestRecord = tr
1112211145

11123-
App.currentAccountIndex = accountIndex3
11146+
App.currentAccountIndex = accountIndex
1112411147
App.request(false, method, type, curEnvUrl, constJson, header, function (url, res, err) {
1112511148
try {
1112611149
App.onResponse(url, res, err)
@@ -11345,7 +11368,8 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1134511368
App.deepDoneCount = 0;
1134611369
this.startRandomTest4Doc(list, this.toTestDocIndexes, 0, deepAllCount, accountIndex, isCross)
1134711370
} else if (isCross && doneCount == allCount && accountIndex <= this.accounts.length) {
11348-
this.test(false, accountIndex + 1, isCross)
11371+
this.testAccountIndex = (this.testAccountIndex || 0) + 1
11372+
this.test(false, this.testAccountIndex, isCross)
1134911373
}
1135011374
}
1135111375
},
@@ -11836,19 +11860,26 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1183611860

1183711861
this.isFullAssert = true
1183811862

11839-
var chain = item.Chain
11840-
var testAccountId = chain == null ? null : chain.testAccountId
11841-
var testInfo = (chain == null ? null : chain.testInfo) || {}
11842-
var accounts = (StringUtil.isEmpty(testAccountId == null ? null : String(testAccountId), true) ? null : this.accounts) || []
11843-
for (var i = 0; i < accounts.length; i ++) {
11844-
var acc = accounts[i]
11845-
if (acc != null && (acc.id == chain.testAccountId || ( acc.baseUrl = testInfo.baseUrl && (
11846-
(StringUtil.isNotEmpty(item.phone) && acc.phone == testInfo.phone)
11847-
|| (StringUtil.isNotEmpty(item.email) && acc.email == testInfo.email) )
11848-
))) {
11849-
this.currentAccountIndex = i
11850-
acc.isLoggedIn = true
11851-
break
11863+
const chain = item.Chain
11864+
if (chain != null) {
11865+
const testAccountId = chain.testAccountId
11866+
if (StringUtil.isEmpty(testAccountId, true)) {
11867+
this.currentAccountIndex = -1
11868+
} else {
11869+
const testInfo = chain.testInfo || {}
11870+
const accounts = this.accounts || []
11871+
for (var i = 0; i < accounts.length; i ++) {
11872+
var acc = accounts[i]
11873+
if (acc != null && (acc.id == testAccountId || ( acc.baseUrl = testInfo.baseUrl && (
11874+
(StringUtil.isNotEmpty(item.phone) && acc.phone == testInfo.phone)
11875+
|| (StringUtil.isNotEmpty(item.email) && acc.email == testInfo.email) )
11876+
))) {
11877+
chain.testAccountId = acc.id
11878+
this.currentAccountIndex = i
11879+
acc.isLoggedIn = testInfo.isLoggedIn == null || testInfo.isLoggedIn
11880+
break
11881+
}
11882+
}
1185211883
}
1185311884
}
1185411885

0 commit comments

Comments
 (0)