fix(测试跟踪): 关联测试模块树及列表数据问题

--bug=1017975 --user=宋昌昌 【测试跟踪】测试用例-关联测试-选择其他项目-左侧模块统计数是0 https://www.tapd.cn/55049933/s/1262038

Co-authored-by: song-cc-rock <changchang.song@fit2cloud.com>
This commit is contained in:
MeterSphere Bot 2022-10-14 23:46:58 +08:00 committed by GitHub
parent 0ad5e00c39
commit 2333ca5c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 6 deletions

View File

@ -37,6 +37,7 @@ import io.metersphere.service.plan.TestPlanApiCaseService;
import io.metersphere.service.scenario.ApiScenarioReferenceIdService;
import io.metersphere.xpack.api.service.ApiCaseBatchSyncService;
import io.metersphere.xpack.api.service.ApiTestCaseSyncService;
import io.metersphere.xpack.version.service.ProjectVersionService;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.comparators.FixedOrderComparator;
@ -1157,13 +1158,25 @@ public class ApiTestCaseService {
public List<ApiTestCaseDTO> getRelevanceApiList(ApiTestCaseRequest request) {
List<ApiTestCaseDTO> apiTestCaseDTOS = extApiTestCaseMapper.relevanceApiList(request);
ServiceUtils.buildVersionInfo(apiTestCaseDTOS);
List<String> versionIds = apiTestCaseDTOS.stream().map(ApiTestCaseDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
apiTestCaseDTOS.forEach(apiTestCaseDTO -> {
apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId()));
});
return apiTestCaseDTOS;
}
public List<ApiScenarioDTO> getRelevanceScenarioList(ApiScenarioRequest request) {
List<ApiScenarioDTO> apiScenarioDTOS = extApiScenarioMapper.relevanceScenarioList(request);
ServiceUtils.buildVersionInfo(apiScenarioDTOS);
List<String> versionIds = apiScenarioDTOS.stream().map(ApiScenarioDTO::getVersionId).collect(Collectors.toList());
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
Map<String, String> projectVersionMap = projectVersionService.getProjectVersionByIds(versionIds).stream()
.collect(Collectors.toMap(ProjectVersion::getId, ProjectVersion::getName));
apiScenarioDTOS.forEach(apiTestCaseDTO -> {
apiTestCaseDTO.setVersionName(projectVersionMap.get(apiTestCaseDTO.getVersionId()));
});
return apiScenarioDTOS;
}

View File

@ -7,6 +7,7 @@
<template v-slot:aside>
<ms-api-module
:show-case-num="false"
:relevance-project-id="projectId"
@nodeSelectEvent="nodeChange"
@protocolChange="handleProtocolChange"
@ -32,7 +33,7 @@
<script>
import TestCaseRelateApiList from "@/business/case/components/TestCaseRelateApiList";
import MsApiModule from "@/business/plan/view/comonents/api/module/ApiModule";
import MsApiModule from "metersphere-frontend/src/components/environment/snippet/ext/module/ApiModule";
import TestCaseRelevanceBase from "@/business/plan/view/comonents/base/TestCaseRelevanceBase";
import {saveCaseRelevanceApi} from "@/api/testCase";
@ -87,7 +88,6 @@ export default {
refresh(data) {
this.$refs.apiCaseList.initTable(data);
},
nodeChange(node, nodeIds, pNodes) {
this.selectNodeIds = nodeIds;
},

View File

@ -7,6 +7,7 @@
<template v-slot:aside>
<ms-api-scenario-module
:show-case-num="false"
:relevance-project-id="projectId"
@nodeSelectEvent="nodeChange"
@refreshTable="refresh"

View File

@ -122,6 +122,9 @@ export default {
if (this.condition.protocol !== this.defaultProtocol) {
this.condition.protocol = this.defaultProtocol;
}
},
relevanceProjectId() {
this.list();
}
},
methods: {

View File

@ -781,7 +781,7 @@ export default {
getVersionOptions() {
if (hasLicense()) {
getProjectVersions(getCurrentProjectID())
.then(response => {
.then((response) => {
this.versionOptions = response.data;
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};

View File

@ -502,7 +502,7 @@ export default {
getVersionOptions() {
if (hasLicense()) {
getProjectVersions(getCurrentProjectID())
.then(response => {
.then((response) => {
this.versionOptions = response.data;
this.versionFilters = response.data.map(u => {
return {text: u.name, value: u.id};