refactor(测试评审): 测试评审关联用例时数量显示在上面

This commit is contained in:
CaptainB 2022-04-11 17:52:31 +08:00 committed by 刘瑞斌
parent 3d0de7626e
commit b1184d237f
13 changed files with 621 additions and 368 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.FileMetadata; import io.metersphere.base.domain.FileMetadata;
import io.metersphere.base.domain.LoadTest; import io.metersphere.base.domain.LoadTest;
import io.metersphere.controller.request.BaseQueryRequest;
import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.LoadTestDTO;
import io.metersphere.performance.request.QueryProjectFileRequest; import io.metersphere.performance.request.QueryProjectFileRequest;
import io.metersphere.performance.request.QueryTestPlanRequest; import io.metersphere.performance.request.QueryTestPlanRequest;
@ -39,4 +40,6 @@ public interface ExtLoadTestMapper {
List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId); List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId);
List<FileMetadata> getFileMetadataByIds(@Param("testId") String testId); List<FileMetadata> getFileMetadataByIds(@Param("testId") String testId);
List<String> selectIds(@Param("request") BaseQueryRequest request);
} }

View File

@ -225,6 +225,53 @@
</where> </where>
</select> </select>
<sql id="filter">
<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">
<choose>
<when test="key=='status'">
and load_test.status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='method'">
and load_test.method in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='user_id'">
and load_test.user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='user_name'">
and load_test.user_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='case_status'">
and load_test.case_status in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
<when test="key=='version_id'">
and load_test.version_id in
<foreach collection="values" item="value" separator="," open="(" close=")">
#{value}
</foreach>
</when>
</choose>
</if>
</foreach>
</if>
</sql>
<sql id="queryWhereCondition"> <sql id="queryWhereCondition">
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
@ -234,6 +281,37 @@
<property name="objectKey" value="request.combine.tags"/> <property name="objectKey" value="request.combine.tags"/>
</include> </include>
</if> </if>
<if test="request.name != null">
and (load_test.name like CONCAT('%', #{request.name},'%')
or load_test.num like CONCAT('%', #{request.name},'%')
</if>
<if test="request.notEqStatus != null">
and (load_test.status is null or load_test.status != #{request.notEqStatus})
</if>
<if test="request.id != null">
AND load_test.id = #{request.id}
</if>
<if test="request.userId != null">
AND load_test.user_id = #{request.userId}
</if>
<if test="request.createTime >0">
AND load_test.create_time >= #{request.createTime}
</if>
<if test="request.notInIds != null and request.notInIds.size() > 0">
and load_test.id not in
<foreach collection="request.notInIds" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</if>
<if test="request.projectId != null">
AND load_test.project_id = #{request.projectId}
</if>
<include refid="filter"/>
<include refid="queryVersionCondition">
<property name="versionTable" value="load_test"/>
</include>
</where> </where>
</sql> </sql>
@ -349,4 +427,11 @@
WHERE test_id = #{testId} WHERE test_id = #{testId}
ORDER BY sort ORDER BY sort
</select> </select>
<select id="selectIds" resultType="java.lang.String">
select load_test.id
from load_test
<include refid="queryWhereCondition"/>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
</mapper> </mapper>

View File

@ -22,6 +22,7 @@ import io.metersphere.dto.ScheduleDao;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.notice.annotation.SendNotice; import io.metersphere.notice.annotation.SendNotice;
import io.metersphere.performance.dto.LoadModuleDTO; import io.metersphere.performance.dto.LoadModuleDTO;
import io.metersphere.performance.dto.LoadTestBatchRequest;
import io.metersphere.performance.dto.LoadTestExportJmx; import io.metersphere.performance.dto.LoadTestExportJmx;
import io.metersphere.performance.request.*; import io.metersphere.performance.request.*;
import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.performance.service.PerformanceTestService;
@ -69,6 +70,11 @@ public class PerformanceTestController {
return performanceTestService.getLoadTestByProjectId(projectId); return performanceTestService.getLoadTestByProjectId(projectId);
} }
@PostMapping("/list/batch")
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ")
public List<LoadTestDTO> listBatch(@RequestBody LoadTestBatchRequest request) {
return performanceTestService.listBatch(request);
}
@GetMapping("/state/get/{testId}") @GetMapping("/state/get/{testId}")
@RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ") @RequiresPermissions("PROJECT_PERFORMANCE_TEST:READ")

View File

@ -0,0 +1,19 @@
package io.metersphere.performance.dto;
import io.metersphere.base.domain.LoadTestWithBLOBs;
import io.metersphere.controller.request.OrderRequest;
import lombok.Data;
import java.util.List;
@Data
public class LoadTestBatchRequest extends LoadTestWithBLOBs {
private List<String> ids;
private String name;
private List<OrderRequest> orders;
private String projectId;
private String moduleId;
private String protocol;
private LoadTestRequest condition;
}

View File

@ -0,0 +1,42 @@
package io.metersphere.performance.dto;
import io.metersphere.controller.request.BaseQueryRequest;
import lombok.Data;
@Data
public class LoadTestRequest extends BaseQueryRequest {
private String id;
private String projectId;
private String name;
private String description;
private Long createTime;
private Long updateTime;
private String status;
private String testResourcePoolId;
private String userId;
private Integer num;
private String createUser;
private Integer scenarioVersion;
private String scenarioId;
private Long order;
private String refId;
private String versionId;
private Boolean latest;
}

View File

@ -35,6 +35,7 @@ import io.metersphere.log.vo.performance.PerformanceReference;
import io.metersphere.performance.base.GranularityData; import io.metersphere.performance.base.GranularityData;
import io.metersphere.performance.base.VumProcessedStatus; import io.metersphere.performance.base.VumProcessedStatus;
import io.metersphere.performance.dto.LoadModuleDTO; import io.metersphere.performance.dto.LoadModuleDTO;
import io.metersphere.performance.dto.LoadTestBatchRequest;
import io.metersphere.performance.dto.LoadTestExportJmx; import io.metersphere.performance.dto.LoadTestExportJmx;
import io.metersphere.performance.engine.Engine; import io.metersphere.performance.engine.Engine;
import io.metersphere.performance.engine.EngineFactory; import io.metersphere.performance.engine.EngineFactory;
@ -1124,4 +1125,17 @@ public class PerformanceTestService {
} }
public List<LoadTestDTO> listBatch(LoadTestBatchRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extLoadTestMapper.selectIds(query));
if (org.apache.commons.collections.CollectionUtils.isEmpty(request.getIds())) {
return new ArrayList<>();
}
QueryTestPlanRequest request2 = new QueryTestPlanRequest();
Map<String, List<String>> param = new HashMap<>();
param.put("id", request.getIds());
request2.setFilters(param);
return this.list(request2);
}
} }

