feat: 测试计划-接口,性能与版本关联

This commit is contained in:
zhangdahai112 2022-01-12 13:41:10 +08:00
parent 0e8123cbb2
commit c55350f2ec
21 changed files with 356 additions and 37 deletions

View File

@ -33,8 +33,6 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
private String reviewId; private String reviewId;
private String deleteUserId; private String deleteUserId;
private long deleteTime; private long deleteTime;
private String refId;
private String versionId;
/** /**
* 检查待更新的近三天有更新的或者状态为error的 * 检查待更新的近三天有更新的或者状态为error的
*/ */

View File

@ -369,8 +369,35 @@
</select> </select>
<select id="listRelevance" resultType="io.metersphere.api.dto.definition.ApiDefinitionResult"> <select id="listRelevance" resultType="io.metersphere.api.dto.definition.ApiDefinitionResult">
select select
<include refid="io.metersphere.base.mapper.ApiDefinitionMapper.Base_Column_List"/> api_definition.version_id versionId,
project_version.name versionName,
api_definition.id,
api_definition.project_id,
api_definition.`name`,
api_definition.`method`,
api_definition.protocol,
api_definition.`path`,
api_definition.module_path,
api_definition.environment_id,
api_definition.schedule,
api_definition.`status`,
api_definition.module_id,
api_definition.user_id,
api_definition.create_time,
api_definition.update_time,
api_definition.num,
api_definition.tags,
api_definition.original_state,
api_definition.create_user,
api_definition.case_total,
api_definition.case_status,
api_definition.case_passing_rate,
api_definition.delete_time,
api_definition.delete_user_id,
api_definition.`order`,
api_definition.ref_id
from api_definition from api_definition
left join project_version on api_definition.project_id = project_version.project_id and api_definition.version_id = project_version.id
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
<include refid="combine"> <include refid="combine">
@ -425,6 +452,12 @@
#{value} #{value}
</foreach> </foreach>
</when> </when>
<when test="key=='version_id'">
and api_definition.version_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose> </choose>
</if> </if>
</foreach> </foreach>
@ -442,6 +475,32 @@
) )
) )
</if> </if>
<if test="request.versionId != null">
and api_definition.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and api_definition.ref_id = #{request.refId}
</if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND (
version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
WHERE ref_id = api_definition.ref_id
LIMIT 1)
OR
version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = api_definition.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(project_version.create_time) DESC
LIMIT 1)
)
</if>
</where> </where>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by

View File

@ -132,6 +132,12 @@
<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">
<choose> <choose>
<when test="key == 'id'">
AND load_test.id IN
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key == 'status'"> <when test="key == 'status'">
AND load_test.status IN AND load_test.status IN
<foreach collection="values" item="value" separator="," open="(" close=")"> <foreach collection="values" item="value" separator="," open="(" close=")">

View File

@ -94,7 +94,7 @@
project_version.id as versionId project_version.id as versionId
from test_case from test_case
left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId} left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId}
left join project_version on test_case.version_id = project_version.id left join project_version on test_case.version_id = project_version.id and test_casel.project_id = project_version.project_id
<include refid="notInQueryWhereCondition"/> <include refid="notInQueryWhereCondition"/>
and T2.case_id is null and T2.case_id is null
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/> <include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>

View File

