@@ -11403,12 +11403,12 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
11403 | 11403 | const start = value.indexOf('('); |
11404 | 11404 | const end = value.lastIndexOf(')'); |
11405 | 11405 | var _args = []; |
11406 | | - try { // JSON 中不能出现 undefined |
11407 | | - _args = parseJSON('[' + value.substring(start + 1, end) + ']'); |
11408 | | - } catch (e) { |
11409 | | - console.log(e); |
11410 | | - _args = StringUtil.split(value.substring(start + 1, end), ', '); |
11411 | | - } |
| 11406 | + // try { // JSON 中不能出现 undefined |
| 11407 | + _args = eval('[' + value.substring(start + 1, end) + ']'); |
| 11408 | + // } catch (e) { |
| 11409 | + // console.log(e); |
| 11410 | + // _args = StringUtil.split(value.substring(start + 1, end), ', '); |
| 11411 | + // } |
11412 | 11412 | const args = _args || []; |
11413 | 11413 |
|
11414 | 11414 | var request4Db = function(tableName, which, p_k, pathKeys, key, lastKeyInPath, isRandom, isDesc, step, body) { |
@@ -11629,7 +11629,8 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
11629 | 11629 | args[5] = 'data' |
11630 | 11630 | if (err != null) { |
11631 | 11631 | var arg6 = args[6] |
11632 | | - args[6] = StringUtil.isEmpty(arg6) ? err : StringUtil.get(arg6) + '; \n' + StringUtil.get(err); |
| 11632 | + var err2 = new Error(StringUtil.isEmpty(arg6) ? StringUtil.get(err) : StringUtil.get(arg6) + '; \n' + StringUtil.get(err)) |
| 11633 | + args[6] = 'err2'; |
11633 | 11634 | } |
11634 | 11635 |
|
11635 | 11636 | toEval = 'put4Path((ctx || {}).ctx || {}, ' + JSON.stringify(path) + ', ' + args.slice(5).join() + ')'; |
@@ -11662,10 +11663,11 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
11662 | 11663 | args[5] = 'data' |
11663 | 11664 | if (err != null) { |
11664 | 11665 | var arg6 = args[6] |
11665 | | - args[6] = StringUtil.isEmpty(arg6) ? err : StringUtil.get(arg6) + '; \n' + StringUtil.get(err); |
| 11666 | + var err2 = new Error(StringUtil.isEmpty(arg6) ? StringUtil.get(err) : StringUtil.get(arg6) + '; \n' + StringUtil.get(err)) |
| 11667 | + args[6] = 'err2'; |
11666 | 11668 | } |
11667 | 11669 |
|
11668 | | - toEval = 'put4Path((ctx || {}).ctx || {}, ' + JSON.stringify(path) + ', ' + args.slice(5).join() + ')'; |
| 11670 | + toEval = 'put4Path((ctx || {}).ctx || {}, ' + JSON.stringify(path) + ', ' + args.slice(5).join(', ') + ')'; |
11669 | 11671 | try { |
11670 | 11672 | var ret = eval(StringUtil.trim(preScript) + '\n;\n(' + toEval + ')') |
11671 | 11673 | invoke(ret, which, p_k, pathKeys, key, lastKeyInPath); |
@@ -11851,7 +11853,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
11851 | 11853 | var ret = eval(StringUtil.trim(preScript) + '\n;\n(' + toEval + ')') |
11852 | 11854 | invoke(ret, which, p_k, pathKeys, key, lastKeyInPath); |
11853 | 11855 | } catch (e) { |
11854 | | - throw new Error(e.message + '\n; 第 ' + i + ' 行:' + line) |
| 11856 | + throw new Error(e.message + ';\n第 ' + i + ' 行:' + line) |
11855 | 11857 | } |
11856 | 11858 |
|
11857 | 11859 | // alert('> current = ' + JSON.stringify(current, null, ' ')) |
@@ -12220,32 +12222,54 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12220 | 12222 | } |
12221 | 12223 | }, |
12222 | 12224 |
|
12223 | | - startTestSingle: function (list, allCount, index, item, isRandom, accountIndex, isCross, callback, singleCallback, ctx) { |
| 12225 | + startTestSingle: function (list, allCount, index, item, isRandom, accountIndex, isCross, callback, singleCallback, ctx_) { |
12224 | 12226 | this.isFullAssert = false |
| 12227 | + |
| 12228 | + const document = item == null ? null : item.Document |
| 12229 | + if (document == null || document.name == null) { |
| 12230 | + if (isRandom) { |
| 12231 | + App.randomDoneCount ++ |
| 12232 | + } else { |
| 12233 | + App.doneCount ++ |
| 12234 | + } |
| 12235 | + |
| 12236 | + return |
| 12237 | + } |
| 12238 | + |
12225 | 12239 | const caseScript = { |
12226 | 12240 | pre: (item['Script:pre'] || {}), |
12227 | 12241 | post: (item['Script:post'] || {}) |
12228 | 12242 | } |
12229 | 12243 |
|
12230 | | - try { |
12231 | | - const isMLEnabled = this.isMLEnabled |
12232 | | - const standardKey = isMLEnabled != true ? 'response' : 'standard' |
| 12244 | + const chain = item.Chain |
12233 | 12245 |
|
12234 | | - const otherEnv = this.otherEnv; |
12235 | | - const otherBaseUrl = this.isEnvCompareEnabled && StringUtil.isNotEmpty(otherEnv, true) ? this.getBaseUrl(otherEnv) : null |
12236 | | - const isEnvCompare = StringUtil.isNotEmpty(otherBaseUrl, true) // 对比自己也行,看看前后两次是否幂等 && otherBaseUrl != baseUrl |
| 12246 | + const isMLEnabled = this.isMLEnabled |
| 12247 | + const standardKey = isMLEnabled != true ? 'response' : 'standard' |
12237 | 12248 |
|
12238 | | - const document = item == null ? null : item.Document |
12239 | | - if (document == null || document.name == null) { |
12240 | | - if (isRandom) { |
12241 | | - App.randomDoneCount ++ |
12242 | | - } else { |
12243 | | - App.doneCount ++ |
12244 | | - } |
| 12249 | + const otherEnv = this.otherEnv; |
| 12250 | + const otherBaseUrl = this.isEnvCompareEnabled && StringUtil.isNotEmpty(otherEnv, true) ? this.getBaseUrl(otherEnv) : null |
| 12251 | + const isEnvCompare = StringUtil.isNotEmpty(otherBaseUrl, true) // 对比自己也行,看看前后两次是否幂等 && otherBaseUrl != baseUrl |
12245 | 12252 |
|
12246 | | - return |
12247 | | - } |
| 12253 | + const method = document.method |
| 12254 | + const type = document.type |
| 12255 | + const req = this.getRequest(document.request, null, true) |
| 12256 | + const otherEnvUrl = isEnvCompare ? (otherBaseUrl + document.url) : null |
12248 | 12257 |
|
| 12258 | + const testInfo = (chain || {}).testInfo || {} |
| 12259 | + const curEnvUrl = (testInfo.baseUrl || baseUrl) + document.url |
| 12260 | + const cur = item |
| 12261 | + const pre = list[index - 1] || {} // item.pre = item.pre || list[index - 1] || {} |
| 12262 | +// const ctx = item.ctx = item.ctx || {} |
| 12263 | + const ctx = { |
| 12264 | + list: list, |
| 12265 | + allCount: allCount, |
| 12266 | + index: index, |
| 12267 | + cur: cur, |
| 12268 | + pre: pre, |
| 12269 | + ctx: ctx_ // ctx |
| 12270 | + } |
| 12271 | + |
| 12272 | + try { |
12249 | 12273 | var url = document.url || '' |
12250 | 12274 | if (this.isChainShow != true && (url.indexOf('login') >= 0 || url.indexOf('logout') >= 0)) { //login会导致登录用户改变为默认的但UI上还显示原来的,单独测试OWNER权限时能通过很困惑 |
12251 | 12275 | this.log('startTestSingle this.isChainShow != true && (url.indexOf("login") >= 0 || url.indexOf("logout") >= 0) >> continue') |
@@ -12270,8 +12294,6 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12270 | 12294 | } |
12271 | 12295 | const header = hdr |
12272 | 12296 |
|
12273 | | - const chain = item.Chain |
12274 | | - const testInfo = (chain || {}).testInfo || {} |
12275 | 12297 | if (chain != null) { |
12276 | 12298 | const testAccountId = chain.testAccountId |
12277 | 12299 | const accounts = this.accounts || [] |
@@ -12295,23 +12317,6 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12295 | 12317 | } |
12296 | 12318 | } |
12297 | 12319 |
|
12298 | | - const method = document.method |
12299 | | - const type = document.type |
12300 | | - const req = this.getRequest(document.request, null, true) |
12301 | | - const otherEnvUrl = isEnvCompare ? (otherBaseUrl + document.url) : null |
12302 | | - const curEnvUrl = (testInfo.baseUrl || baseUrl) + document.url |
12303 | | - const cur = item |
12304 | | - const pre = list[index - 1] || {} // item.pre = item.pre || list[index - 1] || {} |
12305 | | -// const ctx = item.ctx = item.ctx || {} |
12306 | | - const ctx = { |
12307 | | - list: list, |
12308 | | - allCount: allCount, |
12309 | | - index: index, |
12310 | | - cur: cur, |
12311 | | - pre: pre, |
12312 | | - ctx: {} // ctx |
12313 | | - } |
12314 | | - |
12315 | 12320 | var random = item.Random || {} |
12316 | 12321 | this.parseRandom(req, header, random.config, random.id, true, false, false, function(randomName, constConfig, constJson, constHeader) { |
12317 | 12322 | App.currentAccountIndex = accountIndex |
@@ -12421,7 +12426,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12421 | 12426 | tr.compare.duration = it.durationHint |
12422 | 12427 |
|
12423 | 12428 | var resRandom = it['Random:res'] || {} |
12424 | | - var resCfg = resRandom.config |
| 12429 | + var resCfg = justRecoverTest ? null : resRandom.config |
12425 | 12430 | if (StringUtil.isNotEmpty(resCfg)) { |
12426 | 12431 | try { |
12427 | 12432 | caseScript = caseScript || {} |
@@ -12484,7 +12489,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12484 | 12489 | case JSONResponse.COMPARE_TYPE_CHANGE: |
12485 | 12490 | case JSONResponse.COMPARE_CODE_CHANGE: |
12486 | 12491 | case JSONResponse.COMPARE_THROW_CHANGE: |
12487 | | - var code = response == null ? null : response[JSONResponse.KEY_CODE] || JSONResponse.CODE_SUCCESS |
| 12492 | + var code = response == null ? null : response[JSONResponse.KEY_CODE] |
12488 | 12493 | it.compareColor = 'red' |
12489 | 12494 | it.hintMessage = (code != null && code != JSONResponse.CODE_SUCCESS |
12490 | 12495 | ? code + ' ' : (status != null && status != 200 ? status + ' ' : '')) + '状态码/异常/值类型 改变等' |
@@ -12523,13 +12528,14 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12523 | 12528 | } |
12524 | 12529 |
|
12525 | 12530 | var doneCount = isRandom ? App.randomDoneCount : App.doneCount |
| 12531 | + var isDone = doneCount >= allCount |
12526 | 12532 | if (isRandom) { |
12527 | | - this.testRandomProcess = doneCount >= allCount ? '' : ('正在测试: ' + doneCount + '/' + allCount) |
| 12533 | + this.testRandomProcess =isDone ? '' : ('正在测试: ' + doneCount + '/' + allCount) |
12528 | 12534 | } else { |
12529 | | - this.testProcess = doneCount >= allCount ? (this.isMLEnabled ? '机器学习:已开启' : '机器学习:已关闭') : '正在测试: ' + doneCount + '/' + allCount |
| 12535 | + this.testProcess = isDone ? (this.isMLEnabled ? '机器学习:已开启' : '机器学习:已关闭') : '正在测试: ' + doneCount + '/' + allCount |
12530 | 12536 | } |
12531 | 12537 |
|
12532 | | - if (doneCount < allCount && callback != this.autoTestCallback && typeof this.autoTestCallback == 'function') { |
| 12538 | + if (isDone != true && callback != this.autoTestCallback && typeof this.autoTestCallback == 'function') { |
12533 | 12539 | this.autoTestCallback('正在测试') |
12534 | 12540 | } |
12535 | 12541 |
|
@@ -12560,6 +12566,14 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
12560 | 12566 | if (DEBUG) { |
12561 | 12567 | this.log('tests = ' + JSON.stringify(tests, null, ' ')) |
12562 | 12568 | } |
| 12569 | + |
| 12570 | + if (isDone && isRandom) { |
| 12571 | + this.currentRandomIndex = -1 |
| 12572 | + this.isRandomShow = true |
| 12573 | + // this.isRandomListShow = true |
| 12574 | + // this.handleTest(false, 0, list[0], null, isRandom) // , false, isCross) |
| 12575 | + } |
| 12576 | + |
12563 | 12577 | // this.showTestCase(true) |
12564 | 12578 |
|
12565 | 12579 | if (singleCallback != null && singleCallback(res, allCount, list, index, response, cmp, isRandom, accountIndex, justRecoverTest, isCross)) { |
@@ -13116,6 +13130,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13116 | 13130 | } |
13117 | 13131 |
|
13118 | 13132 | const rawRspStr = currentResponse == null ? null : JSON.stringify(currentResponse) |
| 13133 | + var rsp = parseJSON(rawRspStr) |
13119 | 13134 |
|
13120 | 13135 | const list = isRandom ? (random.toId == null || random.toId <= 0 ? this.randoms : this.randomSubs) : this.testCases |
13121 | 13136 |
|
@@ -13149,7 +13164,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13149 | 13164 | tag: 'TestRecord' |
13150 | 13165 | } |
13151 | 13166 |
|
13152 | | - this.request(true, HTTP_METHOD_POST, REQUEST_TYPE_JSON, url, req, {}, function (url, res, err) { |
| 13167 | + this.adminRequest(url, req, {}, function (url, res, err) { |
13153 | 13168 | App.onResponse(url, res, err) |
13154 | 13169 |
|
13155 | 13170 | var data = res.data || {} |
@@ -13176,7 +13191,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13176 | 13191 | item.TestRecord = null |
13177 | 13192 | } |
13178 | 13193 |
|
13179 | | - App.updateTestRecord(0, list, index, item, rawRspStr == null ? null : parseJSON(rawRspStr), isRandom, true, App.currentAccountIndex, isCross) |
| 13194 | + App.updateTestRecord(0, list, index, item, rsp, isRandom, true, App.currentAccountIndex, isCross) |
13180 | 13195 | }) |
13181 | 13196 | } |
13182 | 13197 | else { //上传新的校验标准 |
@@ -13224,9 +13239,9 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13224 | 13239 | else { |
13225 | 13240 | standard = (StringUtil.isEmpty(testRecord.standard, true) ? null : parseJSON(testRecord.standard)) || {} |
13226 | 13241 | if (pathKeys.length <= 0) { |
13227 | | - stddObj = JSONResponse.updateFullStandard(standard, rawRspStr == null ? null : parseJSON(rawRspStr), isML) |
| 13242 | + stddObj = JSONResponse.updateFullStandard(standard, rsp, isML) |
13228 | 13243 | } else if (isML) { |
13229 | | - stddObj = JSONResponse.updateStandardByPath(standard, pathNames, lastKey, rawRspStr == null ? null : parseJSON(rawRspStr)) |
| 13244 | + stddObj = JSONResponse.updateStandardByPath(standard, pathNames, lastKey, rsp) |
13230 | 13245 | } |
13231 | 13246 | } |
13232 | 13247 |
|
@@ -13287,7 +13302,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13287 | 13302 | // } |
13288 | 13303 | // } |
13289 | 13304 |
|
13290 | | - this.request(true, HTTP_METHOD_POST, REQUEST_TYPE_JSON, url, req, {}, function (url, res, err) { |
| 13305 | + this.adminRequest(url, req, {}, function (url, res, err) { |
13291 | 13306 | App.onResponse(url, res, err) |
13292 | 13307 |
|
13293 | 13308 | var data = res.data || {} |
@@ -13347,7 +13362,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13347 | 13362 | // } |
13348 | 13363 | // } |
13349 | 13364 |
|
13350 | | - App.updateTestRecord(0, list, index, item, rawRspStr == null ? null : parseJSON(rawRspStr), isRandom, true, App.currentAccountIndex, isCross) |
| 13365 | + App.updateTestRecord(0, list, index, item, rsp, isRandom, true, App.currentAccountIndex, isCross) |
13351 | 13366 | } |
13352 | 13367 |
|
13353 | 13368 | }) |
@@ -13360,10 +13375,10 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea |
13360 | 13375 | item = item || {} |
13361 | 13376 | var doc = (isRandom ? item.Random : item.Document) || {} |
13362 | 13377 |
|
13363 | | - this.request(true, HTTP_METHOD_POST, REQUEST_TYPE_JSON, this.server + '/get', { |
| 13378 | + this.adminRequest('/get', { |
13364 | 13379 | TestRecord: { |
13365 | 13380 | documentId: isRandom ? doc.documentId : doc.id, |
13366 | | - randomId: isRandom ? doc.id : null, |
| 13381 | + randomId: isRandom ? doc.id : 0, |
13367 | 13382 | testAccountId: this.getCurrentAccountId(), |
13368 | 13383 | 'invalid': 0, |
13369 | 13384 | 'host': this.getBaseUrl(), |
|