View File

@ -13,17 +13,28 @@
ref="envPopover" class="env-popover"/> ref="envPopover" class="env-popover"/>
<el-input :placeholder="$t('api_test.definition.request.select_case')" @blur="search" <el-input :placeholder="$t('api_test.definition.request.select_case')" @blur="search"
@keyup.enter.native="search" class="search-input" size="small" v-model="condition.name"/> @keyup.enter.native="search" class="search-input" size="small" v-model="condition.name"/>
<ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar" <ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar"
v-if="condition.components !== undefined && condition.components.length > 0" v-if="condition.components !== undefined && condition.components.length > 0"
@search="search"/> @search="search"/>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20" <version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20"
class="search-input"/> class="search-input"/>
<el-table ref="scenarioTable" border :data="tableData" class="adjust-table" @select-all="handleSelectAll" @select="handleSelect" @filter-change="filter"> <ms-table ref="scenarioTable"
<el-table-column type="selection"/> v-loading="result.loading"
:data="tableData"
:condition="condition"
:page-size="pageSize"
:total="total"
:remember-order="true"
row-key="id"
:row-order-group-id="projectId"
@refresh="search"
:disable-header-config="true"
:show-select-all="false"
@selectCountChange="selectCountChange">
<el-table-column v-if="!customNum" prop="num" label="ID" <el-table-column v-if="!customNum" prop="num" label="ID"
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
@ -52,7 +63,8 @@
</el-table-column> </el-table-column>
<el-table-column prop="tagNames" :label="$t('api_test.automation.tag')" min-width="120"> <el-table-column prop="tagNames" :label="$t('api_test.automation.tag')" min-width="120">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-tag v-for="itemName in scope.row.tags" :key="itemName" type="success" effect="plain" :content="itemName" style="margin-left: 0px; margin-right: 2px"/> <ms-tag v-for="itemName in scope.row.tags" :key="itemName" type="success" effect="plain" :content="itemName"
style="margin-left: 0px; margin-right: 2px"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="userId" :label="$t('api_test.automation.creator')" show-overflow-tooltip/> <el-table-column prop="userId" :label="$t('api_test.automation.creator')" show-overflow-tooltip/>
@ -64,13 +76,17 @@
<el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" show-overflow-tooltip/> <el-table-column prop="stepTotal" :label="$t('api_test.automation.step')" show-overflow-tooltip/>
<el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')"> <el-table-column prop="lastResult" :label="$t('api_test.automation.last_result')">
<template v-slot:default="{row}"> <template v-slot:default="{row}">
<el-link type="success" @click="showReport(row)" v-if="row.lastResult === 'Success'">{{ $t('api_test.automation.success') }}</el-link> <el-link type="success" @click="showReport(row)" v-if="row.lastResult === 'Success'">
<el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'Fail'">{{ $t('api_test.automation.fail') }}</el-link> {{ $t('api_test.automation.success') }}
</el-link>
<el-link type="danger" @click="showReport(row)" v-if="row.lastResult === 'Fail'">
{{ $t('api_test.automation.fail') }}
</el-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')" <el-table-column prop="passRate" :label="$t('api_test.automation.passing_rate')"
show-overflow-tooltip/> show-overflow-tooltip/>
</el-table> </ms-table>
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize" <ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/> :total="total"/>
</el-card> </el-card>
@ -79,221 +95,222 @@
</template> </template>
<script> <script>
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn"; import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
import MsTag from "../../../../../common/components/MsTag"; import MsTag from "../../../../../common/components/MsTag";
import MsApiReportDetail from "../../../../../api/automation/report/ApiReportDetail"; import MsApiReportDetail from "../../../../../api/automation/report/ApiReportDetail";
import MsTableMoreBtn from "../../../../../api/automation/scenario/TableMoreBtn"; import MsTableMoreBtn from "../../../../../api/automation/scenario/TableMoreBtn";
import MsTestPlanList from "../../../../../api/automation/scenario/testplan/TestPlanList"; import MsTestPlanList from "../../../../../api/automation/scenario/testplan/TestPlanList";
import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader"; import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader";
import {_handleSelect, _handleSelectAll} from "../../../../../../../common/js/tableUtils"; import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; import PriorityTableItem from "@/business/components/track/common/tableItems/planview/PriorityTableItem";
import PriorityTableItem from "@/business/components/track/common/tableItems/planview/PriorityTableItem"; import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar";
import MsTableAdvSearchBar from "@/business/components/common/components/search/MsTableAdvSearchBar"; import {
import {TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS} from "@/business/components/common/components/search/search-components"; TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS
import {ENV_TYPE} from "@/common/js/constants"; } from "@/business/components/common/components/search/search-components";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); import {ENV_TYPE} from "@/common/js/constants";
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
import {hasLicense, getCurrentProjectID} from "@/common/js/utils"; import MsTable from "@/business/components/common/components/table/MsTable";
export default { const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
name: "RelevanceScenarioList", const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
components: {
PriorityTableItem, export default {
EnvPopover, name: "RelevanceScenarioList",
TestPlanScenarioListHeader, components: {
MsTablePagination, MsTable,
MsTableMoreBtn, PriorityTableItem,
ShowMoreBtn, EnvPopover,
MsTableHeader, TestPlanScenarioListHeader,
MsTag, MsTablePagination,
MsApiReportDetail, MsTableMoreBtn,
MsTestPlanList, ShowMoreBtn,
MsTableAdvSearchBar, MsTableHeader,
'VersionSelect': VersionSelect.default, MsTag,
MsApiReportDetail,
MsTestPlanList,
MsTableAdvSearchBar,
'VersionSelect': VersionSelect.default,
},
props: {
referenced: {
type: Boolean,
default: false,
}, },
props: { selectNodeIds: Array,
referenced: { projectId: String,
type: Boolean, planId: String,
default: false, versionEnable: Boolean,
},
data() {
return {
result: {},
showConfigButtonWithOutPermission: false,
condition: {
components: TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS
}, },
selectNodeIds: Array, currentScenario: {},
projectId: String, schedule: {},
planId: String, selectAll: false,
versionEnable: Boolean, tableData: [],
currentPage: 1,
pageSize: 10,
total: 0,
reportId: "",
infoDb: false,
selectRows: new Set(),
projectEnvMap: new Map(),
projectList: [],
projectIds: new Set(),
map: new Map(),
customNum: false,
environmentType: ENV_TYPE.JSON,
envGroupId: "",
versionFilters: [],
};
},
computed: {
ENV_TYPE() {
return ENV_TYPE;
}
},
watch: {
selectNodeIds() {
this.search();
}, },
data() { projectId() {
return { this.search();
result: {}, },
showConfigButtonWithOutPermission:false, },
condition: { created() {
components: TEST_PLAN_RELEVANCE_API_SCENARIO_CONFIGS this.getWsProjects();
}, this.getVersionOptions();
currentScenario: {}, },
schedule: {}, methods: {
selectAll: false, search() {
tableData: [], this.projectEnvMap.clear();
currentPage: 1, this.projectIds.clear();
pageSize: 10, if (!this.projectId) {
total: 0, return;
reportId: "",
infoDb: false,
selectRows: new Set(),
projectEnvMap: new Map(),
projectList: [],
projectIds: new Set(),
map: new Map(),
customNum: false,
environmentType: ENV_TYPE.JSON,
envGroupId: "",
versionFilters: [],
} }
}, this.getProject(this.projectId);
computed: { this.selectRows = new Set();
ENV_TYPE() { this.loading = true;
return ENV_TYPE; if (this.condition.filters) {
this.condition.filters.status = ["Prepare", "Underway", "Completed"];
} else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
} }
},
watch: {
selectNodeIds() {
this.search();
},
projectId() {
this.search();
},
},
created() {
this.getWsProjects();
this.getVersionOptions();
},
methods: {
search() {
this.projectEnvMap.clear();
this.projectIds.clear();
if (!this.projectId) {
return;
}
this.getProject(this.projectId);
this.selectRows = new Set();
this.loading = true;
if (this.condition.filters) {
this.condition.filters.status = ["Prepare", "Underway", "Completed"];
} else {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
}
this.condition.moduleIds = this.selectNodeIds; this.condition.moduleIds = this.selectNodeIds;
if (this.projectId != null) { if (this.projectId != null) {
this.condition.projectId = this.projectId; this.condition.projectId = this.projectId;
} }
if (this.planId != null) { if (this.planId != null) {
this.condition.planId = this.planId; this.condition.planId = this.planId;
} }
let url = "/test/plan/scenario/case/relevance/list/" + this.currentPage + "/" + this.pageSize; let url = "/test/plan/scenario/case/relevance/list/" + this.currentPage + "/" + this.pageSize;
this.result = this.$post(url, this.condition, response => { this.result = this.$post(url, this.condition, response => {
let data = response.data; let data = response.data;
this.total = data.itemCount; this.total = data.itemCount;
this.tableData = data.listObject; this.tableData = data.listObject;
this.tableData.forEach(item => { this.tableData.forEach(item => {
if (item.tags && item.tags.length > 0) { if (item.tags && item.tags.length > 0) {
item.tags = JSON.parse(item.tags); item.tags = JSON.parse(item.tags);
} }
}); });
this.clear(); this.clear();
});
},
clear() {
this.selectRows.clear();
},
setProjectEnvMap(projectEnvMap) {
this.projectEnvMap = projectEnvMap;
},
setEnvGroup(id) {
this.envGroupId = id;
},
getWsProjects() {
this.$get("/project/getOwnerProjects", res => {
this.projectList = res.data;
});
},
getProject(projectId) {
if (projectId) {
this.$get('/project_application/get/config/' + projectId + "/SCENARIO_CUSTOM_NUM", result => {
let data = result.data;
if (data) {
this.customNum = data.scenarioCustomNum;
}
}); });
},
clear() {
this.selectRows.clear();
},
handleSelectAll(selection) {
_handleSelectAll(this, selection, this.tableData, this.selectRows);
this.initProjectIds();
},
handleSelect(selection, row) {
_handleSelect(this, selection, row, this.selectRows);
this.initProjectIds();
},
setProjectEnvMap(projectEnvMap) {
this.projectEnvMap = projectEnvMap;
},
setEnvGroup(id) {
this.envGroupId = id;
},
getWsProjects() {
this.$get("/project/getOwnerProjects", res => {
this.projectList = res.data;
})
},
getProject(projectId) {
if (projectId) {
this.$get('/project_application/get/config/' + projectId + "/SCENARIO_CUSTOM_NUM", result => {
let data = result.data;
if (data) {
this.customNum = data.scenarioCustomNum;
}
});
}
},
initProjectIds() {
this.projectIds.clear();
this.map.clear();
this.selectRows.forEach(row => {
this.result = this.$get('/api/automation/getApiScenarioProjectId/' + row.id, res => {
let data = res.data;
data.projectIds.forEach(d => this.projectIds.add(d));
this.map.set(row.id, data.projectIds);
})
})
},
checkEnv() {
return this.$refs.envPopover.checkEnv();
},
changeVersion(currentVersion) {
this.condition.versionId = currentVersion || null;
this.search();
},
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
filter(field) {
this.condition.filters = field || null;
this.search();
} }
},
initProjectIds() {
this.projectIds.clear();
this.map.clear();
this.selectRows.forEach(row => {
this.$get('/api/automation/getApiScenarioProjectId/' + row.id, res => {
let data = res.data;
data.projectIds.forEach(d => this.projectIds.add(d));
this.map.set(row.id, data.projectIds);
});
});
},
checkEnv() {
return this.$refs.envPopover.checkEnv();
},
changeVersion(currentVersion) {
this.condition.versionId = currentVersion || null;
this.search();
},
getVersionOptions() {
if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};
});
});
}
},
filter(field) {
this.condition.filters = field || null;
this.search();
},
selectCountChange(data) {
this.selectRows = this.$refs.scenarioTable.selectRows;
this.initProjectIds();
this.$emit("selectCountChange", data);
} }
} }
};
</script> </script>
<style scoped> <style scoped>
/deep/ .el-drawer__header { /deep/ .el-drawer__header {
margin-bottom: 0px; margin-bottom: 0px;
} }
.env-popover { .env-popover {
float: right; float: right;
margin-top: 10px; margin-top: 10px;
} }
.search-input { .search-input {
float: right; float: right;
width: 250px; width: 250px;
margin-top: 10px; margin-top: 10px;
margin-bottom: 20px; margin-bottom: 20px;
margin-right: 20px; margin-right: 20px;
} }
.adv-search-bar { .adv-search-bar {
float: right; float: right;
margin-top: 15px; margin-top: 15px;
margin-right: 10px; margin-right: 10px;
} }
</style> </style>

