|
507 | 507 | ], |
508 | 508 | currentAccountIndex: 0, |
509 | 509 | tests: [], |
| 510 | + crossProcess: '交叉账号:已关闭', |
510 | 511 | testProcess: '机器学习:已关闭', |
511 | 512 | randomTestTitle: null, |
512 | 513 | testRandomProcess: '', |
|
529 | 530 | loginType: 'login', |
530 | 531 | isExportRemote: false, |
531 | 532 | isRegister: false, |
| 533 | + isCrossEnabled: false, |
532 | 534 | isMLEnabled: false, |
533 | 535 | isDelegateEnabled: false, |
534 | 536 | isLocalShow: false, |
|
1505 | 1507 |
|
1506 | 1508 |
|
1507 | 1509 |
|
1508 | | - onClickAccount: function (index, item) { |
| 1510 | + onClickAccount: function (index, item, callback) { |
| 1511 | + if (index < 0 || item == null) { |
| 1512 | + callback(false) |
| 1513 | + return |
| 1514 | + } |
| 1515 | + |
1509 | 1516 | if (this.currentAccountIndex == index) { |
1510 | 1517 | this.setRememberLogin(item.remember) |
1511 | 1518 | vAccount.value = item.phone |
|
1519 | 1526 | item.isLoggedIn = false |
1520 | 1527 | App.saveCache(App.getBaseUrl(), 'currentAccountIndex', App.currentAccountIndex) |
1521 | 1528 | App.saveCache(App.getBaseUrl(), 'accounts', App.accounts) |
| 1529 | + |
| 1530 | + if (callback != null) { |
| 1531 | + callback(false) |
| 1532 | + } |
1522 | 1533 | }); |
1523 | 1534 | } |
1524 | 1535 | else { |
|
1536 | 1547 |
|
1537 | 1548 | App.saveCache(App.getBaseUrl(), 'currentAccountIndex', App.currentAccountIndex) |
1538 | 1549 | App.saveCache(App.getBaseUrl(), 'accounts', App.accounts) |
| 1550 | + |
| 1551 | + if (callback != null) { |
| 1552 | + callback(true) |
| 1553 | + } |
1539 | 1554 | } |
1540 | 1555 | }); |
1541 | 1556 | } |
|
1555 | 1570 |
|
1556 | 1571 | //目前还没做到同一标签页下测试账号切换后,session也跟着切换,所以干脆每次切换tab就重新登录 |
1557 | 1572 | item.isLoggedIn = false |
1558 | | - this.onClickAccount(index, item) |
| 1573 | + this.onClickAccount(index, item, callback) |
1559 | 1574 | }, |
1560 | 1575 |
|
1561 | 1576 | removeAccountTab: function () { |
|
2876 | 2891 | return doc |
2877 | 2892 | }, |
2878 | 2893 |
|
| 2894 | + enableCross: function (enable) { |
| 2895 | + this.isCrossEnabled = enable |
| 2896 | + this.crossProcess = enable ? '交叉账号:已开启' : '交叉账号:已关闭' |
| 2897 | + this.saveCache(App.server, 'isCrossEnabled', enable) |
| 2898 | + }, |
| 2899 | + |
2879 | 2900 | enableML: function (enable) { |
2880 | 2901 | this.isMLEnabled = enable |
2881 | 2902 | this.testProcess = enable ? '机器学习:已开启' : '机器学习:已关闭' |
|
3159 | 3180 | 3-对象缺少字段/整数变小数,黄色; |
3160 | 3181 | 4-code/值类型 改变,红色; |
3161 | 3182 | */ |
3162 | | - test: function (isRandom) { |
| 3183 | + test: function (isRandom, accountIndex) { |
| 3184 | + var accounts = this.accounts || [] |
| 3185 | + alert('test accountIndex = ' + accountIndex) |
| 3186 | + var isCrossEnabled = this.isCrossEnabled |
| 3187 | + if (accountIndex == null) { |
| 3188 | + accountIndex = -1 //isCrossEnabled ? -1 : 0 |
| 3189 | + } |
| 3190 | + if (isCrossEnabled) { |
| 3191 | + var isCrossDone = accountIndex >= accounts.length |
| 3192 | + this.crossProcess = isCrossDone ? (isCrossEnabled ? '交叉账号:已开启' : '交叉账号:已关闭') : ('交叉账号: ' + accountIndex + '/' + accounts.length) |
| 3193 | + if (isCrossDone) { |
| 3194 | + alert('test isCrossDone') |
| 3195 | + return |
| 3196 | + } |
| 3197 | + } |
| 3198 | + |
3163 | 3199 | var baseUrl = StringUtil.trim(App.getBaseUrl()) |
3164 | 3200 | if (baseUrl == '') { |
3165 | 3201 | alert('请先输入有效的URL!') |
|
3183 | 3219 | alert('请先获取测试用例文档\n点击[查看共享]图标按钮') |
3184 | 3220 | return |
3185 | 3221 | } |
3186 | | - App.testProcess = '正在测试: ' + 0 + '/' + allCount |
3187 | 3222 |
|
3188 | | - for (var i = 0; i < allCount; i ++) { |
3189 | | - const item = list[i] |
3190 | | - const document = item == null ? null : item.Document |
3191 | | - if (document == null || document.name == null) { |
3192 | | - doneCount ++ |
3193 | | - continue |
3194 | | - } |
3195 | | - if (document.url == '/login' || document.url == '/logout') { //login会导致登录用户改变为默认的但UI上还显示原来的,单独测试OWNER权限时能通过很困惑 |
3196 | | - App.log('test document.url == "/login" || document.url == "/logout" >> continue') |
3197 | | - doneCount ++ |
3198 | | - continue |
3199 | | - } |
3200 | | - App.log('test document = ' + JSON.stringify(document, null, ' ')) |
3201 | 3223 |
|
3202 | | - const index = i |
| 3224 | + if (accountIndex < 0 && isCrossEnabled) { //退出登录已登录的账号 |
| 3225 | + accounts[this.currentAccountIndex].isLoggedIn = true |
| 3226 | + } |
3203 | 3227 |
|
3204 | | - var header = null |
3205 | | - try { |
3206 | | - header = App.getHeader(document.header) |
3207 | | - } catch (e) { |
3208 | | - App.log('test for ' + i + ' >> try { header = App.getHeader(document.header) } catch (e) { \n' + e.message) |
3209 | | - } |
| 3228 | + var index = accountIndex < 0 && isCrossEnabled ? this.currentAccountIndex : accountIndex |
| 3229 | + this.onClickAccount(index, accounts[index], function(isLoggedIn) { |
| 3230 | + App.showTestCase(true, false) |
| 3231 | + |
| 3232 | + App.testProcess = '正在测试: ' + 0 + '/' + allCount |
| 3233 | + |
| 3234 | + for (var i = 0; i < allCount; i++) { |
| 3235 | + const item = list[i] |
| 3236 | + const document = item == null ? null : item.Document |
| 3237 | + if (document == null || document.name == null) { |
| 3238 | + doneCount++ |
| 3239 | + continue |
| 3240 | + } |
| 3241 | + if (document.url == '/login' || document.url == '/logout') { //login会导致登录用户改变为默认的但UI上还显示原来的,单独测试OWNER权限时能通过很困惑 |
| 3242 | + App.log('test document.url == "/login" || document.url == "/logout" >> continue') |
| 3243 | + doneCount++ |
| 3244 | + continue |
| 3245 | + } |
| 3246 | + App.log('test document = ' + JSON.stringify(document, null, ' ')) |
3210 | 3247 |
|
3211 | | - App.request(false, document.type, baseUrl + document.url, App.getRequest(document.request), header, function (url, res, err) { |
| 3248 | + const index = i |
3212 | 3249 |
|
| 3250 | + var header = null |
3213 | 3251 | try { |
3214 | | - App.onResponse(url, res, err) |
3215 | | - App.log('test App.request >> res.data = ' + JSON.stringify(res.data, null, ' ')) |
| 3252 | + header = App.getHeader(document.header) |
3216 | 3253 | } catch (e) { |
3217 | | - App.log('test App.request >> } catch (e) {\n' + e.message) |
| 3254 | + App.log('test for ' + i + ' >> try { header = App.getHeader(document.header) } catch (e) { \n' + e.message) |
3218 | 3255 | } |
3219 | 3256 |
|
3220 | | - App.compareResponse(allCount, index, item, res.data, isRandom) |
3221 | | - }) |
3222 | | - } |
| 3257 | + App.request(false, document.type, baseUrl + document.url, App.getRequest(document.request), header, function (url, res, err) { |
| 3258 | + |
| 3259 | + try { |
| 3260 | + App.onResponse(url, res, err) |
| 3261 | + App.log('test App.request >> res.data = ' + JSON.stringify(res.data, null, ' ')) |
| 3262 | + } catch (e) { |
| 3263 | + App.log('test App.request >> } catch (e) {\n' + e.message) |
| 3264 | + } |
| 3265 | + |
| 3266 | + App.compareResponse(allCount, index, item, res.data, isRandom, accountIndex) |
| 3267 | + }) |
| 3268 | + } |
| 3269 | + |
| 3270 | + }) |
| 3271 | + |
3223 | 3272 | }, |
3224 | 3273 |
|
3225 | | - compareResponse: function (allCount, index, item, response, isRandom) { |
| 3274 | + compareResponse: function (allCount, index, item, response, isRandom, accountIndex) { |
3226 | 3275 | var it = item || {} //请求异步 |
3227 | 3276 | var d = (isRandom ? App.currentRemoteItem.Document : it.Document) || {} //请求异步 |
3228 | 3277 | var r = isRandom ? it.Random : null//请求异步 |
|
3233 | 3282 | var standardKey = App.isMLEnabled != true ? 'response' : 'standard' |
3234 | 3283 | var standard = StringUtil.isEmpty(tr[standardKey], true) ? null : JSON.parse(tr[standardKey]); |
3235 | 3284 | tr.compare = JSONResponse.compareResponse(standard, releaseResponse, '', App.isMLEnabled) || {} |
3236 | | - App.onTestResponse(allCount, index, it, d, r, tr, response, tr.compare || {}, isRandom); |
| 3285 | + App.onTestResponse(allCount, index, it, d, r, tr, response, tr.compare || {}, isRandom, accountIndex); |
3237 | 3286 | }, |
3238 | 3287 |
|
3239 | | - onTestResponse: function(allCount, index, it, d, r, tr, response, cmp, isRandom) { |
| 3288 | + onTestResponse: function(allCount, index, it, d, r, tr, response, cmp, isRandom, accountIndex) { |
3240 | 3289 |
|
3241 | 3290 | doneCount ++ |
3242 | 3291 | App.testProcess = doneCount >= allCount ? (App.isMLEnabled ? '机器学习:已开启' : '机器学习:已关闭') : '正在测试: ' + doneCount + '/' + allCount |
|
3295 | 3344 | console.log('tests = ' + JSON.stringify(tests, null, ' ')) |
3296 | 3345 | // App.showTestCase(true) |
3297 | 3346 |
|
| 3347 | + if (doneCount >= allCount && App.isCrossEnabled) { |
| 3348 | + alert('onTestResponse accountIndex = ' + accountIndex) |
| 3349 | + App.test(false, accountIndex + 1) |
| 3350 | + } |
3298 | 3351 | }, |
3299 | 3352 |
|
3300 | 3353 | /**移除调试字段 |
|
3600 | 3653 |
|
3601 | 3654 | try { //可能URL_BASE是const类型,不允许改,这里是初始化,不能出错 |
3602 | 3655 | this.User = this.getCache(this.server, 'User') || {} |
| 3656 | + this.isCrossEnabled = this.getCache(this.server, 'isCrossEnabled') || this.isCrossEnabled |
3603 | 3657 | this.isMLEnabled = this.getCache(this.server, 'isMLEnabled') || this.isMLEnabled |
| 3658 | + this.crossProcess = this.isCrossEnabled ? '交叉账号:已开启' : '交叉账号:已关闭' |
3604 | 3659 | this.testProcess = this.isMLEnabled ? '机器学习:已开启' : '机器学习:已关闭' |
3605 | 3660 | } catch (e) { |
3606 | 3661 | console.log('created try { ' + |
|
0 commit comments