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}
</foreach>
</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">
<foreach collection="request.filters.entrySet()" index="key" item="values">
<if test="values != null and values.size() > 0">
@ -184,9 +191,128 @@
</if>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</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
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
left join test_case_test tct on atc.id = tct.test_id
where tct.test_id is NULL and atc.status != 'Trash'
@ -204,11 +330,18 @@
#{nodeId}
</foreach>
</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"/>
</select>
<select id="relevanceLoadList" resultType="io.metersphere.dto.LoadTestDTO">
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
left join test_case_test tct on atc.id = tct.test_id
where tct.test_id is NULL and atc.status != 'Trash'
@ -219,6 +352,13 @@
and (atc.name like CONCAT('%', #{request.name},'%')
or atc.num like CONCAT('%', #{request.name},'%'))
</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"/>
</select>
<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_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_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"
@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"
:total="total"
:showSelectAll="false"
@ -31,7 +33,12 @@
<priority-table-item :value="scope.row.priority"/>
</template>
</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-->
<!-- prop="path"-->
<!-- 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 MsTablePagination from "@/business/components/common/pagination/TablePagination";
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 {
name: "TestCaseRelateApiList",
@ -70,11 +80,15 @@ export default {
MsTablePagination,
PriorityTableItem,
MsTable,
MsTableColumn
MsTableColumn,
MsTableAdvSearchBar,
MsTag
},
data() {
return {
condition: {},
condition: {
components: TEST_CASE_RELEVANCE_API_CASE_CONFIGS
},
selectCase: {},
result: {},
priorityFilters: [
@ -135,6 +149,11 @@ export default {
this.result = this.$post(this.buildPagePath(url), this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
});
},
clear() {
@ -164,4 +183,9 @@ export default {
/*margin-bottom: 20px;*/
margin-right: 20px;
}
.adv-search-bar {
float: right;
margin-top: 5px;
margin-right: 10px;
}
</style>

View File

@ -3,7 +3,9 @@
<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"/>
<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"
:total="total"
:showSelectAll="false"
@ -30,6 +32,21 @@
<ms-performance-test-status :row="row"/>
</template>
</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-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 TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar";
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 {
name: "TestCaseRelateLoadList",
@ -56,11 +75,14 @@ export default {
TableSelectCountBar,
MsTablePagination,
MsTable,
MsTableColumn
MsTableColumn,
MsTableAdvSearchBar,
},
data() {
return {
condition: {},
condition: {
components: TEST_CASE_RELEVANCE_LOAD_CASE
},
result: {},
screenHeight: '600px',//
tableData: [],
@ -129,4 +151,9 @@ export default {
width: 300px;
margin-right: 20px;
}
.adv-search-bar {
float: right;
margin-top: 5px;
margin-right: 10px;
}
</style>

View File

@ -3,7 +3,9 @@
<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"/>
<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"
:total="total"
:showSelectAll="false"
@ -55,6 +57,14 @@
</template>
</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-pagination :change="initTable" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
@ -73,6 +83,9 @@ import PriorityTableItem from "@/business/components/track/common/tableItems/pla
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar";
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 {
name: "TestCaseRelateScenarioList",
@ -82,11 +95,15 @@ export default {
MsTablePagination,
PriorityTableItem,
MsTable,
MsTableColumn
MsTableColumn,
MsTableAdvSearchBar,
MsTag
},
data() {
return {
condition: {},
condition: {
components: TEST_CASE_RELEVANCE_API_CASE_CONFIGS
},
result: {},
priorityFilters: [
{text: 'P0', value: 'P0'},
@ -138,6 +155,11 @@ export default {
this.result = this.$post(this.buildPagePath(url), this.condition, response => {
this.total = response.data.itemCount;
this.tableData = response.data.listObject;
this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags);
}
});
});
},
clear() {
@ -166,4 +188,9 @@ export default {
width: 300px;
margin-right: 20px;
}
.adv-search-bar {
float: right;
margin-top: 5px;
margin-right: 10px;
}
</style>