View File

@ -28,6 +28,7 @@
:versionFilters="versionFilters" :versionFilters="versionFilters"
:version-enable="versionEnable" :version-enable="versionEnable"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
@selectCountChange="setSelectCounts"
ref="apiList"> ref="apiList">
<template v-slot:version> <template v-slot:version>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event,'api')" margin-left="10"/> <version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event,'api')" margin-left="10"/>
@ -45,6 +46,7 @@
:version-enable="versionEnable" :version-enable="versionEnable"
:plan-id="planId" :plan-id="planId"
@isApiListEnableChange="isApiListEnableChange" @isApiListEnableChange="isApiListEnableChange"
@selectCountChange="setSelectCounts"
ref="apiCaseList"> ref="apiCaseList">
<template v-slot:version> <template v-slot:version>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event, 'case')" <version-select v-xpack :project-id="projectId" @changeVersion="changeVersion($event, 'case')"
@ -229,7 +231,10 @@
this.$refs.apiCaseList.condition.versionId = currentVersion || null; this.$refs.apiCaseList.condition.versionId = currentVersion || null;
this.$refs.apiCaseList.initTable(); this.$refs.apiCaseList.initTable();
} }
} },
setSelectCounts(data) {
this.$refs.baseRelevance.selectCounts = data;
},
} }
} }
</script> </script>

