refactor(测试用例): 关联测试页面增加高级搜索#1002993

--story=1002993 --user=lyh 21.功能用例关联测试的时候 参考测试计划的关联列表展示 支持标签、高级搜索
https://www.tapd.cn/55049933/s/1044591
This commit is contained in:
shiziyuan9527 2021-09-07 18:01:46 +08:00 committed by 刘瑞斌
parent 3605b12e7b
commit c706564720
5 changed files with 236 additions and 13 deletions

View File

@ -162,6 +162,13 @@
#{nodeId} #{nodeId}
</foreach> </foreach>
</if> </if>
<if test="request.combine != null">
<include refid="combine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
<property name="objectKey" value="request.combine.tags"/>
</include>
</if>
<if test="request.filters != null and request.filters.size() > 0"> <if test="request.filters != null and request.filters.size() > 0">
<foreach collection="request.filters.entrySet()" index="key" item="values"> <foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0"> <if test="values != null and values.size() > 0">
@ -184,9 +191,128 @@
</if> </if>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select> </select>
<sql id="condition">
<choose>
<when test='${object}.operator == "like"'>
like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "not like"'>
not like CONCAT('%', #{${object}.value},'%')
</when>
<when test='${object}.operator == "in"'>
in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "not in"'>
not in
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</when>
<when test='${object}.operator == "between"'>
between #{${object}.value[0]} and #{${object}.value[1]}
</when>
<when test='${object}.operator == "gt"'>
&gt; #{${object}.value}
</when>
<when test='${object}.operator == "lt"'>
&lt; #{${object}.value}
</when>
<when test='${object}.operator == "ge"'>
&gt;= #{${object}.value}
</when>
<when test='${object}.operator == "le"'>
&lt;= #{${object}.value}
</when>
<when test='${object}.operator == "current user"'>
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
</when>
<otherwise>
= #{${object}.value}
</otherwise>
</choose>
</sql>
<sql id="combine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and atc.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and atc.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.createTime != null">
and atc.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.priority != null">
and atc.priority
<include refid="condition">
<property name="object" value="${condition}.priority"/>
</include>
</if>
<if test="${condition}.status != null">
and atc.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
<if test='${condition}.tags != null and ${objectKey}.operator == "like"'>
and atc.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
</if>
</sql>
<sql id="scenarioCombine">
<if test='${condition}.name != null and (${name} == null or ${name} == "")'>
and atc.name
<include refid="condition">
<property name="object" value="${condition}.name"/>
</include>
</if>
<if test="${condition}.updateTime != null">
and atc.update_time
<include refid="condition">
<property name="object" value="${condition}.updateTime"/>
</include>
</if>
<if test="${condition}.createTime != null">
and atc.create_time
<include refid="condition">
<property name="object" value="${condition}.createTime"/>
</include>
</if>
<if test="${condition}.priority != null">
and atc.level
<include refid="condition">
<property name="object" value="${condition}.priority"/>
</include>
</if>
<if test="${condition}.status != null">
and atc.status
<include refid="condition">
<property name="object" value="${condition}.status"/>
</include>
</if>
<if test='${condition}.tags != null and ${objectKey}.operator == "like"'>
and atc.tags
<include refid="condition">
<property name="object" value="${condition}.tags"/>
</include>
</if>
</sql>
<select id="relevanceScenarioList" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO"> <select id="relevanceScenarioList" resultType="io.metersphere.api.dto.automation.ApiScenarioDTO">
SELECT SELECT
atc.id, atc.project_id , atc.name , atc.num , atc.`level`, atc.step_total, atc.status atc.id, atc.project_id , atc.name , atc.num , atc.`level`, atc.step_total, atc.status, atc.tags
from api_scenario atc from api_scenario atc
left join test_case_test tct on atc.id = tct.test_id left join test_case_test tct on atc.id = tct.test_id
where tct.test_id is NULL and atc.status != 'Trash' where tct.test_id is NULL and atc.status != 'Trash'
@ -204,11 +330,18 @@
#{nodeId} #{nodeId}
</foreach> </foreach>
</if> </if>
<if test="request.combine != null">
<include refid="scenarioCombine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
<property name="objectKey" value="request.combine.tags"/>
</include>
</if>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select> </select>
<select id="relevanceLoadList" resultType="io.metersphere.dto.LoadTestDTO"> <select id="relevanceLoadList" resultType="io.metersphere.dto.LoadTestDTO">
SELECT SELECT
atc.id, atc.project_id , atc.name , atc.num , atc.status atc.id, atc.project_id , atc.name , atc.num , atc.status, atc.create_time, atc.update_time
from load_test atc from load_test atc
left join test_case_test tct on atc.id = tct.test_id left join test_case_test tct on atc.id = tct.test_id
where tct.test_id is NULL and atc.status != 'Trash' where tct.test_id is NULL and atc.status != 'Trash'
@ -219,6 +352,13 @@
and (atc.name like CONCAT('%', #{request.name},'%') and (atc.name like CONCAT('%', #{request.name},'%')
or atc.num like CONCAT('%', #{request.name},'%')) or atc.num like CONCAT('%', #{request.name},'%'))
</if> </if>
<if test="request.combine != null">
<include refid="scenarioCombine">
<property name="condition" value="request.combine"/>
<property name="name" value="request.name"/>
<property name="objectKey" value="request.combine.tags"/>
</include>
</if>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map">

View File

@ -503,4 +503,9 @@ export const TEST_PLAN_RELEVANCE_FUNC_CONFIGS = [NAME, API_TAGS, CREATE_TIME, UP
export const TEST_PLAN_RELEVANCE_API_DEFINITION_CONFIGS = [NAME, API_METHOD, API_PATH, API_TAGS, UPDATE_TIME, CREATE_TIME, CREATOR]; export const TEST_PLAN_RELEVANCE_API_DEFINITION_CONFIGS = [NAME, API_METHOD, API_PATH, API_TAGS, UPDATE_TIME, CREATE_TIME, CREATOR];
export const TEST_PLAN_RELEVANCE_API_CASE_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, UPDATE_TIME, CREATOR]; export const TEST_PLAN_RELEVANCE_API_CASE_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, UPDATE_TIME, CREATOR];
export const TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, API_SCENARIO_RESULT, CREATE_TIME, UPDATE_TIME, CREATOR]; export const TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, API_SCENARIO_RESULT, CREATE_TIME, UPDATE_TIME, CREATOR];
export const TEST_PLAN_RELEVANCE_LOAD_CASE= [NAME, UPDATE_TIME, CREATE_TIME, STATUS, CREATOR]; export const TEST_PLAN_RELEVANCE_LOAD_CASE= [NAME, STATUS, CREATE_TIME, UPDATE_TIME, CREATOR];
// 测试用例关联测试
export const TEST_CASE_RELEVANCE_API_CASE_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, CREATOR];
export const TEST_CASE_RELEVANCE_API_SCENARIO_CONFIGS = [NAME, API_CASE_PRIORITY, API_TAGS, CREATOR];
export const TEST_CASE_RELEVANCE_LOAD_CASE= [NAME, STATUS, CREATE_TIME, UPDATE_TIME, CREATOR];