@ -28,22 +28,49 @@
</select> </select>
<select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO"> <select id="list" resultType="io.metersphere.api.dto.definition.TestPlanApiCaseDTO">
select select
t.id, t.environment_id,(select name from api_test_environment where id = t.environment_id) as environment_name, t.create_time, t.update_time, t.id,
c.id as case_id, c.project_id, c.name, c.api_definition_id, c.priority, c.description, c.create_user_id, t.environment_id,
c.update_user_id, c.num, c.tags, t.create_user, (
a.module_id, a.path, a.protocol, t.status execResult, a.user_id SELECT
NAME
FROM
api_test_environment
WHERE
id = t.environment_id
) AS environment_name,
t.create_time,
t.update_time,
c.id AS case_id,
c.project_id,
c.name,
c.api_definition_id,
c.priority,
c.description,
c.create_user_id,
c.update_user_id,
c.num,
c.tags,
t.create_user,
a.module_id,
a.path,
a.protocol,
t.status execResult,
a.user_id,
a.version_id versionId,
project_version.name versionName
from from
test_plan_api_case t test_plan_api_case t
inner join inner join
api_test_case c api_test_case c
on t.api_case_id = c.id on t.api_case_id = c.id
<if test="request.planId != null and request.planId!=''"> <if test="request.planId != null and request.planId!=''">
and t.test_plan_id = #{request.planId} and t.test_plan_id = #{request.planId}
</if> </if>
inner join inner join
api_definition a api_definition a
on on
c.api_definition_id = a.id c.api_definition_id = a.id
left join project_version on a.version_id = project_version.id and a.project_id = project_version.project_id
<if test="request.protocol != null and request.protocol!=''"> <if test="request.protocol != null and request.protocol!=''">
and a.protocol = #{request.protocol} and a.protocol = #{request.protocol}
</if> </if>
@ -112,6 +139,32 @@
</if> </if>
</foreach> </foreach>
</if> </if>
<if test="request.versionId != null">
and a.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and a.ref_id = #{request.refId}
</if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND (
a.version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
WHERE ref_id = a.ref_id
LIMIT 1)
OR
a.version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = a.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(project_version.create_time) DESC
LIMIT 1)
)
</if>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">
@ -128,6 +181,7 @@
</choose> </choose>
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="selectIds" resultType="java.lang.String"> <select id="selectIds" resultType="java.lang.String">
select select

View File

@ -25,6 +25,32 @@
<if test="request.name != null and request.name != ''"> <if test="request.name != null and request.name != ''">
and (load_test.name like CONCAT('%', #{request.name},'%') OR load_test.num like CONCAT('%', #{request.name},'%')) and (load_test.name like CONCAT('%', #{request.name},'%') OR load_test.num like CONCAT('%', #{request.name},'%'))
</if> </if>
<if test="request.versionId != null">
and load_test.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and load_test.ref_id = #{request.refId}
</if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND (
load_test.version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
WHERE ref_id = load_test.ref_id
LIMIT 1)
OR
load_test.version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = load_test.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(project_version.create_time) DESC
LIMIT 1)
)
</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">
@ -35,6 +61,12 @@
#{value} #{value}
</foreach> </foreach>
</when> </when>
<when test="key=='version_id'">
and load_test.version_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose> </choose>
</if> </if>
</foreach> </foreach>
@ -135,11 +167,14 @@
tplc.status as caseStatus, tplc.status as caseStatus,
lt.name as caseName, lt.name as caseName,
tplc.load_report_id, tplc.load_report_id,
p.name as projectName p.name as projectName,
pv.name versionName,
lt.version_id versionId
from test_plan_load_case tplc from test_plan_load_case tplc
inner join load_test lt on tplc.load_case_id = lt.id inner join load_test lt on tplc.load_case_id = lt.id
left join user u on lt.user_id = u.id left join user u on lt.user_id = u.id
left join project p on lt.project_id = p.id left join project p on lt.project_id = p.id
left join project_version pv on lt.project_id = pv.project_id and lt.version_id = pv.id
<where> <where>
tplc.test_plan_id = #{request.testPlanId} tplc.test_plan_id = #{request.testPlanId}
<if test="request.caseIds != null and request.caseIds.size > 0"> <if test="request.caseIds != null and request.caseIds.size > 0">
@ -172,6 +207,32 @@
</foreach> </foreach>
</if> </if>
</where> </where>
<if test="request.versionId != null">
and lt.version_id = #{request.versionId}
</if>
<if test="request.refId != null">
and lt.ref_id = #{request.refId}
</if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND (
lt.version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
WHERE ref_id = lt.ref_id
LIMIT 1)
OR
lt.version_id = (SELECT project_version.id
FROM load_test tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = lt.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(project_version.create_time) DESC
LIMIT 1)
)
</if>
<if test="request.orders != null and request.orders.size() > 0"> <if test="request.orders != null and request.orders.size() > 0">
order by order by
<foreach collection="request.orders" separator="," item="order"> <foreach collection="request.orders" separator="," item="order">

View File