View File

@ -22,6 +22,7 @@
:version-enable="versionEnable" :version-enable="versionEnable"
:plan-id="planId" :plan-id="planId"
:project-id="projectId" :project-id="projectId"
@selectCountChange="setSelectCounts"
ref="apiScenarioList"/> ref="apiScenarioList"/>
</test-case-relevance-base> </test-case-relevance-base>
@ -30,138 +31,167 @@
<script> <script>
import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase"; import TestCaseRelevanceBase from "../base/TestCaseRelevanceBase";
import MsApiModule from "../../../../../api/definition/components/module/ApiModule"; import MsApiModule from "../../../../../api/definition/components/module/ApiModule";
import {getCurrentProjectID, strMapToObj} from "../../../../../../../common/js/utils"; import {strMapToObj} from "../../../../../../../common/js/utils";
import ApiCaseSimpleList from "../../../../../api/definition/components/list/ApiCaseSimpleList"; import ApiCaseSimpleList from "../../../../../api/definition/components/list/ApiCaseSimpleList";
import MsApiScenarioList from "../../../../../api/automation/scenario/ApiScenarioList"; import MsApiScenarioList from "../../../../../api/automation/scenario/ApiScenarioList";
import MsApiScenarioModule from "../../../../../api/automation/scenario/ApiScenarioModule"; import MsApiScenarioModule from "../../../../../api/automation/scenario/ApiScenarioModule";
import RelevanceScenarioList from "./RelevanceScenarioList"; import RelevanceScenarioList from "./RelevanceScenarioList";
import {ENV_TYPE} from "@/common/js/constants"; import {ENV_TYPE} from "@/common/js/constants";
export default { export default {
name: "TestCaseScenarioRelevance", name: "TestCaseScenarioRelevance",
components: { components: {
RelevanceScenarioList, RelevanceScenarioList,
MsApiScenarioModule, MsApiScenarioModule,
MsApiScenarioList, MsApiScenarioList,
ApiCaseSimpleList, ApiCaseSimpleList,
MsApiModule, MsApiModule,
TestCaseRelevanceBase, TestCaseRelevanceBase,
},
data() {
return {
showCasePage: true,
currentProtocol: null,
currentModule: null,
selectNodeIds: [],
moduleOptions: {},
trashEnable: false,
condition: {},
currentRow: {},
projectId: ""
};
},
props: {
planId: {
type: String
}, },
data() { versionEnable: {
return { type: Boolean,
showCasePage: true, default: false
currentProtocol: null, }
currentModule: null, },
selectNodeIds: [], watch: {
moduleOptions: {}, planId() {
trashEnable: false, this.condition.planId = this.planId;
condition: {},
currentRow: {},
projectId: ""
};
}, },
props: { },
planId: { methods: {
type: String open() {
}, this.$refs.baseRelevance.open();
versionEnable: { if (this.$refs.apiScenarioList) {
type: Boolean, this.$refs.apiScenarioList.clear();
default: false this.$refs.apiScenarioList.search();
} }
}, },
watch: { setProject(projectId) {
planId() { this.projectId = projectId;
this.condition.planId = this.planId;
},
}, },
methods: {
open() {
this.$refs.baseRelevance.open();
if (this.$refs.apiScenarioList) {
this.$refs.apiScenarioList.clear();
this.$refs.apiScenarioList.search();
}
},
setProject(projectId) {
this.projectId = projectId;
},
refresh(data) { refresh(data) {
this.$refs.apiScenarioList.search(data); this.$refs.apiScenarioList.search(data);
}, },
nodeChange(node, nodeIds, pNodes) { nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
}, },
handleProtocolChange(protocol) { handleProtocolChange(protocol) {
this.currentProtocol = protocol; this.currentProtocol = protocol;
}, },
setModuleOptions(data) { setModuleOptions(data) {
this.moduleOptions = data; this.moduleOptions = data;
}, },
async saveCaseRelevance() { postRelevance() {
const sign = await this.$refs.apiScenarioList.checkEnv(); let url = '/api/automation/relevance';
if (!sign) { const envMap = this.$refs.apiScenarioList.projectEnvMap;
return false; let envType = this.$refs.apiScenarioList.environmentType;
} let map = this.$refs.apiScenarioList.map;
let param = {}; let envGroupId = this.$refs.apiScenarioList.envGroupId;
let url = '/api/automation/relevance';
const envMap = this.$refs.apiScenarioList.projectEnvMap;
let map = this.$refs.apiScenarioList.map;
let envType = this.$refs.apiScenarioList.environmentType;
let envGroupId = this.$refs.apiScenarioList.envGroupId;
if (!map || map.size < 1) {
this.$warning(this.$t("api_test.please_select_case"));
return false;
}
if (envType === ENV_TYPE.JSON && (!envMap || envMap.size < 1)) {
this.$warning(this.$t("api_test.environment.select_environment"));
return false;
} else if (envType === ENV_TYPE.GROUP && !envGroupId) {
this.$warning(this.$t("api_test.environment.select_environment"));
return false;
}
param.planId = this.planId;
param.mapping = strMapToObj(map);
param.envMap = strMapToObj(envMap);
param.environmentType = envType;
param.envGroupId = envGroupId;
this.result = this.$post(url, param, () => { if (envType === ENV_TYPE.JSON && (!envMap || envMap.size < 1)) {
this.$success(this.$t('commons.save_success')); this.$warning(this.$t("api_test.environment.select_environment"));
this.$emit('refresh'); return false;
this.refresh(); } else if (envType === ENV_TYPE.GROUP && !envGroupId) {
this.autoCheckStatus(); this.$warning(this.$t("api_test.environment.select_environment"));
this.$refs.baseRelevance.close(); return false;
}); }
}, let param = {};
autoCheckStatus() { // param.planId = this.planId;
if (!this.planId) { param.mapping = strMapToObj(map);
return; param.envMap = strMapToObj(envMap);
} param.environmentType = envType;
this.$post('/test/plan/autoCheck/' + this.planId, (response) => { param.envGroupId = envGroupId;
});
}, this.result = this.$post(url, param, () => {
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
this.refresh();
this.autoCheckStatus();
this.$refs.baseRelevance.close();
});
},
async saveCaseRelevance() {
const sign = await this.$refs.apiScenarioList.checkEnv();
if (!sign) {
return false;
}
let url = '/api/automation/relevance';
const envMap = this.$refs.apiScenarioList.projectEnvMap;
let envType = this.$refs.apiScenarioList.environmentType;
let map = this.$refs.apiScenarioList.map;
let envGroupId = this.$refs.apiScenarioList.envGroupId;
if (envType === ENV_TYPE.JSON && (!envMap || envMap.size < 1)) {
this.$warning(this.$t("api_test.environment.select_environment"));
return false;
} else if (envType === ENV_TYPE.GROUP && !envGroupId) {
this.$warning(this.$t("api_test.environment.select_environment"));
return false;
}
let param = {};
param.planId = this.planId;
param.mapping = strMapToObj(map);
param.envMap = strMapToObj(envMap);
param.environmentType = envType;
param.envGroupId = envGroupId;
this.result = this.$post(url, param, () => {
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
this.refresh();
this.autoCheckStatus();
this.$refs.baseRelevance.close();
});
},
autoCheckStatus() { //
if (!this.planId) {
return;
}
this.$post('/test/plan/autoCheck/' + this.planId, (response) => {
});
},
setSelectCounts(data) {
this.$refs.baseRelevance.selectCounts = data;
} }
} }
};
</script> </script>
<style scoped> <style scoped>
/deep/ .select-menu { /deep/ .select-menu {
margin-bottom: 15px; margin-bottom: 15px;
} }
/deep/ .environment-select { /deep/ .environment-select {
float: right; float: right;
margin-right: 10px; margin-right: 10px;
} }
/deep/ .module-input { /deep/ .module-input {
width: 243px; width: 243px;
} }
</style> </style>

