diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index c9c8199acf..01e4cbc553 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -65,8 +65,6 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import javax.annotation.Resource; import javax.servlet.ServletOutputStream; @@ -1550,6 +1548,10 @@ public class TestPlanService { envMap = planTestPlanApiCaseService.getApiCaseEnv(planId); Map> scenarioEnv = planTestPlanScenarioCaseService.getApiScenarioEnv(planId); + if (DiscoveryUtil.hasService(MicroServiceName.UI_TEST)) { + scenarioEnv = mergeUiScenarioEnv(planId, scenarioEnv); + } + Set projectIds = scenarioEnv.keySet(); for (String projectId : projectIds) { if (envMap.containsKey(projectId)) { @@ -1572,6 +1574,32 @@ public class TestPlanService { return envMap; } + /** + * 合并ui场景的环境信息 + * @param planId + * @param scenarioEnv + * @return + */ + private Map> mergeUiScenarioEnv(String planId, Map> scenarioEnv) { + Map> uiScenarioEnv = planTestPlanUiScenarioCaseService.getUiScenarioEnv(planId); + if (MapUtils.isEmpty(scenarioEnv)) { + return uiScenarioEnv; + } + if (MapUtils.isNotEmpty(uiScenarioEnv)) { + uiScenarioEnv.entrySet().forEach(entry -> { + if (scenarioEnv.containsKey(entry.getKey())) { + List environmentIds = scenarioEnv.get(entry.getKey()); + entry.getValue().forEach(eId -> { + if (!environmentIds.contains(eId)) { + environmentIds.add(eId); + } + }); + } + }); + } + return scenarioEnv; + } + public String runPlan(TestPlanRunRequest testplanRunRequest) { //检查测试计划下有没有可以执行的用例; if (!haveExecCase(testplanRunRequest.getTestPlanId(), false)) { diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java index 4ea516fe4b..bbd04cbbfd 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/remote/ui/PlanTestPlanUiScenarioCaseService.java @@ -153,4 +153,8 @@ public class PlanTestPlanUiScenarioCaseService extends UiTestService { public List selectExtForPlanReport(String planId) { return microService.getForDataArray(serviceName, BASE_URL + "/get/report/ext/" + planId, UiScenarioReportWithBLOBs.class); } + + public Map> getUiScenarioEnv(String planId) { + return microService.getForData(serviceName, BASE_URL + "/get/env/" + planId, Map.class); + } } diff --git a/test-track/frontend/src/api/remote/ui/ui-automation.js b/test-track/frontend/src/api/remote/ui/ui-automation.js new file mode 100644 index 0000000000..dfba3d5842 --- /dev/null +++ b/test-track/frontend/src/api/remote/ui/ui-automation.js @@ -0,0 +1,15 @@ +import {get, post} from "metersphere-frontend/src/plugins/request" + +const BASE_URL = "/ui/automation/"; + +export function getUiScenarioEnvByProjectId(id) { + return get(BASE_URL + `env-project-ids/${id}`); +} + +export function uiAutomationReduction(param) { + return post(BASE_URL + 'reduction', param); +} + +export function uiScenarioEnvMap(params) { + return post(BASE_URL + 'env/map', params); +} diff --git a/test-track/frontend/src/business/plan/env/EnvSelectPopover.vue b/test-track/frontend/src/business/plan/env/EnvSelectPopover.vue index 344d3c5fcb..49e58b9a50 100644 --- a/test-track/frontend/src/business/plan/env/EnvSelectPopover.vue +++ b/test-track/frontend/src/business/plan/env/EnvSelectPopover.vue @@ -201,7 +201,7 @@ export default { // 选中环境是否存在 temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId; } - if (this.projectEnvMap) { + if (this.projectEnvMap && Object.keys(this.projectEnvMap).length > 0) { let projectEnvMapElement = this.projectEnvMap[d]; if (projectEnvMapElement.length>0) { projectEnvMapElement.forEach(envId => { diff --git a/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue b/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue index 38d9c31e72..0e6c09f61a 100644 --- a/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue +++ b/test-track/frontend/src/business/plan/view/comonents/ui/RelevanceUiScenarioList.vue @@ -1,5 +1,21 @@