@ -662,14 +662,16 @@ public class PerformanceTestService {
} }
} }
public List<LoadTest> getLoadTestListByIds(List<String> ids) { public List<LoadTestDTO> getLoadTestListByIds(List<String> ids) {
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>(); return new ArrayList<>();
} }
LoadTestExample loadTestExample = new LoadTestExample(); QueryTestPlanRequest request = new QueryTestPlanRequest();
loadTestExample.createCriteria().andIdIn(ids); Map filters = new HashMap();
List<LoadTest> loadTests = loadTestMapper.selectByExample(loadTestExample); filters.put("id", ids);
return Optional.ofNullable(loadTests).orElse(new ArrayList<>()); request.setFilters(filters);
List<LoadTestDTO> loadTestDTOS = extLoadTestMapper.list(request);
return loadTestDTOS;
} }
private int getNextNum(String projectId) { private int getNextNum(String projectId) {

View File

@ -10,6 +10,7 @@ import io.metersphere.commons.constants.TriggerMode;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.request.RunTestPlanRequest;
import io.metersphere.track.dto.TestPlanLoadCaseDTO; import io.metersphere.track.dto.TestPlanLoadCaseDTO;
@ -31,7 +32,7 @@ public class TestPlanLoadCaseController {
private TestPlanLoadCaseService testPlanLoadCaseService; private TestPlanLoadCaseService testPlanLoadCaseService;
@PostMapping("/relevance/list/{goPage}/{pageSize}") @PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<LoadTest>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) { public Pager<List<LoadTestDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody LoadCaseRequest request) {
return testPlanLoadCaseService.relevanceList(request, goPage, pageSize); return testPlanLoadCaseService.relevanceList(request, goPage, pageSize);
} }

View File

@ -1,17 +1,18 @@
package io.metersphere.track.controller; package io.metersphere.track.controller;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.LoadTest;
import io.metersphere.base.domain.TestCaseReviewLoad; import io.metersphere.base.domain.TestCaseReviewLoad;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.dto.TestReviewLoadCaseDTO; import io.metersphere.dto.TestReviewLoadCaseDTO;
import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.request.RunTestPlanRequest;
import io.metersphere.track.request.testplan.LoadCaseReportRequest; import io.metersphere.track.request.testplan.LoadCaseReportRequest;
import io.metersphere.track.request.testplan.LoadCaseRequest;
import io.metersphere.track.request.testreview.TestReviewRequest; import io.metersphere.track.request.testreview.TestReviewRequest;
import io.metersphere.track.service.TestCaseReviewLoadService; import io.metersphere.track.service.TestCaseReviewLoadService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -22,7 +23,7 @@ public class TestReviewLoadCaseController {
private TestCaseReviewLoadService testCaseReviewLoadService; private TestCaseReviewLoadService testCaseReviewLoadService;
@PostMapping("/relevance/list/{goPage}/{pageSize}") @PostMapping("/relevance/list/{goPage}/{pageSize}")
public Pager<List<LoadTest>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRequest request) { public Pager<List<LoadTestDTO>> relevanceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestReviewRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, testCaseReviewLoadService.relevanceList(request)); return PageUtils.setPageInfo(page, testCaseReviewLoadService.relevanceList(request));
} }

View File

@ -25,6 +25,8 @@ public class TestPlanLoadCaseDTO extends TestPlanLoadCaseWithBLOBs {
private String name; private String name;
private ResponseDTO response; private ResponseDTO response;
private String reportId; private String reportId;
private String versionId;
private String versionName;
@Getter @Getter
@Setter @Setter

View File

@ -19,7 +19,8 @@ public class LoadCaseRequest extends TestPlanLoadCase {
private Map<String, List<String>> filters; private Map<String, List<String>> filters;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, Object> combine; private Map<String, Object> combine;
private String versionId;
private String refId;
// 测试计划是否允许重复 // 测试计划是否允许重复
private boolean repeatCase; private boolean repeatCase;
} }

View File

