diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index d2e475ea11..f3d2dd1433 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -392,9 +392,11 @@ public class ApiAutomationService { ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId()); http.setUrl(apiDefinition.getPath()); } - if (StringUtils.isBlank(http.getUrl()) || !isURL(http.getUrl())) { - env.getProjectIds().add(http.getProjectId()); - env.setFullUrl(false); + if (http.isEnable()) { + if (StringUtils.isBlank(http.getUrl()) || !isURL(http.getUrl())) { + env.getProjectIds().add(http.getProjectId()); + env.setFullUrl(false); + } } } else if (StringUtils.equals(tr.getType(), "TCPSampler")) { if (StringUtils.equals(tr.getRefType(), "CASE")) { @@ -405,11 +407,13 @@ public class ApiAutomationService { env.getProjectIds().add(apiDefinition.getProjectId()); } } else if (StringUtils.equals(tr.getType(), "scenario")) { - ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); - String scenarioDefinition = apiScenario.getScenarioDefinition(); - JSONObject element1 = JSON.parseObject(scenarioDefinition); - LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); - tr.setHashTree(hashTree1); + if (tr.isEnable()) { + ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); + String scenarioDefinition = apiScenario.getScenarioDefinition(); + JSONObject element1 = JSON.parseObject(scenarioDefinition); + LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); + tr.setHashTree(hashTree1); + } } } else { if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) { @@ -425,6 +429,9 @@ public class ApiAutomationService { env.getProjectIds().add(tr.getProjectId()); } } + if (!tr.isEnable()) { + continue; + } if (CollectionUtils.isNotEmpty(tr.getHashTree())) { getHashTree(tr.getHashTree(), env); } @@ -452,9 +459,11 @@ public class ApiAutomationService { ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId()); http.setUrl(apiDefinition.getPath()); } - if (StringUtils.isBlank(http.getUrl()) || !this.isURL(http.getUrl())) { - env.setFullUrl(false); - env.getProjectIds().add(http.getProjectId()); + if (http.isEnable()) { + if (StringUtils.isBlank(http.getUrl()) || !this.isURL(http.getUrl())) { + env.setFullUrl(false); + env.getProjectIds().add(http.getProjectId()); + } } } else if (StringUtils.equals(tr.getType(), "TCPSampler")) { if (StringUtils.equals(tr.getRefType(), "CASE")) { @@ -465,11 +474,13 @@ public class ApiAutomationService { env.getProjectIds().add(apiDefinition.getProjectId()); } } else if (StringUtils.equals(tr.getType(), "scenario")) { - ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); - String scenarioDefinition = apiScenario.getScenarioDefinition(); - JSONObject element1 = JSON.parseObject(scenarioDefinition); - LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); - tr.setHashTree(hashTree1); + if (tr.isEnable()) { + ApiScenarioDTO apiScenario = getApiScenario(tr.getId()); + String scenarioDefinition = apiScenario.getScenarioDefinition(); + JSONObject element1 = JSON.parseObject(scenarioDefinition); + LinkedList hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference>(){}); + tr.setHashTree(hashTree1); + } } } else { if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) { @@ -485,6 +496,9 @@ public class ApiAutomationService { env.getProjectIds().add(tr.getProjectId()); } } + if (!tr.isEnable()) { + continue; + } if (CollectionUtils.isNotEmpty(tr.getHashTree())) { getHashTree(tr.getHashTree(), env); } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index c294314450..4426dbe7b4 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -121,7 +121,7 @@ + @showPopover="showPopover" :project-list="projectList" ref="envPopover"/> {{$t('api_test.request.debug')}} @@ -205,8 +205,8 @@ { this.loading = false }); - let definition = JSON.parse(JSON.stringify(this.currentScenario)); - definition.hashTree = this.scenarioDefinition; - this.getEnv(JSON.stringify(definition)); + // let definition = JSON.parse(JSON.stringify(this.currentScenario)); + // definition.hashTree = this.scenarioDefinition; + // this.getEnv(JSON.stringify(definition)); }, runDebug() { /*触发执行操作*/ @@ -789,24 +789,28 @@ let definition = JSON.parse(JSON.stringify(this.currentScenario)); definition.hashTree = this.scenarioDefinition; this.getEnv(JSON.stringify(definition)).then(() => { - let sign = this.$refs.envPopover.checkEnv(this.isFullUrl); - if (!sign) { - return; - } - this.editScenario().then(() => { - this.debugData = { - id: this.currentScenario.id, - name: this.currentScenario.name, - type: "scenario", - variables: this.currentScenario.variables, - referenced: 'Created', - enableCookieShare: this.enableCookieShare, - headers: this.currentScenario.headers, - environmentMap: this.projectEnvMap, - hashTree: this.scenarioDefinition - }; - this.reportId = getUUID().substring(0, 8); + let promise = this.$refs.envPopover.initEnv(); + promise.then(() => { + let sign = this.$refs.envPopover.checkEnv(this.isFullUrl); + if (!sign) { + return; + } + this.editScenario().then(() => { + this.debugData = { + id: this.currentScenario.id, + name: this.currentScenario.name, + type: "scenario", + variables: this.currentScenario.variables, + referenced: 'Created', + enableCookieShare: this.enableCookieShare, + headers: this.currentScenario.headers, + environmentMap: this.projectEnvMap, + hashTree: this.scenarioDefinition + }; + this.reportId = getUUID().substring(0, 8); + }) }) + }) } }) @@ -1002,7 +1006,7 @@ if (response.data) { this.path = "/api/automation/update"; if (response.data.scenarioDefinition != null) { - this.getEnv(response.data.scenarioDefinition); + // this.getEnv(response.data.scenarioDefinition); let obj = JSON.parse(response.data.scenarioDefinition); if (obj) { this.currentEnvironmentId = obj.environmentId; @@ -1138,6 +1142,13 @@ close(name) { this.drawer = false; this.$emit('closePage', name); + }, + showPopover() { + let definition = JSON.parse(JSON.stringify(this.currentScenario)); + definition.hashTree = this.scenarioDefinition; + this.getEnv(JSON.stringify(definition)).then(() => { + this.$refs.envPopover.openEnvSelect(); + }) } } } diff --git a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue index 32580f3be9..83072dd7cc 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvPopover.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvPopover.vue @@ -39,11 +39,17 @@ export default { }, methods: { showPopover() { - this.$refs.envSelect.open(); + this.$emit("showPopover"); + }, + openEnvSelect() { + return this.$refs.envSelect.open(); }, setProjectEnvMap(map) { this.$emit("setProjectEnvMap", map); }, + initEnv() { + return this.$refs.envSelect.initEnv(); + }, checkEnv(data) { return this.$refs.envSelect.checkEnv(data); } diff --git a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue index 1ea30c2a20..23b8e387cf 100644 --- a/frontend/src/business/components/api/automation/scenario/EnvSelect.vue +++ b/frontend/src/business/components/api/automation/scenario/EnvSelect.vue @@ -5,12 +5,14 @@ - + {{ $t('api_test.environment.environment_config') }} diff --git a/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue b/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue index 2588a23bb2..e22f8f7711 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/ScenarioHeader.vue @@ -19,7 +19,7 @@ 共享cookie + @showPopover="showPopover" :project-list="projectList" ref="envPopover" class="ms-right"/> {{$t('api_test.request.debug')}} @@ -37,7 +37,12 @@ export default { name: "ScenarioHeader", components: {EnvPopover}, - props: {currentScenario: {}, scenarioDefinition: Array, enableCookieShare: Boolean, projectEnvMap: Map, projectIds: Set, projectList: Array}, + props: {currentScenario: {}, scenarioDefinition: Array, enableCookieShare: Boolean, + projectEnvMap: Map, + projectIds: Set, + projectList: Array, + isFullUrl: Boolean + }, data() { return { envMap: new Map, @@ -102,7 +107,25 @@ setProjectEnvMap(projectEnvMap) { this.$emit('setProjectEnvMap', projectEnvMap); this.envMap = projectEnvMap; - } + }, + showPopover() { + let definition = JSON.parse(JSON.stringify(this.currentScenario)); + definition.hashTree = this.scenarioDefinition; + this.getEnv(JSON.stringify(definition)).then(() => { + this.$refs.envPopover.openEnvSelect(); + }) + }, + getEnv(definition) { + return new Promise((resolve) => { + this.$post("/api/automation/getApiScenarioEnv", {definition: definition}, res => { + if (res.data) { + this.$emit("update:projectIds", new Set(res.data.projectIds)) + this.$emit("update:isFullUrl", res.data.fullUrl) + } + resolve(); + }) + }); + }, }, } diff --git a/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue b/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue index af4b987937..2e3f7a0249 100644 --- a/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue +++ b/frontend/src/business/components/api/automation/scenario/testplan/TestPlanList.vue @@ -152,9 +152,7 @@ import {TEST_PLAN_CONFIGS} from "../../../../common/components/search/search-com import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent"; import {getCurrentProjectID} from "../../../../../../common/js/utils"; import {_filter, _sort} from "@/common/js/tableUtils"; -import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; - - +import EnvPopover from "@/business/components/track/common/EnvPopover"; export default { name: "TestPlanList", components: { diff --git a/frontend/src/business/components/track/case/components/BatchEdit.vue b/frontend/src/business/components/track/case/components/BatchEdit.vue index 3c4a5fb55b..4f5c8e63c2 100644 --- a/frontend/src/business/components/track/case/components/BatchEdit.vue +++ b/frontend/src/business/components/track/case/components/BatchEdit.vue @@ -41,8 +41,7 @@ + + diff --git a/frontend/src/business/components/track/common/EnvSelect.vue b/frontend/src/business/components/track/common/EnvSelect.vue new file mode 100644 index 0000000000..f88f2b53a7 --- /dev/null +++ b/frontend/src/business/components/track/common/EnvSelect.vue @@ -0,0 +1,285 @@ + + + + + diff --git a/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue b/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue index 1ca672c50c..9c5e67ae5f 100644 --- a/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/api/RelevanceScenarioList.vue @@ -68,7 +68,7 @@ import MsTestPlanList from "../../../../../api/automation/scenario/testplan/TestPlanList"; import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader"; import {_handleSelect, _handleSelectAll} from "../../../../../../../common/js/tableUtils"; - import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover"; + import EnvPopover from "@/business/components/track/common/EnvPopover"; export default { name: "RelevanceScenarioList", diff --git a/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue b/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue index 8dfa06769a..fe798b6389 100644 --- a/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue +++ b/frontend/src/business/components/track/review/view/components/ReviewRelevanceScenarioList.vue @@ -56,7 +56,7 @@