From 1fccb03322541e01e87351f25064e23c1ec11c06 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 29 Jun 2021 13:35:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=EF=BC=8C=E5=88=87=E6=8D=A2=E6=9D=A1=E4=BB=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E4=B8=8D=E5=88=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiAutomationService.java | 20 +++++++++---------- .../automation/scenario/ApiScenarioList.vue | 3 +++ .../automation/scenario/ImportApiScenario.vue | 3 +++ 3 files changed, 16 insertions(+), 10 deletions(-) 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 494996e432..914c1b08ba 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -50,7 +50,6 @@ import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.FileOperationRequest; import io.metersphere.track.service.TestPlanScenarioCaseService; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; @@ -585,6 +584,9 @@ public class ApiAutomationService { List hashTree = getScenarioHashTree(definition); for (int i = 0; i < hashTree.size(); i++) { MsTestElement tr = hashTree.get(i); + if (!tr.isEnable()) { + continue; + } String referenced = tr.getReferenced(); if (StringUtils.equals(MsTestElementConstants.REF.name(), referenced)) { if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) { @@ -599,7 +601,7 @@ public class ApiAutomationService { } } if (http.isEnable()) { - if (StringUtils.isBlank(http.getUrl()) || !tr.isURL(http.getUrl())) { + if (http.getIsRefEnvironment()) { env.getProjectIds().add(http.getProjectId()); env.setFullUrl(false); } @@ -631,7 +633,7 @@ public class ApiAutomationService { // 校验是否是全路径 MsHTTPSamplerProxy httpSamplerProxy = (MsHTTPSamplerProxy) tr; if (httpSamplerProxy.isEnable()) { - if (StringUtils.isBlank(httpSamplerProxy.getUrl()) || !tr.isURL(httpSamplerProxy.getUrl())) { + if (httpSamplerProxy.getIsRefEnvironment()) { env.getProjectIds().add(httpSamplerProxy.getProjectId()); env.setFullUrl(false); } @@ -640,9 +642,7 @@ public class ApiAutomationService { env.getProjectIds().add(tr.getProjectId()); } } - if (!tr.isEnable()) { - continue; - } + if (StringUtils.equals(tr.getType(), "scenario")) { env.getProjectIds().add(tr.getProjectId()); } @@ -659,6 +659,9 @@ public class ApiAutomationService { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); for (int i = 0; i < tree.size(); i++) { MsTestElement tr = tree.get(i); + if (!tr.isEnable()) { + continue; + } String referenced = tr.getReferenced(); if (StringUtils.equals(MsTestElementConstants.REF.name(), referenced)) { if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) { @@ -671,7 +674,7 @@ public class ApiAutomationService { http.setUrl(apiDefinition.getPath()); } if (http.isEnable()) { - if (StringUtils.isBlank(http.getUrl()) || !tr.isURL(http.getUrl())) { + if (http.getIsRefEnvironment()) { env.setFullUrl(false); env.getProjectIds().add(http.getProjectId()); } @@ -711,9 +714,6 @@ public class ApiAutomationService { env.getProjectIds().add(tr.getProjectId()); } } - if (!tr.isEnable()) { - continue; - } if (StringUtils.equals(tr.getType(), "scenario")) { env.getProjectIds().add(tr.getProjectId()); } diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index fd6b989773..ced59de4d4 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -486,6 +486,9 @@ export default { if(this.needRefreshModule()){ this.$emit('refreshTree'); } + if(this.selectProjectId){ + projectId = this.selectProjectId; + } this.selectRows = new Set(); this.condition.moduleIds = this.selectNodeIds; if (this.trashEnable) { diff --git a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue index 556506c192..d2dd633486 100644 --- a/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/ImportApiScenario.vue @@ -10,6 +10,7 @@ @edit="editScenario" @selection="setData" :referenced="true" + :select-project-id="cuurentProjectId" ref="apiScenarioList"/> {{ $t('api_test.scenario.reference') }} @@ -40,6 +41,7 @@ currentScenario: [], currentScenarioIds: [], moduleOptions: {}, + cuurentProjectId: "", scenarioDefinition: Object, } }, @@ -84,6 +86,7 @@ this.moduleOptions = data; }, refresh(data) { + this.cuurentProjectId = data; this.$refs.apiScenarioList.search(data); }, editScenario(row) {