@ -6,6 +6,7 @@ import io.metersphere.base.mapper.ext.ExtTestCaseReviewLoadMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper;
import io.metersphere.commons.constants.TestPlanStatus; import io.metersphere.commons.constants.TestPlanStatus;
import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.OrderRequest;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.dto.TestReviewLoadCaseDTO; import io.metersphere.dto.TestReviewLoadCaseDTO;
import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.request.RunTestPlanRequest;
import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.performance.service.PerformanceTestService;
@ -46,7 +47,7 @@ public class TestCaseReviewLoadService {
@Resource @Resource
private LoadTestMapper loadTestMapper; private LoadTestMapper loadTestMapper;
public List<LoadTest> relevanceList(TestReviewRequest request) { public List<LoadTestDTO> relevanceList(TestReviewRequest request) {
List<String> ids = extTestCaseReviewLoadMapper.selectIdsNotInPlan(request.getProjectId(), request.getTestCaseReviewId()); List<String> ids = extTestCaseReviewLoadMapper.selectIdsNotInPlan(request.getProjectId(), request.getTestCaseReviewId());
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>(); return new ArrayList<>();

View File

@ -19,6 +19,7 @@ import io.metersphere.commons.utils.*;
import io.metersphere.constants.RunModeConstants; import io.metersphere.constants.RunModeConstants;
import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.ResetOrderRequest; import io.metersphere.controller.request.ResetOrderRequest;
import io.metersphere.dto.LoadTestDTO;
import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.request.RunTestPlanRequest;
import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.performance.service.PerformanceTestService;
@ -69,7 +70,7 @@ public class TestPlanLoadCaseService {
@Lazy @Lazy
private TestPlanService testPlanService; private TestPlanService testPlanService;
public Pager<List<LoadTest>> relevanceList(LoadCaseRequest request, int goPage, int pageSize) { public Pager<List<LoadTestDTO>> relevanceList(LoadCaseRequest request, int goPage, int pageSize) {
List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder(request.getOrders()); List<OrderRequest> orders = ServiceUtils.getDefaultSortOrder(request.getOrders());
orders.forEach(i -> i.setPrefix("load_test")); orders.forEach(i -> i.setPrefix("load_test"));
request.setOrders(orders); request.setOrders(orders);
@ -78,7 +79,7 @@ public class TestPlanLoadCaseService {
} }
List<String> ids = extTestPlanLoadCaseMapper.selectIdsNotInPlan(request); List<String> ids = extTestPlanLoadCaseMapper.selectIdsNotInPlan(request);
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return PageUtils.setPageInfo(PageHelper.startPage(goPage, pageSize, true), new ArrayList<>()); return PageUtils.setPageInfo(PageHelper.startPage(goPage, pageSize, true), new ArrayList <>());
} }
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, performanceTestService.getLoadTestListByIds(ids)); return PageUtils.setPageInfo(page, performanceTestService.getLoadTestListByIds(ids));

View File

@ -120,7 +120,6 @@ export default {
this.$emit('isApiListEnableChange', data); this.$emit('isApiListEnableChange', data);
}, },
initTable(projectId) { initTable(projectId) {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) { if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]}; this.condition.filters = {status: ["Trash"]};

View File

@ -25,6 +25,7 @@
:project-id="projectId" :project-id="projectId"
:is-test-plan="true" :is-test-plan="true"
:plan-id="planId" :plan-id="planId"
:versionFilters="versionFilters"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
ref="apiList"/> ref="apiList"/>
@ -49,6 +50,7 @@
import MsApiModule from "../../../../../api/definition/components/module/ApiModule"; import MsApiModule from "../../../../../api/definition/components/module/ApiModule";
import RelevanceApiList from "../../../../../api/automation/scenario/api/RelevanceApiList"; import RelevanceApiList from "../../../../../api/automation/scenario/api/RelevanceApiList";
import RelevanceCaseList from "../../../../../api/automation/scenario/api/RelevanceCaseList"; import RelevanceCaseList from "../../../../../api/automation/scenario/api/RelevanceCaseList";
import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
export default { export default {
name: "TestCaseApiRelevance", name: "TestCaseApiRelevance",
@ -69,7 +71,8 @@
isApiListEnable: true, isApiListEnable: true,
condition: {}, condition: {},
currentRow: {}, currentRow: {},
projectId: "" projectId: "",
versionFilters: [],
}; };
}, },
props: { props: {
@ -82,6 +85,9 @@
this.condition.planId = this.planId; this.condition.planId = this.planId;
}, },
}, },
mounted() {
this.getVersionOptions();
},
methods: { methods: {
open() { open() {
this.init(); this.init();
@ -182,6 +188,16 @@
this.$refs.baseRelevance.close(); this.$refs.baseRelevance.close();
}); });
}, },
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionOptions = response.data;
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
} }
} }
</script> </script>

