From 9e0bb8c208423147d38f9da4ed4ec608ac93f2e0 Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Sat, 17 Dec 2022 03:46:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20U?= =?UTF-8?q?I=E6=94=AF=E6=8C=81=E7=8E=AF=E5=A2=83=E8=BF=90=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1010692 --user=张大海 【UI测试】支持与环境管理打通 https://www.tapd.cn/55049933/s/1315234 --- .../plan/service/TestPlanService.java | 32 ++++++++++++- .../ui/PlanTestPlanUiScenarioCaseService.java | 4 ++ .../src/api/remote/ui/ui-automation.js | 15 ++++++ .../business/plan/env/EnvSelectPopover.vue | 2 +- .../comonents/ui/RelevanceUiScenarioList.vue | 35 +++++++++++++- .../ui/TestCaseUiScenarioRelevance.vue | 6 ++- .../comonents/ui/TestPlanUiScenarioList.vue | 32 ++++++++----- .../plan/view/comonents/ui/UiRunMode.vue | 47 ++++++++++++++++++- .../src/business/utils/track-table-header.js | 1 + 9 files changed, 155 insertions(+), 19 deletions(-) create mode 100644 test-track/frontend/src/api/remote/ui/ui-automation.js 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 @@