fix: 修复接口测试树节点统计缺陷、更改树节点样式、修复场景步骤单独调试无法更改环境变量的Bug

修复接口测试树节点统计缺陷、更改树节点样式、修复场景步骤单独调试无法更改环境变量的Bug
This commit is contained in:
song-tianyang 2021-06-01 14:42:32 +08:00 committed by 刘瑞斌
parent fd968dfbfa
commit 81106b0311
8 changed files with 70 additions and 5 deletions

View File

@ -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<MsTestElement> 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<EnvironmentConfig> 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()+".\"");

View File

@ -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<MsTestElement> 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<EnvironmentConfig> 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()+".\"");

View File

@ -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);
}

View File

@ -12,6 +12,7 @@
@exportAPI="exportAPI"
@exportJmx="exportJmx"
@refreshAll="refreshAll"
page-source="scenario"
:type="'edit'"
ref="nodeTree"/>
</ms-aside-container>

View File

@ -4,7 +4,7 @@
<slot name="header"></slot>
<ms-node-tree
:is-display="openType"
:is-display="getIsRelevance"
v-loading="result.loading"
:tree-nodes="data"
:allLabel="$t('commons.all_module_title')"
@ -69,7 +69,8 @@
},
showOperator: Boolean,
relevanceProjectId: String,
planId: String
planId: String,
pageSource:String,
},
computed: {
isPlanModel() {
@ -81,6 +82,13 @@
projectId() {
return getCurrentProjectID();
},
getIsRelevance(){
if(this.pageSource !== 'scenario'){
return this.openType;
}else {
return "scenario";
}
}
},
data() {
return {

View File

@ -14,6 +14,7 @@
@setNodeTree="setNodeTree"
@enableTrash="enableTrash"
:type="'edit'"
page-source="definition"
ref="nodeTree"/>
</ms-aside-container>

View File

@ -4,7 +4,7 @@
<slot name="header"></slot>
<ms-node-tree
:is-display="openType"
:is-display="getIsRelevance"
v-loading="result.loading"
:tree-nodes="data"
:type="isReadOnly ? 'view' : 'edit'"
@ -82,7 +82,8 @@
showOperator: Boolean,
planId: String,
relevanceProjectId: String,
reviewId: String
reviewId: String,
pageSource:String,
},
computed: {
isPlanModel() {
@ -97,6 +98,13 @@
projectId() {
return getCurrentProjectID();
},
getIsRelevance(){
if(this.pageSource !== 'definition'){
return this.openType;
}else {
return "definition";
}
}
},
mounted() {
this.initProtocol();

View File

@ -30,7 +30,7 @@
<i class="el-icon-folder"/>
</span>
<span v-if="!data.isEdit" class="node-title" v-text="data.name"/>
<span class="node-title" v-if="isDisplay!=='relevance'">
<span class="count-title" v-if="isDisplay!=='relevance'">
<span style="color: #6C317C">{{ data.caseNum }}</span>
</span>
<span v-if="!disabled" class="node-operate child">
@ -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;