View File

@ -6,6 +6,7 @@
:project-id="getProjectId()" :project-id="getProjectId()"
:condition="condition" :condition="condition"
:plan-id="planId" :plan-id="planId"
@changeVersion="changeVersion"
@refresh="initTable" @refresh="initTable"
@relevanceCase="$emit('relevanceCase')" @relevanceCase="$emit('relevanceCase')"
@setEnvironment="setEnvironment" @setEnvironment="setEnvironment"
@ -39,6 +40,18 @@
<ms-table-column :field="item" :fields-width="fieldsWidth" prop="name" sortable min-width="120" <ms-table-column :field="item" :fields-width="fieldsWidth" prop="name" sortable min-width="120"
:label="$t('test_track.case.name')"/> :label="$t('test_track.case.name')"/>
<ms-table-column
prop="versionId"
:field="item"
:filters="versionFilters"
:fields-width="fieldsWidth"
:label="$t('commons.version')"
min-width="120px">
<template v-slot:default="scope">
<span>{{ scope.row.versionName }}</span>
</template>
</ms-table-column>
<ms-table-column <ms-table-column
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
@ -166,7 +179,7 @@ import MsContainer from "../../../../../common/components/MsContainer";
import MsBottomContainer from "../../../../../api/definition/components/BottomContainer"; import MsBottomContainer from "../../../../../api/definition/components/BottomContainer";
import BatchEdit from "@/business/components/track/case/components/BatchEdit"; import BatchEdit from "@/business/components/track/case/components/BatchEdit";
import {API_METHOD_COLOUR, CASE_PRIORITY, RESULT_MAP} from "../../../../../api/definition/model/JsonData"; import {API_METHOD_COLOUR, CASE_PRIORITY, RESULT_MAP} from "../../../../../api/definition/model/JsonData";
import {getCurrentProjectID, strMapToObj} from "@/common/js/utils"; import {getCurrentProjectID, hasLicense, strMapToObj} from "@/common/js/utils";
import ApiListContainer from "../../../../../api/definition/components/list/ApiListContainer"; import ApiListContainer from "../../../../../api/definition/components/list/ApiListContainer";
import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem"; import PriorityTableItem from "../../../../common/tableItems/planview/PriorityTableItem";
import {getUUID} from "../../../../../../../common/js/utils"; import {getUUID} from "../../../../../../../common/js/utils";
@ -212,6 +225,9 @@ export default {
MsBottomContainer, MsBottomContainer,
MsTaskCenter MsTaskCenter
}, },
mounted(){
this.getVersionOptions();
},
data() { data() {
return { return {
type: TEST_PLAN_API_CASE, type: TEST_PLAN_API_CASE,
@ -275,7 +291,8 @@ export default {
rowLoading: "", rowLoading: "",
userFilters: [], userFilters: [],
projectIds: [], projectIds: [],
projectList: [] projectList: [],
versionFilters: [],
}; };
}, },
props: { props: {
@ -627,6 +644,24 @@ export default {
} }
}); });
}, },
changeVersion(currentVersion) {
if (currentVersion == "") {
this.condition.versionId = null;
} else {
this.condition.versionId = currentVersion;
}
this.initTable();
},
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionOptions= response.data;
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
}, },
}; };
</script> </script>

View File