View File

@ -3,7 +3,9 @@
<el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable" <el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable"
@keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/> @keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/>
<ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar"
v-if="condition.components !== undefined && condition.components.length > 0"
@search="initTable"/>
<ms-table v-loading="result.loading" :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize" <ms-table v-loading="result.loading" :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize"
:total="total" :total="total"
:showSelectAll="false" :showSelectAll="false"
@ -31,7 +33,12 @@
<priority-table-item :value="scope.row.priority"/> <priority-table-item :value="scope.row.priority"/>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column prop="tags" width="120px" :label="$t('commons.tag')">
<template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 0px; margin-right: 2px"></ms-tag>
</template>
</ms-table-column>
<!-- <ms-table-column--> <!-- <ms-table-column-->
<!-- prop="path"--> <!-- prop="path"-->
<!-- width="180px"--> <!-- width="180px"-->
@ -62,6 +69,9 @@ import {API_METHOD_COLOUR} from "@/business/components/api/definition/model/Json
import PriorityTableItem from "@/business/components/track/common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "@/business/components/track/common/tableItems/planview/PriorityTableItem";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar"; import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar";
import {TEST_CASE_RELEVANCE_API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import MsTag from "@/business/components/common/components/MsTag";
export default { export default {
name: "TestCaseRelateApiList", name: "TestCaseRelateApiList",
@ -70,11 +80,15 @@ export default {
MsTablePagination, MsTablePagination,
PriorityTableItem, PriorityTableItem,
MsTable, MsTable,
MsTableColumn MsTableColumn,
MsTableAdvSearchBar,
MsTag
}, },
data() { data() {
return { return {
condition: {}, condition: {
components: TEST_CASE_RELEVANCE_API_CASE_CONFIGS
},
selectCase: {}, selectCase: {},
result: {}, result: {},
priorityFilters: [ priorityFilters: [
@ -135,6 +149,11 @@ export default {
this.result = this.$post(this.buildPagePath(url), this.condition, response => { this.result = this.$post(this.buildPagePath(url), this.condition, response => {
this.total = response.data.itemCount; this.total = response.data.itemCount;
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
}); });
}, },
clear() { clear() {
@ -164,4 +183,9 @@ export default {
/*margin-bottom: 20px;*/ /*margin-bottom: 20px;*/
margin-right: 20px; margin-right: 20px;
} }
.adv-search-bar {
float: right;
margin-top: 5px;
margin-right: 10px;
}
</style> </style>

View File

@ -3,7 +3,9 @@
<el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable" <el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable"
@keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/> @keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/>
<ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar"
v-if="condition.components !== undefined && condition.components.length > 0"
@search="initTable"/>
<ms-table v-loading="result.loading" :data="tableData" :condition="condition" :page-size="pageSize" <ms-table v-loading="result.loading" :data="tableData" :condition="condition" :page-size="pageSize"
:total="total" :total="total"
:showSelectAll="false" :showSelectAll="false"
@ -30,6 +32,21 @@
<ms-performance-test-status :row="row"/> <ms-performance-test-status :row="row"/>
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column
prop="updateTime"
:label="$t('commons.update_time')"
min-width="150px">
<template v-slot:default="scope">
<span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template>
</ms-table-column>
<ms-table-column prop="createTime"
:label="$t('commons.create_time')"
min-width="150px">
<template v-slot:default="scope">
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
</template>
</ms-table-column >
</ms-table> </ms-table>
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
@ -48,6 +65,8 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar"; import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar";
import MsPerformanceTestStatus from "@/business/components/performance/test/PerformanceTestStatus"; import MsPerformanceTestStatus from "@/business/components/performance/test/PerformanceTestStatus";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import {TEST_CASE_RELEVANCE_LOAD_CASE} from "@/business/components/common/components/search/search-components";
export default { export default {
name: "TestCaseRelateLoadList", name: "TestCaseRelateLoadList",
@ -56,11 +75,14 @@ export default {
TableSelectCountBar, TableSelectCountBar,
MsTablePagination, MsTablePagination,
MsTable, MsTable,
MsTableColumn MsTableColumn,
MsTableAdvSearchBar,
}, },
data() { data() {
return { return {
condition: {}, condition: {
components: TEST_CASE_RELEVANCE_LOAD_CASE
},
result: {}, result: {},
screenHeight: '600px',// screenHeight: '600px',//
tableData: [], tableData: [],
@ -129,4 +151,9 @@ export default {
width: 300px; width: 300px;
margin-right: 20px; margin-right: 20px;
} }
.adv-search-bar {
float: right;
margin-top: 5px;
margin-right: 10px;
}
</style> </style>

View File

@ -3,7 +3,9 @@
<el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable" <el-input :placeholder="$t('commons.search_by_name_or_id')" @blur="initTable"
@keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/> @keyup.enter.native="initTable" class="search-input" size="small" v-model="condition.name"/>
<ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar"
v-if="condition.components !== undefined && condition.components.length > 0"
@search="initTable"/>
<ms-table v-loading="result.loading" :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize" <ms-table v-loading="result.loading" :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize"
:total="total" :total="total"
:showSelectAll="false" :showSelectAll="false"
@ -55,6 +57,14 @@
</template> </template>
</ms-table-column> </ms-table-column>
<ms-table-column prop="tags" width="120px" :label="$t('commons.tag')">
<template v-slot:default="scope">
<ms-tag v-for="(itemName,index) in scope.row.tags" :key="index" type="success" effect="plain"
:content="itemName" style="margin-left: 0px; margin-right: 2px"/>
<span></span>
</template>
</ms-table-column>
</ms-table> </ms-table>
<ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
@ -73,6 +83,9 @@ import PriorityTableItem from "@/business/components/track/common/tableItems/pla
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar"; import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar";
import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem"; import PlanStatusTableItem from "@/business/components/track/common/tableItems/plan/PlanStatusTableItem";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import MsTag from "@/business/components/common/components/MsTag";
import {TEST_CASE_RELEVANCE_API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
export default { export default {
name: "TestCaseRelateScenarioList", name: "TestCaseRelateScenarioList",
@ -82,11 +95,15 @@ export default {
MsTablePagination, MsTablePagination,
PriorityTableItem, PriorityTableItem,
MsTable, MsTable,
MsTableColumn MsTableColumn,
MsTableAdvSearchBar,
MsTag
}, },
data() { data() {
return { return {
condition: {}, condition: {
components: TEST_CASE_RELEVANCE_API_CASE_CONFIGS
},
result: {}, result: {},
priorityFilters: [ priorityFilters: [
{text: 'P0', value: 'P0'}, {text: 'P0', value: 'P0'},
@ -138,6 +155,11 @@ export default {
this.result = this.$post(this.buildPagePath(url), this.condition, response => { this.result = this.$post(this.buildPagePath(url), this.condition, response => {
this.total = response.data.itemCount; this.total = response.data.itemCount;
this.tableData = response.data.listObject; this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
}); });
}, },
clear() { clear() {
@ -166,4 +188,9 @@ export default {
width: 300px; width: 300px;
margin-right: 20px; margin-right: 20px;
} }
.adv-search-bar {
float: right;
margin-top: 5px;
margin-right: 10px;
}
</style> </style>