测试用例筛选

This commit is contained in:
chenjianxing 2020-04-23 14:49:08 +08:00
parent 7d99ac3e8b
commit a58623ba24
7 changed files with 222 additions and 245 deletions

View File

@ -1,4 +1,4 @@
<template>
<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
<div>
<el-card v-loading="result.loading">
@ -27,26 +27,32 @@
</el-table-column>
<el-table-column
prop="priority"
:filters="priorityFilters"
:filter-method="filter"
: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"
:filter-method="filter"
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
<span v-if="scope.row.type == 'functional'">{{$t('test_track.case.functional_test')}}</span>
<span v-if="scope.row.type == 'performance'">{{$t('commons.performance')}}</span>
<span v-if="scope.row.type == 'api'">{{$t('commons.api')}}</span>
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column
prop="method"
:filters="methodFilters"
:filter-method="filter"
:label="$t('test_track.case.method')"
show-overflow-tooltip>
<template v-slot:default="scope">
<span v-if="scope.row.method == 'manual'">{{$t('test_track.case.manual')}}</span>
<span v-if="scope.row.method == 'auto'">{{$t('test_track.case.auto')}}</span>
<method-table-item :value="scope.row.method"/>
</template>
</el-table-column>
<el-table-column
@ -55,12 +61,16 @@
show-overflow-tooltip>
</el-table-column>
<el-table-column
prop="createTime"
sortable
:label="$t('commons.create_time')">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</el-table-column>
<el-table-column
prop="updateTime"
sortable
:label="$t('commons.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -90,20 +100,41 @@
import MsTablePagination from '../../../../components/common/pagination/TablePagination';
import NodeBreadcrumb from '../../common/NodeBreadcrumb';
import MsTableHeader from '../../../../components/common/components/MsTableHeader';
import PriorityTableItem from "../../common/TableItems/PriorityTableItem";
import TypeTableItem from "../../common/TableItems/TypeTableItem";
import MethodTableItem from "../../common/TableItems/MethodTableItem";
export default {
name: "TestCaseList",
components: {MsCreateBox, TestCaseImport, TestCaseExport, MsTablePagination, NodeBreadcrumb, MsTableHeader},
data() {
return {
result: {},
deletePath: "/test/case/delete",
condition: {},
tableData: [],
currentPage: 1,
pageSize: 5,
total: 0,
}
components: {
MethodTableItem,
TypeTableItem,
PriorityTableItem,
MsCreateBox, TestCaseImport, TestCaseExport, MsTablePagination, NodeBreadcrumb, MsTableHeader},
data() {
return {
result: {},
deletePath: "/test/case/delete",
condition: {},
tableData: [],
currentPage: 1,
pageSize: 5,
total: 0,
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'}
],
methodFilters: [
{text: this.$t('test_track.case.manual'), value: 'manual'},
{text: this.$t('test_track.case.auto'), value: 'auto'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
]
}
},
props: {
currentProject: {
@ -174,6 +205,10 @@
refresh() {
this.condition = {};
this.$emit('refresh');
},
filter(value, row, column) {
const property = column['property'];
return row[property] === value;
}
}
}

View File

@ -1,183 +0,0 @@
<template>
<div>
<el-input :placeholder="$t('test_track.module.search')" v-model="filterText" size="small"></el-input>
<el-tree
v-loading="result.loading"
class="filter-tree node-tree"
:data="treeNodes"
node-key="id"
@node-drag-end="handleDragEnd"
:filter-node-method="filterNode"
:expand-on-click-node="false"
highlight-current
draggable
ref="tree">
<template v-slot:default="{node}">
<span class="custom-tree-node" @click="selectNode(node)">
{{node.label}}
</span>
</template>
</el-tree>
</div>
</template>
<script>
export default {
name: "PlanNodeTree",
data() {
return {
result: {},
filterText: '',
defaultProps: {
children: 'children',
label: 'label'
},
dialogTableVisible: false,
defaultKeys: [],
treeNodes: []
};
},
props: {
planId: {
type: String
},
showAll: {
type: Boolean
}
},
created() {
this.initTree();
},
watch: {
filterText(val) {
this.$refs.tree.filter(val);
},
planId() {
this.initTree();
},
'$route'(to, from) {
if (to.path.indexOf("/track/plan/view/") >= 0){
this.initTree();
}
}
},
selectNode(node) {
let nodeIds = [];
this.getChildNodeId(node, nodeIds);
this.$emit("nodeSelectEvent", nodeIds);
},
getChildNodeId(rootNode, nodeIds) {
//ID
nodeIds.push(rootNode.data.id);
for (let i = 0; i < rootNode.childNodes.length; i++) {
this.getChildNodeId(rootNode.childNodes[i], nodeIds);
}
return nodeIds;
},
methods: {
initTree() {
if (this.showAll) {
this.getAllNodeTreeByPlanId();
} else {
this.getNodeTreeByPlanId();
}
},
handleDragEnd(draggingNode, dropNode, dropType, ev) {
let param = {};
param.id = draggingNode.data.id;
if(dropType === 'inner'){
param.pId = dropNode.data.id;
param.level = dropNode.data.level + 1;
} else {
if(dropNode.parent.id === 0){
param.pId = 0;
param.level = 1;
} else {
param.pId = dropNode.parent.data.id;
param.level = dropNode.parent.data.level + 1;
}
}
this.$post('/case/node/edit', param);
},
selectNode(node) {
let nodeIds = [];
let nodeNames = [];
this.getChildNodeId(node, nodeIds);
this.getParentNodeName(node, nodeNames);
this.$emit("nodeSelectEvent", nodeIds, nodeNames);
},
getChildNodeId(rootNode, nodeIds) {
//ID
nodeIds.push(rootNode.data.id);
for (let i = 0; i < rootNode.childNodes.length; i++){
this.getChildNodeId(rootNode.childNodes[i], nodeIds);
}
},
getParentNodeName(rootNode, nodeNames) {
if (rootNode.parent && rootNode.parent.id != 0) {
this.getParentNodeName(rootNode.parent, nodeNames)
}
if (rootNode.data.name && rootNode.data.name != '') {
nodeNames.push(rootNode.data.name);
}
},
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
getNodeTreeByPlanId() {
if(this.planId){
this.result = this.$get("/case/node/list/plan/" + this.planId, response => {
this.treeNodes = response.data;
});
}
},
getAllNodeTreeByPlanId() {
if (this.planId) {
this.result = this.$get("/case/node/list/all/plan/" + this.planId, response => {
this.treeNodes = response.data;
});
}
}
}
}
</script>
<style scoped>
.el-dropdown-link {
cursor: pointer;
color: #409EFF;
}
.el-icon-arrow-down {
font-size: 12px;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
width: 100%;
}
.node-tree {
margin-top: 15px;
}
.father .child {
display: none;
}
.father:hover .child {
display: block;
}
</style>

View File

@ -0,0 +1,21 @@
<template>
<div>
<span v-if="value == 'manual'">{{$t('test_track.case.manual')}}</span>
<span v-if="value == 'auto'">{{$t('test_track.case.auto')}}</span>
</div>
</template>
<script>
export default {
name: "MethodTableItem",
props: {
value: {
type: String
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,36 @@
<template>
<div>
<el-tag v-if="value == 'P0'"
type="danger"
effect="dark"
size="mini">{{value}}</el-tag>
<el-tag v-if="value == 'P1'"
type="danger"
effect="light"
size="mini">{{value}}</el-tag>
<el-tag v-if="value == 'P2'"
type="warning"
effect="dark"
size="mini">{{value}}</el-tag>
<el-tag v-if="value == 'P3'"
type="warning"
effect="light"
size="mini">{{value}}</el-tag>
</div>
</template>
<script>
export default {
name: "PriorityTableItem",
props: {
value: {
type: String
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,39 @@
<template>
<div>
<el-tag v-if="value == 'Prepare'"
type="info"
effect="dark"
size="mini">{{$t('test_track.plan.plan_status_prepare')}}</el-tag>
<el-tag v-if="value == 'Pass'"
type="success"
effect="dark"
size="mini">{{$t('test_track.plan_view.pass')}}</el-tag>
<el-tag v-if="value == 'Failure'"
type="danger"
effect="dark"
size="mini">{{$t('test_track.plan_view.failure')}}</el-tag>
<el-tag v-if="value == 'Blocking'"
type="warning"
effect="dark"
size="mini">{{$t('test_track.plan_view.blocking')}}</el-tag>
<el-tag v-if="value == 'Skip'"
type="info"
effect="dark"
size="mini">{{$t('test_track.plan_view.skip')}}</el-tag>
</div>
</template>
<script>
export default {
name: "StatusTableItem",
props: {
value: {
type: String
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,24 @@
<template>
<div>
<span v-if="value == 'functional'">{{$t('commons.functional')}}</span>
<span v-if="value == 'performance'">{{$t('commons.performance')}}</span>
<span v-if="value == 'api'">{{$t('commons.api')}}</span>
</div>
</template>
<script>
export default {
name: "TypeTableItem",
props: {
value: {
type: String
}
}
}
</script>
<style scoped>
</style>

View File

@ -33,49 +33,36 @@
</el-table-column>
<el-table-column
prop="priority"
:filters="priorityFilters"
:filter-method="filter"
:label="$t('test_track.case.priority')">
<template v-slot:default="scope">
<el-tag v-if="scope.row.priority == 'P0'"
type="danger"
effect="dark"
size="mini">{{scope.row.priority}}</el-tag>
<el-tag v-if="scope.row.priority == 'P1'"
type="danger"
effect="light"
size="mini">{{scope.row.priority}}</el-tag>
<el-tag v-if="scope.row.priority == 'P2'"
type="warning"
effect="dark"
size="mini">{{scope.row.priority}}</el-tag>
<el-tag v-if="scope.row.priority == 'P3'"
type="warning"
effect="light"
size="mini">{{scope.row.priority}}</el-tag>
<priority-table-item :value="scope.row.priority" ref="priority"/>
</template>
</el-table-column>
<el-table-column
prop="type"
:filters="typeFilters"
:filter-method="filter"
:label="$t('test_track.case.type')"
show-overflow-tooltip>
<template v-slot:default="scope">
<span v-if="scope.row.type == 'functional'">{{$t('commons.functional')}}</span>
<span v-if="scope.row.type == 'performance'">{{$t('commons.performance')}}</span>
<span v-if="scope.row.type == 'api'">{{$t('commons.api')}}</span>
<type-table-item :value="scope.row.type"/>
</template>
</el-table-column>
<el-table-column
prop="method"
:filters="methodFilters"
:filter-method="filter"
:label="$t('test_track.case.method')"
show-overflow-tooltip>
<template v-slot:default="scope">
<span v-if="scope.row.method == 'manual'">{{$t('test_track.case.manual')}}</span>
<span v-if="scope.row.method == 'auto'">{{$t('test_track.case.auto')}}</span>
<method-table-item :value="scope.row.method"/>
</template>
</el-table-column>
<el-table-column
prop="executor"
:label="$t('test_track.plan_view.executor')">
@ -83,32 +70,17 @@
<el-table-column
prop="status"
:filters="statusFilters"
:filter-method="filter"
:label="$t('test_track.plan_view.execute_result')">
<template v-slot:default="scope">
<el-tag v-if="scope.row.status == 'Prepare'"
type="info"
effect="dark"
size="mini">{{$t('test_track.plan.plan_status_prepare')}}</el-tag>
<el-tag v-if="scope.row.status == 'Pass'"
type="success"
effect="dark"
size="mini">{{$t('test_track.plan_view.pass')}}</el-tag>
<el-tag v-if="scope.row.status == 'Failure'"
type="danger"
effect="dark"
size="mini">{{$t('test_track.plan_view.failure')}}</el-tag>
<el-tag v-if="scope.row.status == 'Blocking'"
type="warning"
effect="dark"
size="mini">{{$t('test_track.plan_view.blocking')}}</el-tag>
<el-tag v-if="scope.row.status == 'Skip'"
type="info"
effect="dark"
size="mini">{{$t('test_track.plan_view.skip')}}</el-tag>
<status-table-item :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column
sortable
prop="updateTime"
:label="$t('commons.update_time')">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
@ -135,7 +107,6 @@
</template>
<script>
import PlanNodeTree from '../../common/PlanNodeTree';
import ExecutorEdit from './ExecutorEdit';
import StatusEdit from './StatusEdit';
import TestPlanTestCaseEdit from "../components/TestPlanTestCaseEdit";
@ -146,10 +117,19 @@
import NodeBreadcrumb from '../../common/NodeBreadcrumb';
import {TokenKey} from '../../../../../common/js/constants';
import {tableFilter} from '../../../../../common/js/utils';
import PriorityTableItem from "../../common/TableItems/PriorityTableItem";
import StatusTableItem from "../../common/TableItems/StatusTableItem";
import TypeTableItem from "../../common/TableItems/TypeTableItem";
import MethodTableItem from "../../common/TableItems/MethodTableItem";
export default {
name: "TestPlanTestCaseList",
components: {PlanNodeTree, StatusEdit, ExecutorEdit, MsTipButton, MsTablePagination,
components: {
MethodTableItem,
TypeTableItem,
StatusTableItem,
PriorityTableItem, StatusEdit, ExecutorEdit, MsTipButton, MsTablePagination,
TestPlanTestCaseEdit, MsTableHeader, NodeBreadcrumb, MsTableButton},
data() {
return {
@ -161,7 +141,28 @@
currentPage: 1,
pageSize: 5,
total: 0,
selectIds: new Set()
selectIds: new Set(),
priorityFilters: [
{text: 'P0', value: 'P0'},
{text: 'P1', value: 'P1'},
{text: 'P2', value: 'P2'}
],
methodFilters: [
{text: this.$t('test_track.case.manual'), value: 'manual'},
{text: this.$t('test_track.case.auto'), value: 'auto'}
],
typeFilters: [
{text: this.$t('commons.functional'), value: 'functional'},
{text: this.$t('commons.performance'), value: 'performance'},
{text: this.$t('commons.api'), value: 'api'}
],
statusFilters: [
{text: this.$t('test_track.plan.plan_status_prepare'), value: 'Prepare'},
{text: this.$t('test_track.plan_view.pass'), value: 'Pass'},
{text: this.$t('test_track.plan_view.failure'), value: 'Failure'},
{text: this.$t('test_track.plan_view.blocking'), value: 'Blocking'},
{text: this.$t('test_track.plan_view.skip'), value: 'Skip'},
]
}
},
props:{
@ -267,6 +268,10 @@
this.condition.executor = null;
}
this.initTableData();
},
filter(value, row, column) {
const property = column['property'];
return row[property] === value;
}
}
}