@ -11,6 +11,7 @@
<ms-table-button v-permission="['PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL']" icon="el-icon-connection" <ms-table-button v-permission="['PROJECT_TRACK_PLAN:READ+RELEVANCE_OR_CANCEL']" icon="el-icon-connection"
:content="$t('test_track.plan_view.relevance_test_case')" :content="$t('test_track.plan_view.relevance_test_case')"
@click="$emit('relevanceCase')"/> @click="$emit('relevanceCase')"/>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion"/>
</template> </template>
</ms-table-header> </ms-table-header>
@ -20,10 +21,12 @@
import MsTableHeader from "../../../../../common/components/MsTableHeader"; import MsTableHeader from "../../../../../common/components/MsTableHeader";
import MsTableButton from "../../../../../common/components/MsTableButton"; import MsTableButton from "../../../../../common/components/MsTableButton";
import MsEnvironmentSelect from "../../../../../api/definition/components/case/MsEnvironmentSelect"; import MsEnvironmentSelect from "../../../../../api/definition/components/case/MsEnvironmentSelect";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "TestPlanCaseListHeader", name: "TestPlanCaseListHeader",
components: {MsEnvironmentSelect, MsTableButton, MsTableHeader}, components: {MsEnvironmentSelect, MsTableButton, MsTableHeader, 'VersionSelect': VersionSelect.default},
props: ['condition', 'projectId', 'isReadOnly', 'planId'], props: ['condition', 'projectId', 'isReadOnly', 'planId'],
methods: { methods: {
setEnvironment(data) { setEnvironment(data) {
@ -35,6 +38,9 @@ export default {
this.$emit('setEnvironment', data); this.$emit('setEnvironment', data);
}); });
} }
},
changeVersion(currentVersion) {
this.$emit('changeVersion', currentVersion);
} }
} }
}; };
@ -46,4 +52,7 @@ export default {
margin-right: 10px; margin-right: 10px;
} }
.version-select {
padding-left: 10px;
}
</style> </style>

View File

@ -42,6 +42,18 @@
:label="$t('commons.name')" :label="$t('commons.name')"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
<el-table-column
prop="versionId"
:column-key="'versionId'"
:filters="versionFilters"
:label="$t('commons.version')"
min-width="120px">
<template v-slot:default="scope">
<span>{{ scope.row.versionName }}</span>
</template>
</el-table-column>
<el-table-column <el-table-column
prop="status" prop="status"
column-key="status" column-key="status"
@ -88,6 +100,7 @@ import MsPerformanceTestStatus from "@/business/components/performance/test/Perf
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import {_filter} from "@/common/js/tableUtils"; import {_filter} from "@/common/js/tableUtils";
import {TEST_PLAN_RELEVANCE_LOAD_CASE} from "@/business/components/common/components/search/search-components"; import {TEST_PLAN_RELEVANCE_LOAD_CASE} from "@/business/components/common/components/search/search-components";
import {hasLicense, getCurrentProjectID} from "@/common/js/utils";
export default { export default {
name: "TestCaseLoadRelevance", name: "TestCaseLoadRelevance",
@ -126,7 +139,8 @@ export default {
{text: 'Reporting', value: 'Reporting'}, {text: 'Reporting', value: 'Reporting'},
{text: 'Completed', value: 'Completed'}, {text: 'Completed', value: 'Completed'},
{text: 'Error', value: 'Error'} {text: 'Error', value: 'Error'}
] ],
versionFilters: []
}; };
}, },
props: { props: {
@ -145,6 +159,9 @@ export default {
this.condition.reviewId = this.reviewId; this.condition.reviewId = this.reviewId;
}, },
}, },
mounted(){
this.getVersionOptions();
},
methods: { methods: {
filter(filters) { filter(filters) {
_filter(filters, this.condition); _filter(filters, this.condition);
@ -275,7 +292,17 @@ export default {
} }
this.treeNodes = []; this.treeNodes = [];
this.selectNodeIds = []; this.selectNodeIds = [];
} },
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionOptions = response.data;
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
} }
} }
</script> </script>

View File

