GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 场景串联:完善按账号及 Host 分组记录接口上下文;解决场景用例有时 JSON 结果和断言对不上、分组|子项中的竖线未显示;参数配置:支… · TommyLemon/APIAuto@73c5f23

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • js
    • main.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎js/main.js‎

Copy file name to clipboardExpand all lines: js/main.js
+89-38Lines changed: 89 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,15 @@
354354
*/
355355
Vue.prototype.setResponseHint = function (val, key, $event, isAssert, color, isDynamic) {
356356
console.log('setResponseHint')
357+
var responseKey = this.$refs.responseKey
358+
if (responseKey == null) {
359+
return
360+
}
361+
357362
if (! isDynamic) {
358363
CodeUtil.tableList = (docObj || {})['[]'] || CodeUtil.tableList;
359364
}
360-
this.$refs.responseKey.setAttribute('data-hint', isSingle ? '' : this.getResponseHint(val, key, $event, isAssert, color, isDynamic));
365+
responseKey.setAttribute('data-hint', isSingle ? '' : this.getResponseHint(val, key, $event, isAssert, color, isDynamic));
361366
}
362367
/**获取 Response JSON 的注释
363368
* 方案一:
@@ -5772,10 +5777,10 @@ https://github.com/Tencent/APIJSON/issues
57725777
this.isLocalShow = type == 2
57735778

57745779
this.testCases = this.remotes = []
5775-
if (type == 1 && this.chainGroups.length <= 0) {
5780+
if (type == 1 && StringUtil.isEmpty(this.chainGroups)) {
57765781
this.selectChainGroup(-1, null)
57775782
}
5778-
else if (type == 0 && this.caseGroups.length <= 0) {
5783+
else if (type == 0 && StringUtil.isEmpty(this.caseGroups)) {
57795784
this.selectCaseGroup(-1, null)
57805785
}
57815786
else {
@@ -5791,29 +5796,18 @@ https://github.com/Tencent/APIJSON/issues
57915796
},
57925797

57935798
getCaseCountStr: function() {
5794-
var isChainShow = this.isChainShow
5795-
var isCaseGroupShow = this.isCaseGroupShow()
5796-
var isLocalShow = this.isLocalShow
5797-
var caseShowType = this.caseShowType
5798-
var caseGroups = (isChainShow ? this.chainGroups : this.caseGroups) || []
5799-
var testCases = this.testCases || []
5800-
5801-
if (isLocalShow) {
5802-
return '(' + testCases.length + ')'
5799+
if (this.isLocalShow) {
5800+
return '(' + StringUtil.length(this.testCases) + ')'
58035801
}
58045802

5805-
return '(' + (isCaseGroupShow ? caseGroups.length : '')
5806-
+ (caseShowType == 0 && isCaseGroupShow ? '|' : '')
5807-
+ (caseShowType == 2 && (isCaseGroupShow) ? '' : testCases.length) + ')';
5803+
var isChainShow = this.isChainShow
5804+
var isCaseGroupShow = this.isCaseGroupShow()
5805+
var isCaseItemShow = this.isCaseItemShow()
5806+
var caseGroups = (isChainShow ? this.chainGroups : this.caseGroups)
58085807

5809-
// 以下代码不知道为啥结果显示不对
5810-
// var isCaseGroupShow = this.isCaseGroupShow()
5811-
// var isCaseItemShow = this.isCaseItemShow()
5812-
// var caseGroups = (this.isChainShow ? this.chainGroups : this.caseGroups) || []
5813-
//
5814-
// return '(' + (isCaseGroupShow ? caseGroups.length : '')
5815-
// + (isCaseGroupShow && isCaseItemShow ? '|' : '')
5816-
// + (isCaseItemShow ? '' : testCases.length) + ')';
5808+
return '(' + (isCaseGroupShow ? StringUtil.length(caseGroups) : '')
5809+
+ (isCaseGroupShow && isCaseItemShow ? '|' : '')
5810+
+ (isCaseItemShow ? StringUtil.length(this.testCases) : '') + ')';
58175811
},
58185812

58195813
//显示远程的测试用例文档
@@ -7702,6 +7696,20 @@ https://github.com/Tencent/APIJSON/issues
77027696
return Promise.reject(error);
77037697
});
77047698

7699+
// Object.defineProperty(req, 'constructor', {
7700+
// value: 'getInstance',
7701+
// enumerable: true,
7702+
// configurable: false,
7703+
// writable: true
7704+
// })
7705+
7706+
var isJSON = HTTP_JSON_TYPES.indexOf(type) >= 0;
7707+
if (isJSON && JSONResponse.isObject(req) && (req.constructor != null || req.package != null || req.class != null || req.method != null || req.prototype != null)) {
7708+
req = JSON.stringify(req)
7709+
header = header || {}
7710+
header['Content-Type'] = 'application/json'
7711+
}
7712+
77057713
// axios.defaults.withcredentials = true
77067714
axios({
77077715
method: method != null ? method : (HTTP_METHODS.indexOf(type) >= 0 ? type.toLowerCase() : (type == REQUEST_TYPE_PARAM ? 'get' : 'post')),
@@ -7715,7 +7723,7 @@ https://github.com/Tencent/APIJSON/issues
77157723
)
77167724
),
77177725
params: isParam ? req : null,
7718-
data: HTTP_JSON_TYPES.indexOf(type) >= 0 ? req : (HTTP_FORM_DATA_TYPES.indexOf(type) >= 0 ? toFormData(req) : null),
7726+
data: isJSON ? req : (HTTP_FORM_DATA_TYPES.indexOf(type) >= 0 ? toFormData(req) : null),
77197727
headers: header, //Accept-Encoding(HTTP Header 大小写不敏感,SpringBoot 接收后自动转小写)可能导致 Response 乱码
77207728
withCredentials: true, //Cookie 必须要 type == REQUEST_TYPE_JSON
77217729
// crossDomain: true
@@ -11250,8 +11258,28 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1125011258

1125111259
var toEval = value;
1125211260
if (start > 0 && end > start) {
11253-
1125411261
var funWithOrder = value.substring(0, start);
11262+
var prefixEnd = funWithOrder.indexOf('ORDER_')
11263+
if (prefixEnd < 0) {
11264+
prefixEnd = funWithOrder.indexOf('RANDOM_')
11265+
if (prefixEnd < 0) {
11266+
prefixEnd = funWithOrder.indexOf('PRE_')
11267+
if (prefixEnd < 0) {
11268+
prefixEnd = funWithOrder.indexOf('CTX_')
11269+
if (prefixEnd < 0) {
11270+
prefixEnd = funWithOrder.indexOf('CUR_')
11271+
}
11272+
}
11273+
}
11274+
}
11275+
11276+
var prefix = prefixEnd < 0 ? '' : StringUtil.get(funWithOrder.substring(0, prefixEnd))
11277+
if (/^[_A-Za-z]+$/g.test(prefix.substring(prefix.length - 1))) {
11278+
prefix = ''
11279+
} else {
11280+
funWithOrder = funWithOrder.substring(prefixEnd)
11281+
}
11282+
1125511283
var splitIndex = funWithOrder.indexOf('+');
1125611284

1125711285
var isDesc = false;
@@ -11301,26 +11329,26 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1130111329
var as3 = as[3] // account@host/index
1130211330
var accountHostIndexPath = StringUtil.isEmpty(as3) ? '/' : as3 + (as3.indexOf('/') < 0 ? '/' : '')
1130311331
var isChain = StringUtil.isNotEmpty(as2)
11304-
var chainArr = isChain ? '((ctx || {}).map || {})[' + as2 + ']' : null; // [GET /users] = { account@host: [] }
11332+
var chainArr = isChain ? '(((ctx || {}).ctx || {}).map || {})[' + as2 + ']' : null; // [GET /users] = { account@host: [] }
1130511333
if (isChain) {
1130611334
as2 = parseJSON(as2, as2, true)
1130711335
as.splice(2, 2)
1130811336
}
1130911337

1131011338
if (fun == PRE_REQ) {
11311-
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/req")' : 'get4Path(((ctx || {}).pre || {}).req'
11339+
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/req")' : '((ctx || {}).pre || {}).req'
1131211340
toEval = 'get4Path(' + source + ', ' + (value == 'PRE_REQ()' ? JSON.stringify(path) : '') + (isChain ? as.join(', ') + value.substring(end) : value.substring(start + 1));
1131311341
}
1131411342
else if (fun == PRE_ARG) {
11315-
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/arg")' : 'get4Path(((ctx || {}).pre || {}).arg'
11343+
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/arg")' : '((ctx || {}).pre || {}).arg'
1131611344
toEval = 'get4Path(' + source + ', ' + (value == 'PRE_ARG()' ? JSON.stringify(path) : '') + (isChain ? as.join(', ') + value.substring(end) : value.substring(start + 1));
1131711345
}
1131811346
else if (fun == PRE_RES) {
11319-
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/res")' : 'get4Path(((ctx || {}).pre || {}).res'
11347+
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/res")' : '((ctx || {}).pre || {}).res'
1132011348
toEval = 'get4Path(' + source + ', ' + (value == 'PRE_RES()' ? JSON.stringify(path) : '') + (isChain ? as.join(', ') + value.substring(end) : value.substring(start + 1));
1132111349
}
1132211350
else if (fun == PRE_DATA) {
11323-
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/data")' : 'get4Path(((ctx || {}).pre || {}).data'
11351+
var source = isChain ? 'get4Path(' + chainArr + ', "' + accountHostIndexPath + '/data")' : '((ctx || {}).pre || {}).data'
1132411352
toEval = 'get4Path(' + source + ', ' + (value == 'PRE_DATA()' ? JSON.stringify(path) : '') + (isChain ? as.join(', ') + value.substring(end) : value.substring(start + 1));
1132511353
}
1132611354
else if (fun == CTX_GET) {
@@ -11417,6 +11445,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1141711445

1141811446
}
1141911447

11448+
toEval = prefix + toEval
1142011449
}
1142111450

1142211451
var isInject = true;
@@ -11721,7 +11750,16 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1172111750

1172211751
res = res || {}
1172311752
var config = res.config || {}
11724-
cur.arg = App.getRequest(config.data || config.params, {})
11753+
var p = config.data || config.params
11754+
try {
11755+
cur.arg = App.getRequest(p, {})
11756+
} catch (e) {
11757+
if (StringUtil.isNotString(p) || p.indexOf('=') <= 0) {
11758+
throw e
11759+
}
11760+
cur.arg = getRequestFromURL('?' + p, true)
11761+
}
11762+
1172511763
cur.req = {
1172611764
method: method,
1172711765
url: config.url,
@@ -11732,19 +11770,32 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1173211770
cur.statusText = res.statusText
1173311771
cur.res = res
1173411772
cur.data = res.data
11735-
var map = ctx.map = ctx.map || {}
11736-
var m = map[method + ' ' + url] = map[method + ' ' + url] || {}
1173711773

11738-
const baseUrl = App.getBaseUrl(config.url)
11739-
const accountKey = StringUtil.trim(account) + '@' + StringUtil.trim(baseUrl)
11740-
var arr = m[accountKey] = m[accountKey] || []
11741-
arr.push({
11774+
var info = {
1174211775
type: type,
1174311776
req: req,
1174411777
arg: json,
1174511778
res: res,
1174611779
data: res.data
11747-
})
11780+
}
11781+
11782+
var map = ctx.map = ctx.map || {}
11783+
var m = map[method + ' ' + url] = map[method + ' ' + url] || {}
11784+
11785+
const baseUrl = StringUtil.trim(App.getBaseUrl(config.url))
11786+
const accountKey = account + '@' + baseUrl
11787+
var arr = m[accountKey] = m[accountKey] || []
11788+
arr.push(info)
11789+
11790+
if (StringUtil.isNotEmpty(account)) {
11791+
var arr2 = m[account] = m[account] || []
11792+
arr2.push(info)
11793+
}
11794+
11795+
if (StringUtil.isNotEmpty(baseUrl)) {
11796+
var arr2 = m[baseUrl] = m[baseUrl] || []
11797+
arr2.push(info)
11798+
}
1174811799

1174911800
App.startTestChain(list, allCount, index + 1, list[index + 1], item, ctx, isRandom, accountIndex, isCross, callback)
1175011801
}, ctx)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.