View File

@ -7,11 +7,11 @@
</div> </div>
</template> </template>
<template slot="title" slot-scope="{title}" v-if="!$slots.headerBtn"> <template slot="title" slot-scope="{title}" v-if="!$slots.headerBtn">
<ms-dialog-header :title="title" :enable-cancel="false" @confirm="save"> <ms-dialog-header :title="title" :enable-cancel="false" @confirm="save" btn-size="mini">
<template #other> <template #other>
<table-select-count-bar :count="selectCounts" style="float: left; margin: 5px;"/> <table-select-count-bar :count="selectCounts" style="float: left; margin: 5px;"/>
<div v-if="flag" style="margin-top: 5px;"> <div v-if="flag" style="margin: 5px; float: left;">
<el-checkbox v-model="checked" class="el-checkbox__label">{{ $t('test_track.sync_add_api_load') }}</el-checkbox> <el-checkbox v-model="checked" class="el-checkbox__label">{{ $t('test_track.sync_add_api_load') }}</el-checkbox>
</div> </div>
</template> </template>

View File

@ -31,6 +31,7 @@
:page-size.sync="page.pageSize" :page-size.sync="page.pageSize"
:screen-height="null" :screen-height="null"
@handlePageChange="getTestCases" @handlePageChange="getTestCases"
@selectCountChange="setSelectCounts"
@refresh="getTestCases" @refresh="getTestCases"
ref="table"> ref="table">
@ -99,7 +100,8 @@
</ms-table> </ms-table>
<ms-table-pagination :change="getTestCases" :current-page.sync="page.currentPage" :page-size.sync="page.pageSize" :total="page.total"/> <ms-table-pagination :change="getTestCases" :current-page.sync="page.currentPage" :page-size.sync="page.pageSize"
:total="page.total"/>
</test-case-relevance-base> </test-case-relevance-base>
</template> </template>
@ -117,7 +119,8 @@ import MsTableColumn from "@/business/components/common/components/table/MsTable
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsTag from "@/business/components/common/components/MsTag"; import MsTag from "@/business/components/common/components/MsTag";
import {hasLicense, getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
@ -137,14 +140,14 @@ export default {
MsTableHeader, MsTableHeader,
'VersionSelect': VersionSelect.default, 'VersionSelect': VersionSelect.default,
}, },
mounted(){ mounted() {
this.getVersionOptions(); this.getVersionOptions();
}, },
data() { data() {
return { return {
openType: 'relevance', openType: 'relevance',
result: {}, result: {},
isSaving:false, isSaving: false,
treeNodes: [], treeNodes: [],
selectNodeIds: [], selectNodeIds: [],
selectNodeNames: [], selectNodeNames: [],
@ -217,7 +220,7 @@ export default {
if (data) { if (data) {
this.customNum = data.customNum; this.customNum = data.customNum;
} }
}) });
}, },
getTestCases() { getTestCases() {
let condition = this.page.condition; let condition = this.page.condition;
@ -261,7 +264,7 @@ export default {
getVersionOptions() { getVersionOptions() {
if (hasLicense()) { if (hasLicense()) {
this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => { this.$get('/project/version/get-project-versions/' + getCurrentProjectID(), response => {
this.versionOptions= response.data; this.versionOptions = response.data;
this.versionFilters = response.data.map(u => { this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id}; return {text: u.name, value: u.id};
}); });
@ -271,9 +274,12 @@ export default {
changeVersion(currentVersion) { changeVersion(currentVersion) {
this.page.condition.versionId = currentVersion || null; this.page.condition.versionId = currentVersion || null;
this.getTestCases(); this.getTestCases();
},
setSelectCounts(data) {
this.$refs.baseRelevance.selectCounts = data;
} }
} }
} };
</script> </script>
<style scoped> <style scoped>

View File

@ -19,19 +19,23 @@
<ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar" <ms-table-adv-search-bar :condition.sync="condition" class="adv-search-bar"
v-if="condition.components !== undefined && condition.components.length > 0" v-if="condition.components !== undefined && condition.components.length > 0"
@search="getTestCases"/> @search="getTestCases"/>
<version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20" class="search-input"/> <version-select v-xpack :project-id="projectId" @changeVersion="changeVersion" margin-right="20"
class="search-input"/>
<el-table <ms-table
v-loading="result.loading" v-loading="result.loading"
:data="testCases" :data="testCases"
:condition="condition"
:page-size="pageSize"
:total="total"
:remember-order="true"
row-key="id" row-key="id"
@select-all="handleSelectAll" :row-order-group-id="projectId"
@select="handleSelectionChange" @refresh="search"
@filter-change="filter" :disable-header-config="true"
height="50vh" @selectCountChange="setSelectCounts"
ref="table"> ref="table">
<el-table-column
type="selection"/>
<el-table-column <el-table-column
prop="num" prop="num"
label="ID" label="ID"
@ -81,11 +85,10 @@
<span>{{ scope.row.updateTime | timestampFormatDate }}</span> <span>{{ scope.row.updateTime | timestampFormatDate }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </ms-table>
<ms-table-pagination :change="getTestCases" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
</el-card> </el-card>
<ms-table-pagination :change="getTestCases" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
</test-case-relevance-base> </test-case-relevance-base>
</template> </template>
@ -100,15 +103,18 @@ import MsTableAdvSearchBar from "@/business/components/common/components/search/
import MsTableHeader from "@/business/components/common/components/MsTableHeader"; import MsTableHeader from "@/business/components/common/components/MsTableHeader";
import MsPerformanceTestStatus from "@/business/components/performance/test/PerformanceTestStatus"; import MsPerformanceTestStatus from "@/business/components/performance/test/PerformanceTestStatus";
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import {_filter} from "@/common/js/tableUtils"; import {_filter, buildBatchParam} 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"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
import MsTable from "@/business/components/common/components/table/MsTable";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
export default { export default {
name: "TestCaseLoadRelevance", name: "TestCaseLoadRelevance",
components: { components: {
MsTable,
TestCaseRelevanceBase, TestCaseRelevanceBase,
NodeTree, NodeTree,
PriorityTableItem, PriorityTableItem,
@ -167,7 +173,7 @@ export default {
this.condition.reviewId = this.reviewId; this.condition.reviewId = this.reviewId;
}, },
}, },
mounted(){ mounted() {
this.getVersionOptions(); this.getVersionOptions();
}, },
methods: { methods: {
@ -185,31 +191,37 @@ export default {
this.search(); this.search();
}, },
saveCaseRelevance() { saveCaseRelevance() {
let param = {}; let selectRows = this.$refs.table.selectRows;
param.caseIds = [...this.selectIds]; let param = buildBatchParam(this, undefined, this.projectId);
param.ids = Array.from(selectRows).map(row => row.id);
if (this.planId) { if (this.planId) {
param.testPlanId = this.planId; this.result = this.$post("/performance/list/batch", param, (response) => {
this.result = this.$post('/test/plan/load/case/relevance', param, () => { let tests = response.data;
this.selectIds.clear(); let condition = {
this.$success(this.$t('commons.save_success')); caseIds: Array.from(tests).map(row => row.id),
testPlanId: this.planId,
this.$refs.baseRelevance.close(); };
this.result = this.$post('/test/plan/load/case/relevance', condition, () => {
this.$emit('refresh'); this.$success(this.$t('commons.save_success'));
this.$refs.baseRelevance.close();
this.$emit('refresh');
});
}); });
} }
if (this.reviewId) { if (this.reviewId) {
param.testCaseReviewId = this.reviewId; this.result = this.$post("/performance/list/batch", param, (response) => {
this.result = this.$post('/test/review/load/case/relevance', param, () => { let tests = response.data;
this.selectIds.clear(); let condition = {
this.$success(this.$t('commons.save_success')); caseIds: Array.from(tests).map(row => row.id),
testCaseReviewId: this.reviewId,
this.$refs.baseRelevance.close(); };
this.result = this.$post('/test/review/load/case/relevance', condition, () => {
this.$emit('refresh'); this.$success(this.$t('commons.save_success'));
this.$refs.baseRelevance.close();
this.$emit('refresh');
});
}); });
} }
}, },
buildPagePath(path) { buildPagePath(path) {
return path + "/" + this.currentPage + "/" + this.pageSize; return path + "/" + this.currentPage + "/" + this.pageSize;
@ -311,12 +323,15 @@ export default {
}); });
} }
}, },
changeVersion(currentVersion){ changeVersion(currentVersion) {
this.condition.versionId = currentVersion || null; this.condition.versionId = currentVersion || null;
this.search(); this.search();
},
setSelectCounts(data) {
this.$refs.baseRelevance.selectCounts = data;
} }
} }
} };
</script> </script>
<style scoped> <style scoped>

