diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 477e7572bf..1c31a09855 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -247,6 +247,16 @@ public class ApiScenarioExecuteService { return; } Map scenarioMap = apiScenarios.stream().collect(Collectors.toMap(ApiScenarioWithBLOBs::getId, Function.identity(), (t1, t2) -> t1)); + //检查环境组 + Map configEnvMap = new HashMap<>(); + if (request.getConfig() != null) { + if (StringUtils.equals(request.getConfig().getEnvironmentType(), EnvironmentType.JSON.toString()) && MapUtils.isNotEmpty(request.getConfig().getEnvMap())) { + configEnvMap = request.getConfig().getEnvMap(); + } else if (StringUtils.equals(request.getConfig().getEnvironmentType(), EnvironmentType.GROUP.toString()) && StringUtils.isNotBlank(request.getConfig().getEnvironmentGroupId())) { + configEnvMap = environmentGroupProjectService.getEnvMap(request.getConfig().getEnvironmentGroupId()); + } + } + for (String testPlanScenarioId : planScenarioIdMap.keySet()) { String scenarioId = planScenarioIdMap.get(testPlanScenarioId); ApiScenarioWithBLOBs scenario = scenarioMap.get(scenarioId); @@ -268,6 +278,8 @@ public class ApiScenarioExecuteService { } else if (StringUtils.equals(planApiScenario.getEnvironmentType(), EnvironmentType.GROUP.toString()) && StringUtils.isNotBlank(planApiScenario.getEnvironmentGroupId())) { planEnvMap = environmentGroupProjectService.getEnvMap(planApiScenario.getEnvironmentGroupId()); } + planEnvMap.putAll(configEnvMap); + if (StringUtils.isEmpty(request.getProjectId())) { request.setProjectId(extTestPlanScenarioCaseMapper.getProjectIdById(testPlanScenarioId)); } diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java index fdd3883b1f..d5f113003d 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioSerialService.java @@ -21,6 +21,7 @@ import io.metersphere.commons.utils.RequestParamsUtil; import io.metersphere.dto.JmeterRunRequestDTO; import io.metersphere.environment.service.BaseEnvironmentService; import io.metersphere.utils.LoggerUtil; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.jorphan.collections.HashTree; import org.springframework.context.annotation.Lazy; @@ -71,8 +72,11 @@ public class ApiScenarioSerialService { } else { TestPlanApiScenario planApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(queue.getTestId()); if (planApiScenario != null) { - planEnvMap = apiScenarioEnvService.planEnvMap(queue.getTestId()); - queue.setEvnMap(JSON.toJSONString(planEnvMap)); + // envMap不为空的话可以看做是需要指定环境运行; 为空的话则按照默认环境运行 + if (MapUtils.isEmpty(JSON.parseObject(queue.getEvnMap(), Map.class))) { + planEnvMap = apiScenarioEnvService.planEnvMap(queue.getTestId()); + queue.setEvnMap(JSON.toJSONString(planEnvMap)); + } scenario = apiScenarioMapper.selectByPrimaryKey(planApiScenario.getApiScenarioId()); } } diff --git a/api-test/frontend/src/business/automation/scenario/ApiScenarioModule.vue b/api-test/frontend/src/business/automation/scenario/ApiScenarioModule.vue index 3da28f3e65..269754db77 100644 --- a/api-test/frontend/src/business/automation/scenario/ApiScenarioModule.vue +++ b/api-test/frontend/src/business/automation/scenario/ApiScenarioModule.vue @@ -55,7 +55,9 @@ import { getModuleByProjectId, getModuleByRelevanceProjectId, getModuleByTrash, - posScenarioModule, postModuleByProjectId, postModuleByTrash, + posScenarioModule, + postModuleByProjectId, + postModuleByTrash, } from '@/api/scenario-module'; export default { @@ -167,17 +169,17 @@ export default { this.param = {}; }, }, - created(){ - this.$EventBus.$on("scenarioConditionBus", (param)=>{ + created() { + this.$EventBus.$on('scenarioConditionBus', (param) => { this.param = param; this.list(); - }) + }); }, beforeDestroy() { - this.$EventBus.$off("scenarioConditionBus", (param)=>{ + this.$EventBus.$off('scenarioConditionBus', (param) => { this.param = param; this.list(); - }) + }); }, methods: { handleImport() { @@ -352,7 +354,9 @@ export default { }, enableTrash() { this.condition.trashEnable = true; - this.$emit('enableTrash', this.condition.trashEnable); + this.$nextTick(() => { + this.$emit('enableTrash', this.condition.trashEnable); + }); }, removeModuleId(nodeIds) { if (localStorage.getItem('scenarioModule') && localStorage.getItem('scenarioModule') === nodeIds[0]) { diff --git a/test-track/frontend/src/business/utils/constants.js b/test-track/frontend/src/business/utils/constants.js index a4ccce5ca8..7bf3eb9d20 100644 --- a/test-track/frontend/src/business/utils/constants.js +++ b/test-track/frontend/src/business/utils/constants.js @@ -1,19 +1,116 @@ import i18n from "@/i18n"; export const REPORT_STATUS_MAP = new Map([ - ["success", {name: i18n.t('test_track.plan_view.pass'), itemStyle: {color: '#67C23A'}}], - ["Success", {name: i18n.t('test_track.plan_view.pass'), itemStyle: {color: '#67C23A'}}], - ["SUCCESS", {name: i18n.t('test_track.plan_view.pass'), itemStyle: {color: '#67C23A'}}], - ["Pass", {name: i18n.t('test_track.plan_view.pass'), itemStyle: {color: '#67C23A'}}], - ["error", {name: i18n.t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], - ["Error", {name: i18n.t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], - ["ERROR", {name: i18n.t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], - ["Fail", {name: i18n.t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], - ["Failure", {name: i18n.t('test_track.plan_view.failure'), itemStyle: {color: '#F56C6C'}}], - ["Prepare", {name: i18n.t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}], - ["PENDING", {name: i18n.t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}], - ["Underway", {name: i18n.t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}], - ["RERUNNING", {name: i18n.t('api_test.home_page.detail_card.unexecute'), itemStyle: {color: '#909399'}}], - ["FAKE_ERROR", {name: i18n.t('error_report_library.option.name'), itemStyle: {color: '#F6972A'}}], - ["run", {name: i18n.t('test_track.plan_view.running'), itemStyle: {color: '#DEDE10'}}], + [ + "success", + { + name: i18n.t("test_track.plan_view.pass"), + itemStyle: { color: "#67C23A" }, + }, + ], + [ + "Success", + { + name: i18n.t("test_track.plan_view.pass"), + itemStyle: { color: "#67C23A" }, + }, + ], + [ + "SUCCESS", + { + name: i18n.t("test_track.plan_view.pass"), + itemStyle: { color: "#67C23A" }, + }, + ], + [ + "Pass", + { + name: i18n.t("test_track.plan_view.pass"), + itemStyle: { color: "#67C23A" }, + }, + ], + [ + "error", + { + name: i18n.t("test_track.plan_view.failure"), + itemStyle: { color: "#F56C6C" }, + }, + ], + [ + "Error", + { + name: i18n.t("test_track.plan_view.failure"), + itemStyle: { color: "#F56C6C" }, + }, + ], + [ + "ERROR", + { + name: i18n.t("test_track.plan_view.failure"), + itemStyle: { color: "#F56C6C" }, + }, + ], + [ + "Fail", + { + name: i18n.t("test_track.plan_view.failure"), + itemStyle: { color: "#F56C6C" }, + }, + ], + [ + "Failure", + { + name: i18n.t("test_track.plan_view.failure"), + itemStyle: { color: "#F56C6C" }, + }, + ], + [ + "Prepare", + { + name: i18n.t("api_test.home_page.detail_card.unexecute"), + itemStyle: { color: "#909399" }, + }, + ], + [ + "PENDING", + { + name: i18n.t("api_test.home_page.detail_card.unexecute"), + itemStyle: { color: "#909399" }, + }, + ], + [ + "Underway", + { + name: i18n.t("api_test.home_page.detail_card.unexecute"), + itemStyle: { color: "#909399" }, + }, + ], + [ + "RERUNNING", + { + name: i18n.t("api_test.home_page.detail_card.unexecute"), + itemStyle: { color: "#909399" }, + }, + ], + [ + "RUNNING", + { + name: i18n.t("api_test.home_page.detail_card.unexecute"), + itemStyle: { color: "#909399" }, + }, + ], + [ + "FAKE_ERROR", + { + name: i18n.t("error_report_library.option.name"), + itemStyle: { color: "#F6972A" }, + }, + ], + [ + "run", + { + name: i18n.t("test_track.plan_view.running"), + itemStyle: { color: "#DEDE10" }, + }, + ], ]);