fix(接口测试): 修复删除环境变量,导致环境变量不显示的缺陷
--bug=1039354 --user=王孝刚 【项目设置】github#29986,在环境设置中,当恰好是第二页或者第三页的第一条,填写的变量名跟原有变量重复时,再删除该新增变量,此时,会导致所有的变量都展示不出来,包括第一页的所有变量,也无法进行变量的添加 https://www.tapd.cn/55049933/s/1497208
This commit is contained in:
parent
0475180f2f
commit
f66fcbb6fc
|
@ -5,7 +5,6 @@ import io.metersphere.api.dto.definition.request.ParameterConfig;
|
||||||
import io.metersphere.api.dto.definition.request.controller.loop.CountController;
|
import io.metersphere.api.dto.definition.request.controller.loop.CountController;
|
||||||
import io.metersphere.api.dto.definition.request.controller.loop.MsForEachController;
|
import io.metersphere.api.dto.definition.request.controller.loop.MsForEachController;
|
||||||
import io.metersphere.api.dto.definition.request.controller.loop.MsWhileController;
|
import io.metersphere.api.dto.definition.request.controller.loop.MsWhileController;
|
||||||
import io.metersphere.api.dto.definition.request.variable.ScenarioVariable;
|
|
||||||
import io.metersphere.api.dto.shell.filter.ScriptFilter;
|
import io.metersphere.api.dto.shell.filter.ScriptFilter;
|
||||||
import io.metersphere.commons.constants.ElementConstants;
|
import io.metersphere.commons.constants.ElementConstants;
|
||||||
import io.metersphere.commons.constants.LoopConstants;
|
import io.metersphere.commons.constants.LoopConstants;
|
||||||
|
@ -14,7 +13,6 @@ import io.metersphere.plugin.core.MsTestElement;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jmeter.control.*;
|
import org.apache.jmeter.control.*;
|
||||||
import org.apache.jmeter.modifiers.CounterConfig;
|
import org.apache.jmeter.modifiers.CounterConfig;
|
||||||
|
@ -26,11 +24,8 @@ import org.apache.jmeter.testelement.TestElement;
|
||||||
import org.apache.jmeter.timers.ConstantTimer;
|
import org.apache.jmeter.timers.ConstantTimer;
|
||||||
import org.apache.jorphan.collections.HashTree;
|
import org.apache.jorphan.collections.HashTree;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ -53,32 +48,11 @@ public class MsLoopController extends MsTestElement {
|
||||||
|
|
||||||
final HashTree groupTree = controller(tree);
|
final HashTree groupTree = controller(tree);
|
||||||
// 自身场景
|
// 自身场景
|
||||||
if (CollectionUtils.isNotEmpty(config.getVariables())) {
|
if (CollectionUtils.isNotEmpty(config.getVariables()) || CollectionUtils.isNotEmpty(config.getTransferVariables())) {
|
||||||
ElementUtil.addCsvDataSet(groupTree, config.getVariables(), config, "shareMode.thread");
|
ElementUtil.addCsvDataSet(groupTree, config.getVariables(), config, "shareMode.thread");
|
||||||
ElementUtil.addCounter(groupTree, config.getVariables());
|
ElementUtil.addCounter(groupTree, config.getVariables());
|
||||||
ElementUtil.addRandom(groupTree, config.getVariables());
|
ElementUtil.addRandom(groupTree, config.getVariables());
|
||||||
}
|
}
|
||||||
// 当前引用场景
|
|
||||||
if (CollectionUtils.isNotEmpty(config.getTransferVariables())) {
|
|
||||||
final List<ScenarioVariable> variables = new LinkedList<>();
|
|
||||||
if (CollectionUtils.isEmpty(config.getVariables())) {
|
|
||||||
variables.addAll(config.getTransferVariables());
|
|
||||||
} else {
|
|
||||||
// 合并处理
|
|
||||||
Map<String, ScenarioVariable> variableMap = config.getVariables().stream().collect(Collectors.toMap(ScenarioVariable::getId, a -> a, (k1, k2) -> k1));
|
|
||||||
config.getTransferVariables().forEach(item -> {
|
|
||||||
if (!variableMap.containsKey(item.getId())) {
|
|
||||||
variables.add(item);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(variables)) {
|
|
||||||
ElementUtil.addCsvDataSet(groupTree, variables, config, "shareMode.thread");
|
|
||||||
ElementUtil.addCounter(groupTree, variables);
|
|
||||||
ElementUtil.addRandom(groupTree, variables);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 循环下都增加一个计数器,用于结果统计
|
// 循环下都增加一个计数器,用于结果统计
|
||||||
groupTree.add(addCounterConfig());
|
groupTree.add(addCounterConfig());
|
||||||
// 不打开执行成功后轮询功能,则成功后就停止循环
|
// 不打开执行成功后轮询功能,则成功后就停止循环
|
||||||
|
|
|
@ -351,16 +351,20 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
remove: function (index) {
|
remove: function (index) {
|
||||||
const dataIndex = this.pageData.findIndex((d) => d.name === index.name);
|
const dataIndex = this.pageData.findIndex((d) => d.name === index.name && d.id === index.id);
|
||||||
|
//如果是最后一个数据 删除后需要添加一个空行
|
||||||
|
if (dataIndex === this.pageData.length -1) {
|
||||||
|
index.name = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (dataIndex !== -1) {
|
if (dataIndex !== -1) {
|
||||||
this.pageData.splice(dataIndex, 1);
|
this.pageData.splice(dataIndex, 1);
|
||||||
}
|
}
|
||||||
|
const allDataIndex = this.allData.findIndex((d) => d.name === index.name && d.id === index.id);
|
||||||
const allDataIndex = this.allData.findIndex((d) => d.name === index.name);
|
|
||||||
if (allDataIndex !== -1) {
|
if (allDataIndex !== -1) {
|
||||||
this.allData.splice(allDataIndex, 1);
|
this.allData.splice(allDataIndex, 1);
|
||||||
}
|
}
|
||||||
const itemsIndex = this.items.findIndex((d) => d.name === index.name);
|
const itemsIndex = this.items.findIndex((d) => d.name === index.name && d.id === index.id);
|
||||||
if (itemsIndex !== -1) {
|
if (itemsIndex !== -1) {
|
||||||
this.items.splice(itemsIndex, 1);
|
this.items.splice(itemsIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue