feat: 接口测试用例关联页面
This commit is contained in:
parent
f377bd251a
commit
ba689c3e27
|
@ -1 +1 @@
|
|||
Subproject commit 61397c16728a63493507679f7e0940d9099f337f
|
||||
Subproject commit bb494fc68a2367359c9048fa7250c7618de4afb6
|
|
@ -4,7 +4,7 @@
|
|||
<ms-node-tree
|
||||
v-loading="result.loading"
|
||||
:tree-nodes="data"
|
||||
:type="'edit'"
|
||||
:type="isReadOnly ? 'view' : 'edit'"
|
||||
@add="add"
|
||||
@edit="edit"
|
||||
@drag="drag"
|
||||
|
@ -16,6 +16,7 @@
|
|||
<api-module-header
|
||||
:condition="condition"
|
||||
:current-module="currentModule"
|
||||
:is-read-only="isReadOnly"
|
||||
@exportAPI="exportAPI"
|
||||
@saveAsEdit="saveAsEdit"
|
||||
@refresh="refresh"
|
||||
|
@ -60,6 +61,14 @@
|
|||
currentModule: {},
|
||||
}
|
||||
},
|
||||
props: {
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.projectId = getCurrentProjectID();
|
||||
this.$emit('protocolChange', this.condition.protocol);
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
:disabled="item.disabled">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-input class="filter-input" :placeholder="$t('test_track.module.search')" v-model="condition.filterText" size="small">
|
||||
<el-input class="filter-input" :class="{'read-only': isReadOnly}" :placeholder="$t('test_track.module.search')" v-model="condition.filterText" size="small">
|
||||
<template v-slot:append>
|
||||
<el-dropdown size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
|
||||
<el-dropdown v-if="!isReadOnly" size="small" split-button type="primary" class="ms-api-button" @click="handleCommand('add-api')"
|
||||
@command="handleCommand">
|
||||
<el-button icon="el-icon-folder-add" @click="addApi"></el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
|
@ -61,6 +61,12 @@
|
|||
default() {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -105,8 +111,13 @@
|
|||
height: 30px;
|
||||
}
|
||||
|
||||
.read-only {
|
||||
width: 150px !important;
|
||||
}
|
||||
|
||||
.filter-input {
|
||||
width: 175px;
|
||||
padding-left: 3px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -7,62 +7,40 @@
|
|||
ref="baseRelevance">
|
||||
|
||||
<template v-slot:aside>
|
||||
<node-tree class="node-tree"
|
||||
@nodeSelectEvent="nodeChange"
|
||||
@refresh="refresh"
|
||||
:tree-nodes="treeNodes"
|
||||
ref="nodeTree"/>
|
||||
<!--<node-tree class="node-tree"-->
|
||||
<!--@nodeSelectEvent="nodeChange"-->
|
||||
<!--@refresh="refresh"-->
|
||||
<!--:tree-nodes="treeNodes"-->
|
||||
<!--ref="nodeTree"/>-->
|
||||
<ms-api-module
|
||||
@nodeSelectEvent="nodeChange"
|
||||
@protocolChange="handleProtocolChange"
|
||||
@refreshTable="refresh"
|
||||
@exportAPI="exportAPI"
|
||||
@debug="debug"
|
||||
@saveAsEdit="editApi"
|
||||
@setModuleOptions="setModuleOptions"
|
||||
@enableTrash="enableTrash"
|
||||
:is-read-only="true"
|
||||
:type="'edit'"
|
||||
ref="nodeTree"/>
|
||||
</template>
|
||||
|
||||
<ms-table-header :condition.sync="condition" @search="search" title="" :show-create="false"/>
|
||||
|
||||
<el-table
|
||||
v-loading="result.loading"
|
||||
:data="testCases"
|
||||
@filter-change="filter"
|
||||
row-key="id"
|
||||
@mouseleave.passive="leave"
|
||||
v-el-table-infinite-scroll="scrollLoading"
|
||||
@select-all="handleSelectAll"
|
||||
@select="handleSelectionChange"
|
||||
height="50vh"
|
||||
ref="table">
|
||||
<api-list
|
||||
v-if="isApiListEnable"
|
||||
:current-protocol="currentProtocol"
|
||||
:currentRow="currentRow"
|
||||
:select-node-ids="selectNodeIds"
|
||||
:trash-enable="trashEnable"
|
||||
:is-api-list-enable="isApiListEnable"
|
||||
@editApi="editApi"
|
||||
@handleCase="handleCase"
|
||||
@showExecResult="showExecResult"
|
||||
@isApiListEnableChange="isApiListEnableChange"
|
||||
ref="apiList"/>
|
||||
|
||||
<el-table-column
|
||||
type="selection"></el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="name"
|
||||
:label="$t('test_track.case.name')"
|
||||
style="width: 100%">
|
||||
<template v-slot:default="scope">
|
||||
{{scope.row.name}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="priority"
|
||||
:filters="priorityFilters"
|
||||
column-key="priority"
|
||||
:label="$t('test_track.case.priority')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<priority-table-item :value="scope.row.priority"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="type"
|
||||
:filters="typeFilters"
|
||||
column-key="type"
|
||||
:label="$t('test_track.case.type')"
|
||||
show-overflow-tooltip>
|
||||
<template v-slot:default="scope">
|
||||
<type-table-item :value="scope.row.type"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div v-if="!lineStatus" style="text-align: center">{{$t('test_track.review_view.last_page')}}</div>
|
||||
<div style="text-align: center">共 {{total}} 条</div>
|
||||
|
||||
</test-case-relevance-base>
|
||||
|
||||
|
@ -76,14 +54,17 @@
|
|||
import MsTableSearchBar from "../../../../../common/components/MsTableSearchBar";
|
||||
import MsTableAdvSearchBar from "../../../../../common/components/search/MsTableAdvSearchBar";
|
||||
import MsTableHeader from "../../../../../common/components/MsTableHeader";
|
||||
import {TEST_CASE_CONFIGS} from "../../../../../common/components/search/search-components";
|
||||
import elTableInfiniteScroll from 'el-table-infinite-scroll';
|
||||
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
|
||||
import {_filter} from "../../../../../../../common/js/utils";
|
||||
import ApiList from "../../../../../api/automation/scenario/api/ApiList";
|
||||
import MsApiModule from "../../../../../api/definition/components/module/ApiModule";
|
||||
import {getCurrentProjectID} from "../../../../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "TestCaseApiRelevance",
|
||||
components: {
|
||||
MsApiModule,
|
||||
ApiList,
|
||||
TestCaseRelevanceBase,
|
||||
NodeTree,
|
||||
PriorityTableItem,
|
||||
|
@ -97,34 +78,17 @@
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
result: {},
|
||||
isCheckAll: false,
|
||||
testCases: [],
|
||||
selectIds: new Set(),
|
||||
treeNodes: [],
|
||||
showCasePage: true,
|
||||
apiDefaultTab: 'default',
|
||||
currentProtocol: null,
|
||||
currentModule: null,
|
||||
selectNodeIds: [],
|
||||
selectNodeNames: [],
|
||||
projectId: '',
|
||||
projectName: '',
|
||||
projects: [],
|
||||
pageSize: 50,
|
||||
currentPage: 1,
|
||||
total: 0,
|
||||
lineStatus: true,
|
||||
condition: {
|
||||
components: TEST_CASE_CONFIGS
|
||||
},
|
||||
priorityFilters: [
|
||||
{text: 'P0', value: 'P0'},
|
||||
{text: 'P1', value: 'P1'},
|
||||
{text: 'P2', value: 'P2'},
|
||||
{text: 'P3', value: 'P3'}
|
||||
],
|
||||
typeFilters: [
|
||||
{text: this.$t('commons.functional'), value: 'functional'},
|
||||
{text: this.$t('commons.performance'), value: 'performance'},
|
||||
{text: this.$t('commons.api'), value: 'api'}
|
||||
]
|
||||
currentApi: {},
|
||||
moduleOptions: {},
|
||||
trashEnable: false,
|
||||
isApiListEnable: true,
|
||||
condition: {},
|
||||
currentRow: {}
|
||||
};
|
||||
},
|
||||
props: {
|
||||
|
@ -134,15 +98,12 @@
|
|||
},
|
||||
watch: {
|
||||
planId() {
|
||||
this.condition.planId = this.planId;
|
||||
},
|
||||
selectNodeIds() {
|
||||
this.search();
|
||||
// this.condition.planId = this.planId;
|
||||
},
|
||||
projectId() {
|
||||
this.condition.projectId = this.projectId;
|
||||
this.getProjectNode();
|
||||
this.search();
|
||||
// this.getProjectNode();
|
||||
// this.search();
|
||||
}
|
||||
},
|
||||
updated() {
|
||||
|
@ -153,11 +114,96 @@
|
|||
open() {
|
||||
this.$refs.baseRelevance.open();
|
||||
},
|
||||
search() {
|
||||
|
||||
},
|
||||
|
||||
setProject(projectId) {
|
||||
this.projectId = projectId;
|
||||
},
|
||||
|
||||
isApiListEnableChange(data) {
|
||||
this.isApiListEnable = data;
|
||||
},
|
||||
handleCommand(e) {
|
||||
switch (e) {
|
||||
case "ADD":
|
||||
this.handleTabAdd(e);
|
||||
break;
|
||||
case "TEST":
|
||||
this.handleTabsEdit(this.$t("commons.api"), e);
|
||||
break;
|
||||
case "CLOSE_ALL":
|
||||
this.handleTabClose();
|
||||
break;
|
||||
default:
|
||||
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
|
||||
break;
|
||||
}
|
||||
},
|
||||
debug(id) {
|
||||
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug", id);
|
||||
},
|
||||
editApi(row) {
|
||||
let name = this.$t('api_test.definition.request.edit_api');
|
||||
if (row.name) {
|
||||
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
|
||||
}
|
||||
// this.handleTabsEdit(name, "ADD", row);
|
||||
},
|
||||
handleCase(api) {
|
||||
this.currentApi = api;
|
||||
this.showCasePage = false;
|
||||
},
|
||||
apiCaseClose() {
|
||||
this.showCasePage = true;
|
||||
},
|
||||
exportAPI() {
|
||||
if (!this.$refs.apiList[0].tableData) {
|
||||
return;
|
||||
}
|
||||
let obj = {projectName: getCurrentProjectID(), protocol: this.currentProtocol, data: this.$refs.apiList[0].tableData}
|
||||
// downloadFile("导出API.json", JSON.stringify(obj));
|
||||
},
|
||||
refresh(data) {
|
||||
this.$refs.apiList[0].initTable(data);
|
||||
},
|
||||
setTabTitle(data) {
|
||||
for (let index in this.apiTabs) {
|
||||
let tab = this.apiTabs[index];
|
||||
if (tab.name === this.apiDefaultTab) {
|
||||
tab.title = this.$t('api_test.definition.request.edit_api') + "-" + data.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.runTestData = data;
|
||||
},
|
||||
runTest(data) {
|
||||
this.setTabTitle(data);
|
||||
this.handleCommand("TEST");
|
||||
},
|
||||
saveApi(data) {
|
||||
this.setTabTitle(data);
|
||||
this.$refs.apiList[0].initApiTable(data);
|
||||
},
|
||||
|
||||
showExecResult(row){
|
||||
this.debug(row);
|
||||
},
|
||||
|
||||
nodeChange(node, nodeIds, pNodes) {
|
||||
this.selectNodeIds = nodeIds;
|
||||
},
|
||||
handleProtocolChange(protocol) {
|
||||
this.currentProtocol = protocol;
|
||||
},
|
||||
setModuleOptions(data) {
|
||||
this.moduleOptions = data;
|
||||
},
|
||||
enableTrash(data) {
|
||||
this.trashEnable = data;
|
||||
},
|
||||
|
||||
saveCaseRelevance() {
|
||||
let param = {};
|
||||
param.planId = this.planId;
|
||||
|
@ -176,148 +222,6 @@
|
|||
this.$emit('refresh');
|
||||
});
|
||||
},
|
||||
buildPagePath(path) {
|
||||
return path + "/" + this.currentPage + "/" + this.pageSize;
|
||||
},
|
||||
search() {
|
||||
this.currentPage = 1;
|
||||
this.testCases = [];
|
||||
this.getTestCases(true);
|
||||
},
|
||||
getTestCases(flag) {
|
||||
if (this.planId) {
|
||||
this.condition.planId = this.planId;
|
||||
}
|
||||
if (this.selectNodeIds && this.selectNodeIds.length > 0) {
|
||||
this.condition.nodeIds = this.selectNodeIds;
|
||||
} else {
|
||||
this.condition.nodeIds = [];
|
||||
}
|
||||
if (this.projectId) {
|
||||
this.condition.projectId = this.projectId;
|
||||
// this.result = this.$post(this.buildPagePath('/test/case/name'), this.condition, response => {
|
||||
// let data = response.data;
|
||||
// this.total = data.itemCount;
|
||||
// let tableData = data.listObject;
|
||||
// tableData.forEach(item => {
|
||||
// item.checked = false;
|
||||
// });
|
||||
// flag ? this.testCases = tableData : this.testCases = this.testCases.concat(tableData);
|
||||
// // 去重处理
|
||||
// let hash = {}
|
||||
// this.testCases = this.testCases.reduce((item, next) => {
|
||||
// if (!hash[next.id]) {
|
||||
// hash[next.id] = true
|
||||
// item.push(next)
|
||||
// }
|
||||
// return item
|
||||
// }, [])
|
||||
//
|
||||
// this.lineStatus = tableData.length === 50 && this.testCases.length < this.total;
|
||||
// });
|
||||
this.result = this.$post('/api/definition/list/1/10', this.condition, response => {
|
||||
let data = response.data;
|
||||
this.total = data.itemCount;
|
||||
let tableData = data.listObject;
|
||||
tableData.forEach(item => {
|
||||
item.checked = false;
|
||||
});
|
||||
flag ? this.testCases = tableData : this.testCases = this.testCases.concat(tableData);
|
||||
// 去重处理
|
||||
let hash = {}
|
||||
this.testCases = this.testCases.reduce((item, next) => {
|
||||
if (!hash[next.id]) {
|
||||
hash[next.id] = true
|
||||
item.push(next)
|
||||
}
|
||||
return item
|
||||
}, [])
|
||||
|
||||
this.lineStatus = tableData.length === 50 && this.testCases.length < this.total;
|
||||
});
|
||||
}
|
||||
},
|
||||
handleSelectAll(selection) {
|
||||
if (selection.length > 0) {
|
||||
this.testCases.forEach(item => {
|
||||
this.selectIds.add(item.id);
|
||||
});
|
||||
} else {
|
||||
this.testCases.forEach(item => {
|
||||
if (this.selectIds.has(item.id)) {
|
||||
this.selectIds.delete(item.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleSelectionChange(selection, row) {
|
||||
if (this.selectIds.has(row.id)) {
|
||||
this.selectIds.delete(row.id);
|
||||
} else {
|
||||
this.selectIds.add(row.id);
|
||||
}
|
||||
},
|
||||
nodeChange(nodeIds, nodeNames) {
|
||||
this.selectNodeIds = nodeIds;
|
||||
this.selectNodeNames = nodeNames;
|
||||
},
|
||||
refresh() {
|
||||
this.close();
|
||||
},
|
||||
scrollLoading() {
|
||||
if (this.lineStatus) {
|
||||
this.currentPage += 1;
|
||||
this.getTestCases();
|
||||
}
|
||||
},
|
||||
getAllNodeTreeByPlanId() {
|
||||
if (this.planId) {
|
||||
let param = {
|
||||
testPlanId: this.planId,
|
||||
projectId: this.projectId
|
||||
};
|
||||
this.result = this.$get('/api/module/list/' + this.project + '/HTTP', response => {
|
||||
this.treeNodes = response.data;
|
||||
});
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.lineStatus = false;
|
||||
this.selectIds.clear();
|
||||
this.selectNodeIds = [];
|
||||
this.selectNodeNames = [];
|
||||
},
|
||||
filter(filters) {
|
||||
_filter(filters, this.condition);
|
||||
this.search();
|
||||
},
|
||||
toggleSelection(rows) {
|
||||
rows.forEach(row => {
|
||||
this.selectIds.forEach(id => {
|
||||
if (row.id === id) {
|
||||
// true 是为选中
|
||||
this.$refs.table.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
getProjectNode(projectId) {
|
||||
const index = this.projects.findIndex(project => project.id === projectId);
|
||||
if (index !== -1) {
|
||||
this.projectName = this.projects[index].name;
|
||||
}
|
||||
if (projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
this.$refs.nodeTree.result = this.$get('/api/module/list/' + this.projectId + '/HTTP', response => {
|
||||
this.treeNodes = response.data;
|
||||
});
|
||||
// this.$refs.nodeTree.result = this.$post('/api/module/list/' + this.project + '/HTTP',
|
||||
// {testPlanId: this.planId, projectId: this.projectId}, response => {
|
||||
// this.treeNodes = response.data;
|
||||
// });
|
||||
this.selectNodeIds = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
<el-aside class="tree-aside" width="250px">
|
||||
<select-menu
|
||||
:data="projects"
|
||||
width="185px"
|
||||
width="160px"
|
||||
:current-data="currentProject"
|
||||
:title="$t('test_track.plan_view.plan')"
|
||||
:title="$t('test_track.switch_project')"
|
||||
@dataChange="changeProject"/>
|
||||
<slot name="aside"></slot>
|
||||
</el-aside>
|
||||
|
@ -79,11 +79,6 @@
|
|||
this.$emit('save');
|
||||
},
|
||||
|
||||
refresh() {
|
||||
// this.close();
|
||||
|
||||
},
|
||||
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d39dafaf84b9c7a56cb51f2caf67dd7dfde5938c
|
||||
Subproject commit a22a3005d9bd254793fcf634d72539cbdf31be3a
|
Loading…
Reference in New Issue