@ -5,6 +5,8 @@
<test-plan-load-case-list-header <test-plan-load-case-list-header
:condition="condition" :condition="condition"
:plan-id="planId" :plan-id="planId"
:isShowVersion="true"
@changeVersion="changeVersion"
@refresh="initTable" @refresh="initTable"
@relevanceCase="$emit('relevanceCase')"/> @relevanceCase="$emit('relevanceCase')"/>
</template> </template>
@ -43,6 +45,16 @@
min-width="120" min-width="120"
sortable> sortable>
</ms-table-column> </ms-table-column>
<ms-table-column
prop="versionId"
:filters="versionFilters"
:fields-width="fieldsWidth"
:label="$t('commons.version')"
min-width="120px">
<template v-slot:default="scope">
<span>{{ scope.row.versionName }}</span>
</template>
</ms-table-column>
<ms-table-column <ms-table-column
:field="item" :field="item"
:fields-width="fieldsWidth" :fields-width="fieldsWidth"
@ -129,7 +141,7 @@ import {
buildBatchParam, getCustomTableHeader, getCustomTableWidth buildBatchParam, getCustomTableHeader, getCustomTableWidth
} from "@/common/js/tableUtils"; } from "@/common/js/tableUtils";
import {TEST_PLAN_LOAD_CASE} from "@/common/js/constants"; import {TEST_PLAN_LOAD_CASE} from "@/common/js/constants";
import {getCurrentProjectID, getCurrentUser, getCurrentUserId} from "@/common/js/utils"; import {getCurrentProjectID, getCurrentUser, getCurrentUserId, hasLicense} from "@/common/js/utils";
import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate";
import MsPlanRunMode from "../../../common/PlanRunMode"; import MsPlanRunMode from "../../../common/PlanRunMode";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
@ -211,7 +223,8 @@ export default {
], ],
reportId: '', reportId: '',
loading: false, loading: false,
statusScheduler: null statusScheduler: null,
versionFilters: []
} }
}, },
props: { props: {
@ -242,6 +255,9 @@ export default {
this.initTable(); this.initTable();
} }
}, },
mounted() {
this.getVersionOptions();
},
methods: { methods: {
orderBySelectRows(rows){ orderBySelectRows(rows){
let selectIds = Array.from(rows).map(row => row.id); let selectIds = Array.from(rows).map(row => row.id);
@ -450,6 +466,24 @@ export default {
clearInterval(this.refreshScheduler); clearInterval(this.refreshScheduler);
} }
}, },
changeVersion(currentVersion) {
if (currentVersion == "") {
this.condition.versionId = null;
} else {
this.condition.versionId = currentVersion;
}
this.initTable();
},
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionOptions= response.data;
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
}, },
beforeDestroy() { beforeDestroy() {
this.cancelRefresh(); this.cancelRefresh();

View File

@ -1,5 +1,7 @@
<template> <template>
<ms-table-header <ms-table-header
:isShowVersion="isShowVersion"
@changeVersion="changeVersion"
:condition="condition" :condition="condition"
@search="$emit('refresh')" @search="$emit('refresh')"
:show-create="false" :show-create="false"
@ -19,11 +21,20 @@
<script> <script>
import MsTableButton from "@/business/components/common/components/MsTableButton"; import MsTableButton from "@/business/components/common/components/MsTableButton";
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "TestPlanLoadCaseListHeader", name: "TestPlanLoadCaseListHeader",
components: {MsTableButton, MsTableHeader}, components: {
props: ['condition'], MsTableButton, MsTableHeader, 'VersionSelect': VersionSelect.default,
},
props: ['condition', 'isShowVersion'],
methods: {
changeVersion(currentVersion) {
this.$emit("changeVersion", currentVersion)
}
}
}; };
</script> </script>

View File

@ -161,6 +161,7 @@ export let CUSTOM_TABLE_HEADER = {
TEST_PLAN_LOAD_CASE: [ TEST_PLAN_LOAD_CASE: [
{id: 'num', key: '1', label: 'commons.id'}, {id: 'num', key: '1', label: 'commons.id'},
{id: 'caseName', key: '2', label: 'commons.name'}, {id: 'caseName', key: '2', label: 'commons.name'},
{id: 'versionId', key: '9', label: 'project.version.name', xpack: true},
{id: 'projectName', key: '3', label: 'load_test.project_name'}, {id: 'projectName', key: '3', label: 'load_test.project_name'},
{id: 'userName', key: '4', label: 'load_test.user_name'}, {id: 'userName', key: '4', label: 'load_test.user_name'},
{id: 'createTime', key: '5', label: 'commons.create_time'}, {id: 'createTime', key: '5', label: 'commons.create_time'},