View File

@ -8,7 +8,11 @@
<template slot="title" :slot-scope="$t('test_track.review_view.relevance_case')" v-if="!$slots.headerBtn"> <template slot="title" :slot-scope="$t('test_track.review_view.relevance_case')" v-if="!$slots.headerBtn">
<ms-dialog-header :title="$t('test_track.review_view.relevance_case')" @cancel="dialogFormVisible = false" <ms-dialog-header :title="$t('test_track.review_view.relevance_case')" @cancel="dialogFormVisible = false"
@confirm="saveReviewRelevance"/> @confirm="saveReviewRelevance">
<template #other>
<table-select-count-bar :count="selectCounts" style="float: left; margin: 5px;"/>
</template>
</ms-dialog-header>
</template> </template>
<el-container class="main-content"> <el-container class="main-content">
@ -42,6 +46,7 @@
:page-size.sync="pageSize" :page-size.sync="pageSize"
@handlePageChange="getReviews" @handlePageChange="getReviews"
@refresh="getReviews" @refresh="getReviews"
@selectCountChange="setSelectCounts"
:condition="condition" :condition="condition"
ref="table"> ref="table">
@ -133,6 +138,7 @@ import {getCurrentProjectID, getCurrentUserId, getCurrentWorkspaceId, hasLicense
import MsTablePagination from "@/business/components/common/pagination/TablePagination"; import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import MsDialogHeader from "@/business/components/common/components/MsDialogHeader"; import MsDialogHeader from "@/business/components/common/components/MsDialogHeader";
import MsTable from "@/business/components/common/components/table/MsTable"; import MsTable from "@/business/components/common/components/table/MsTable";
import TableSelectCountBar from "@/business/components/api/automation/scenario/api/TableSelectCountBar";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {};
@ -141,6 +147,7 @@ const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./v
export default { export default {
name: "TestReviewRelevance", name: "TestReviewRelevance",
components: { components: {
TableSelectCountBar,
SelectMenu, SelectMenu,
NodeTree, NodeTree,
MsDialogFooter, MsDialogFooter,
@ -199,6 +206,7 @@ export default {
{text: this.$t('test_track.review.pass'), value: 'Pass'}, {text: this.$t('test_track.review.pass'), value: 'Pass'},
{text: this.$t('test_track.review.un_pass'), value: 'UnPass'}, {text: this.$t('test_track.review.un_pass'), value: 'UnPass'},
], ],
selectCounts: null,
}; };
}, },
props: { props: {
@ -252,6 +260,7 @@ export default {
} }
this.result = this.$post('/test/case/review/relevance', param, () => { this.result = this.$post('/test/case/review/relevance', param, () => {
this.selectIds.clear(); this.selectIds.clear();
this.selectCounts = 0;
this.$success(this.$t('commons.save_success')); this.$success(this.$t('commons.save_success'));
this.dialogFormVisible = false; this.dialogFormVisible = false;
this.$emit('refresh'); this.$emit('refresh');
@ -280,7 +289,9 @@ export default {
} }
}, },
setSelectCounts(data) {
this.selectCounts = data;
},
nodeChange(node, nodeIds, nodeNames) { nodeChange(node, nodeIds, nodeNames) {
this.selectNodeIds = nodeIds; this.selectNodeIds = nodeIds;
this.selectNodeNames = nodeNames; this.selectNodeNames = nodeNames;