[go: nahoru, domu]

Skip to content

Commit

Permalink
场景串联用例:优化交互,解决子用例不显示,解决搜索不出来等问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Apr 27, 2024
1 parent f2590a8 commit 0aab24d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
<li v-for="(item, index) in chainGroups" :id="'chainGroup' + index" >
<div style="display: inline-table; width: 100%">
<input v-show="isCaseGroupEditable" style="min-width: 60px; width: 40%; margin-right: 6px" v-model="item.groupName" @keyup="doOnKeyUp(event, 'chainGroup', false, item)" />
<a href="javascript:void(0)" @click="selectChainGroup(index, item)" >{{ isCaseGroupEditable ? '' : item.groupName }}</a><a style="right: 0px; position: absolute; z-index: 100; width: fit-content; background-color: white">{{' (' + item.count + ') '}}</a>
<a href="javascript:void(0)" @click="selectChainGroup(index, item)" :style="{ color: index == currentChainGroupIndex ? 'black' : 'gray' }" >{{ isCaseGroupEditable ? '' : item.groupName }}</a><a style="right: 0px; position: absolute; z-index: 100; width: fit-content; background-color: white">{{' (' + (item.count - 1) + ') '}}</a>
</div>
</li>
</ul>
Expand Down
72 changes: 46 additions & 26 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4114,10 +4114,10 @@ https://github.com/Tencent/APIJSON/issues
this.selectChainGroup(0, path)
},
isChainGroupShow: function () {
return this.chainShowType != 1 && (this.chainGroups.length > 0 || this.chainPaths.length <= 0)
return true // this.chainShowType != 1 && (this.chainGroups.length > 0) // || this.chainPaths.length <= 0)
},
isChainItemShow: function () {
return this.chainShowType != 2 || (this.chainGroups.length <= 0 && this.chainPaths.length > 0)
return true // this.chainShowType != 2 || (this.chainGroups.length <= 0 && this.chainPaths.length > 0)
},
selectChainGroup: function (index, group) {
this.currentChainGroupIndex = index
Expand All @@ -4134,9 +4134,11 @@ https://github.com/Tencent/APIJSON/issues
this.chainPaths.push(group)
}

// this.casePaths = this.chainPaths

var groupId = group == null ? 0 : group.groupId
if (group != null && groupId == 0) {
this.chainGroups = []
if (groupId != null && groupId > 0) { // group != null && groupId == 0) {
// this.chainGroups = []
this.remotes = App.testCases = []
this.showTestCase(true, false, null)
return
Expand All @@ -4156,9 +4158,11 @@ https://github.com/Tencent/APIJSON/issues
'Chain': {
'toGroupId': groupId,
'groupName$': search,
// '@raw': '@column',
'@column': "groupId;any_value(groupName):groupName;count(*):count",
'@group': 'groupId',
'@order': 'groupId-',
// 'documentId>': 0
}
},
'@role': IS_NODE ? null : 'LOGIN',
Expand Down Expand Up @@ -4193,6 +4197,11 @@ https://github.com/Tencent/APIJSON/issues
}

App.chainGroups = data['Chain[]'] || []
if (App.chainGroups.length > 0) {
App.currentChainGroupIndex = 0
App.chainPaths.push(App.chainGroups[0])
}

App.remotes = App.testCases = []
App.showTestCase(true, false, null)
})
Expand All @@ -4206,16 +4215,23 @@ https://github.com/Tencent/APIJSON/issues
}

var group = this.chainGroups[this.currentChainGroupIndex]
if (id == null || id <= 0) {
if (group == null) {
var index = this.chainPaths.length - 1
group = this.chainPaths[index]
}
var groupId = group == null ? 0 : group.groupId
if (groupId == null || groupId <= 0) {
alert('请选择有效的场景串联用例分组!')
return
}

var groupName = group.groupName

var isAdd = true
this.request(true, REQUEST_TYPE_POST, REQUEST_TYPE_JSON, this.server + '/post', {
Chain: {
'groupName': group.groupName,
'groupId': group.groupId,
'groupName': groupName,
'groupId': groupId,
'documentId': item.id
},
tag: 'Chain'
Expand Down Expand Up @@ -4390,7 +4406,8 @@ https://github.com/Tencent/APIJSON/issues

onClickPathRoot: function () {
var isChainShow = this.isChainShow
var paths = isChainShow ? this.chainPaths : this.casePaths
// var paths = isChainShow ? this.chainPaths : this.casePaths
var paths = isChainShow ? [] : this.casePaths
if (paths.length <= 0) {
var type = this.groupShowType = (this.groupShowType + 1)%3
this.isChainShow = type == 1
Expand Down Expand Up @@ -4473,12 +4490,13 @@ https://github.com/Tencent/APIJSON/issues
'[]': {
'count': count || 100, //200 条测试直接卡死 0,
'page': page || 0,
'join': isChainShow ? '@/Document,@/Random' : '@/TestRecord,@/Script:pre,@/Script:post',
'join': isChainShow ? '&/Document,@/Random' : '@/TestRecord,@/Script:pre,@/Script:post',
'Chain': isChainShow ? {
// TODO 后续再支持嵌套子组合 'toGroupId': groupId,
'groupId': groupId,
'@column': "id,groupId,documentId,randomId",
'@order': 'id+',
'documentId>': 0
} : null,
'Document': {
'id@': isChainShow ? '/Chain/documentId' : null,
Expand Down Expand Up @@ -6784,25 +6802,27 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
}
if (! isOk) {
alert(isOk ? '选择右侧接口来添加' : '查询失败!\ngroupName: ' + groupName + '\n' + msg)
} else {
var list = res.data['Document[]'] || []
var options = []
for (var i = 0; i < list.length; i ++) {
var item = list[i] || {}
options.push({
name: '[' + item.method + '] [' + item.type + '] ' + item.name + ' ' + item.url,
// type: stringType,
value: item,
}
)
}
return
}

App.options = options
document.activeElement = vOption // vChainAdd.focusout()
vOption.focus()
// App.showOptions(target, text, before, after);
var list = res.data['Document[]'] || []
var options = []
for (var i = 0; i < list.length; i ++) {
var item = list[i] || {}
options.push({
name: '[' + item.method + '][' + item.type + ']', // + item.name + ' ' + item.url,
type: item.name,
comment: item.url,
value: item
}
)
}

App.options = options
document.activeElement = vOption // vChainAdd.focusout()
vOption.focus()
// App.showOptions(target, text, before, after);

})

return
Expand Down Expand Up @@ -6985,7 +7005,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
this.saveCache(this.server, 'chainGroupCounts', this.chainGroupCounts)
// this.saveCache(this.server, 'chainGroupSearches', this.chainGroupSearches)

this.selectChainGroup()
this.selectChainGroup(-1, null)
}
else if (type == 'caseGroup') {
this.caseGroupPages[groupKey] = this.caseGroupPage
Expand Down

0 comments on commit 0aab24d

Please sign in to comment.