refactor(测试跟踪): 关联场景用例支持全选

This commit is contained in:
chenjianxing 2022-09-06 20:06:09 +08:00 committed by 刘瑞斌
parent c9b399172f
commit c2ce23fcac
6 changed files with 30 additions and 8 deletions

View File

@ -1032,20 +1032,27 @@ public class ApiAutomationService {
}
public void relevance(ApiCaseRelevanceRequest request) {
buildApiCaseRelevanceRequest(request);
Map<String, List<String>> mapping = request.getMapping();
Map<String, String> envMap = request.getEnvMap();
Set<String> set = mapping.keySet();
List<String> relevanceIds = request.getSelectIds();
List<String> relevanceIds = request.getIds();
Collections.reverse(relevanceIds);
String envType = request.getEnvironmentType();
String envGroupId = request.getEnvGroupId();
if (set.isEmpty()) {
return;
}
Long nextOrder = ServiceUtils.getNextOrder(request.getPlanId(), extTestPlanScenarioCaseMapper::getLastOrder);
for (String id : relevanceIds) {
Map<String, String> newEnvMap = new HashMap<>(16);
List<String> list = mapping.get(id);
if (CollectionUtils.isEmpty(list)) {
ScenarioEnv scenarioEnv = getApiScenarioProjectId(id);
list = new ArrayList<>(scenarioEnv.getProjectIds());
}
list.forEach(l -> newEnvMap.put(l, envMap == null ? "" : envMap.getOrDefault(l, "")));
TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario();
testPlanApiScenario.setId(UUID.randomUUID().toString());
@ -1070,6 +1077,12 @@ public class ApiAutomationService {
}
}
public void buildApiCaseRelevanceRequest(ApiCaseRelevanceRequest request) {
this.initRequest(request.getCondition(), true, true);
ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extApiScenarioMapper.selectRelevanceIdsByQuery(query));
}
public void relevanceReview(ApiCaseRelevanceRequest request) {
Map<String, List<String>> mapping = request.getMapping();
Map<String, String> envMap = request.getEnvMap();
@ -2257,7 +2270,7 @@ public class ApiAutomationService {
e.printStackTrace();
}
//Compare the basic information of the APIScenario.
//Compare the basic information of the APIScenario.
if (!StringUtils.equals(exScenario.getName(), scenario.getName())) {
return true;

View File

@ -94,4 +94,5 @@ public interface ExtApiScenarioMapper {
List<ApiScenarioWithBLOBs> selectRepeatByBLOBs(@Param("names") List<String> names, @Param("projectId") String projectId);
List<String> selectRelevanceIdsByQuery(@Param("request") BaseQueryRequest query);
}

View File

@ -763,6 +763,11 @@
and status != 'Trash'
and project_id = #{projectId}
</select>
<select id="selectRelevanceIdsByQuery" resultType="java.lang.String">
select api_scenario.id
from api_scenario
<include refid="queryWhereCondition"/>
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
</select>
</mapper>

View File

@ -1,5 +1,6 @@
package io.metersphere.track.request.testcase;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import lombok.Getter;
import lombok.Setter;
@ -27,6 +28,8 @@ public class ApiCaseRelevanceRequest {
*/
private List<String> selectIds = new ArrayList<>();
private List<String> ids = new ArrayList<>();
/**
* 项目环境对应关系
*/
@ -43,4 +46,6 @@ public class ApiCaseRelevanceRequest {
private String environmentType;
private String envGroupId;
private ApiScenarioRequest condition;
}

View File

@ -32,7 +32,7 @@
@order="search"
@filter="filterSearch"
:disable-header-config="true"
:show-select-all="false"
:show-select-all="true"
@selectCountChange="selectCountChange">
<el-table-column v-if="!customNum" prop="num" label="ID" sortable="custom"

View File

@ -75,9 +75,6 @@ export default {
watch: {
planId() {
this.condition.planId = this.planId;
},
projectId() {
this.getVersionOptions();
}
},
methods: {
@ -164,7 +161,8 @@ export default {
param.envMap = strMapToObj(envMap);
param.environmentType = envType;
param.envGroupId = envGroupId;
param.selectIds = selectIds;
param.ids = selectIds;
param.condition = this.$refs.apiScenarioList.condition;
this.result = this.$post(url, param, () => {
this.$success(this.$t('commons.save_success'));