From 81106b0311bf7939c82b5252db3eb03d2a5a8df6 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 1 Jun 2021 14:42:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=A0=91=E8=8A=82=E7=82=B9=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E3=80=81=E6=9B=B4=E6=94=B9=E6=A0=91=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=A0=B7=E5=BC=8F=E3=80=81=E4=BF=AE=E5=A4=8D=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=AD=A5=E9=AA=A4=E5=8D=95=E7=8B=AC=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=9B=B4=E6=94=B9=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复接口测试树节点统计缺陷、更改树节点样式、修复场景步骤单独调试无法更改环境变量的Bug --- .../post/MsJSR223PostProcessor.java | 19 +++++++++++++++++++ .../processors/pre/MsJSR223PreProcessor.java | 19 +++++++++++++++++++ .../api/service/ApiDefinitionService.java | 1 + .../api/automation/ApiAutomation.vue | 1 + .../automation/scenario/ApiScenarioModule.vue | 12 ++++++++++-- .../api/definition/ApiDefinition.vue | 1 + .../components/module/ApiModule.vue | 12 ++++++++++-- .../components/track/common/NodeTree.vue | 10 +++++++++- 8 files changed, 70 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java index a26bd1981f..ebd57596a0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.annotation.JSONType; import io.metersphere.api.dto.RunningParamKeys; import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.ParameterConfig; +import io.metersphere.api.dto.scenario.environment.EnvironmentConfig; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; @@ -14,6 +15,7 @@ import org.apache.jmeter.save.SaveService; import org.apache.jmeter.testelement.TestElement; import org.apache.jorphan.collections.HashTree; +import java.util.Collection; import java.util.List; @Data @@ -30,6 +32,23 @@ public class MsJSR223PostProcessor extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if(StringUtils.isEmpty(this.getUseEnviroment())){ + if(config.getConfig() != null){ + if(config.getProjectId() != null){ + String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid(); + this.setUseEnviroment(evnId); + }else { + Collection evnConfigList = config.getConfig().values(); + if(evnConfigList!=null && !evnConfigList.isEmpty()){ + for (EnvironmentConfig configItem : evnConfigList) { + String evnId = configItem.getApiEnvironmentid(); + this.setUseEnviroment(evnId); + break; + } + } + } + } + } //替换Metersphere环境变量 script = StringUtils.replace(script,RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getUseEnviroment()+".\""); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java index fd66961b83..109ca2049e 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.annotation.JSONType; import io.metersphere.api.dto.RunningParamKeys; import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.ParameterConfig; +import io.metersphere.api.dto.scenario.environment.EnvironmentConfig; import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; @@ -14,6 +15,7 @@ import org.apache.jmeter.save.SaveService; import org.apache.jmeter.testelement.TestElement; import org.apache.jorphan.collections.HashTree; +import java.util.Collection; import java.util.List; @Data @@ -30,6 +32,23 @@ public class MsJSR223PreProcessor extends MsTestElement { @Override public void toHashTree(HashTree tree, List hashTree, ParameterConfig config) { + if(StringUtils.isEmpty(this.getUseEnviroment())){ + if(config.getConfig() != null){ + if(config.getProjectId() != null){ + String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid(); + this.setUseEnviroment(evnId); + }else { + Collection evnConfigList = config.getConfig().values(); + if(evnConfigList!=null && !evnConfigList.isEmpty()){ + for (EnvironmentConfig configItem : evnConfigList) { + String evnId = configItem.getApiEnvironmentid(); + this.setUseEnviroment(evnId); + break; + } + } + } + } + } //替换Metersphere环境变量 script = StringUtils.replace(script,RunningParamKeys.API_ENVIRONMENT_ID,"\""+RunningParamKeys.RUNNING_PARAMS_PREFIX+this.getUseEnviroment()+".\""); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 51a5a441e3..ee05767db5 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -561,6 +561,7 @@ public class ApiDefinitionService { ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(request.getProjectId())); if (environment != null) { EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); + env.setApiEnvironmentid(environment.getId()); envConfig.put(request.getProjectId(), env); config.setConfig(envConfig); } diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index 0ec8eda914..b5d4e44dd1 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -12,6 +12,7 @@ @exportAPI="exportAPI" @exportJmx="exportJmx" @refreshAll="refreshAll" + page-source="scenario" :type="'edit'" ref="nodeTree"/> diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue index 4407ed58c2..aa6518e48e 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue @@ -4,7 +4,7 @@ diff --git a/frontend/src/business/components/api/definition/components/module/ApiModule.vue b/frontend/src/business/components/api/definition/components/module/ApiModule.vue index 1aed8ded0d..7662232be5 100644 --- a/frontend/src/business/components/api/definition/components/module/ApiModule.vue +++ b/frontend/src/business/components/api/definition/components/module/ApiModule.vue @@ -4,7 +4,7 @@ - + {{ data.caseNum }} @@ -421,6 +421,14 @@ export default { overflow: hidden; } +.count-title { + width: auto; + text-overflow: ellipsis; + white-space: nowrap; + padding: 0px 5px; + overflow: hidden; +} + .node-operate > i { color: #409eff; margin: 0px 5px;