refactor(接口测试): 场景步骤快捷添加优化,请求支持同级添加步骤

--story=1007710 --user=赵勇 接口自动化添加步骤优化 https://www.tapd.cn/55049933/s/1159490
This commit is contained in:
fit2-zhao 2022-05-17 19:30:04 +08:00 committed by fit2-zhao
parent fe5d336638
commit a7caa51135
3 changed files with 50 additions and 34 deletions

View File

@ -136,7 +136,7 @@ public class ApiScenarioEnvService {
if (!StringUtils.equalsIgnoreCase(httpSamplerProxy.getReferenced(), "Created") || (httpSamplerProxy.getIsRefEnvironment() != null &&
httpSamplerProxy.getIsRefEnvironment())) {
env.getProjectIds().add(httpSamplerProxy.getProjectId());
env.setFullUrl(false);
env.setFullUrl(httpSamplerProxy.getIsRefEnvironment() == null ? true : false);
}
} else if (StringUtils.equals(testElement.getType(), "JDBCSampler") || StringUtils.equals(testElement.getType(), "TCPSampler")) {
env.getProjectIds().add(testElement.getProjectId());

View File

@ -1151,13 +1151,14 @@ export default {
setComponent(type, this, plugin);
}
},
nodeClick(data, node) {
if ((data.referenced != 'REF' && data.referenced != 'Deleted' && !data.disabled && this.stepFilter) || data.refType === 'CASE') {
this.operatingElements = this.stepFilter.get(data.type);
} else {
this.operatingElements = [];
}
if (!this.operatingElements && this.stepFilter) {
if ((!this.operatingElements && this.stepFilter)|| this.stepFilter.get("AllSamplerProxy").indexOf(data.type) !== -1) {
this.operatingElements = this.stepFilter.get("ALL");
}
this.selectedTreeNode = data;
@ -1227,9 +1228,14 @@ export default {
addCustomizeApi(request) {
this.customizeVisible = false;
request.enable === undefined ? request.enable = true : request.enable;
if (this.selectedTreeNode !== undefined) {
this.selectedTreeNode.hashTree.push(request);
} else {
if(this.selectedTreeNode !== undefined){
if(this.stepFilter.get("AllSamplerProxy").indexOf(this.selectedTreeNode.type) !== -1){
this.scenarioDefinition.splice(this.selectedTreeNode.index,0,request);
this.$store.state.forceRerenderIndex = getUUID();
}else{
this.selectedTreeNode.hashTree.push(request) ;
}
}else{
this.scenarioDefinition.push(request);
}
this.customizeRequest = {};
@ -1250,9 +1256,14 @@ export default {
this.resetResourceId(item.hashTree);
item.enable === undefined ? item.enable = true : item.enable;
item.variableEnable = item.variableEnable === undefined ? true : item.variableEnable;
if (this.selectedTreeNode !== undefined) {
this.selectedTreeNode.hashTree.push(item);
} else {
if(this.selectedTreeNode !== undefined){
if(this.stepFilter.get("AllSamplerProxy").indexOf(this.selectedTreeNode.type) !== -1){
this.scenarioDefinition.splice(this.selectedTreeNode.index,0,item);
this.$store.state.forceRerenderIndex = getUUID();
}else{
this.selectedTreeNode.hashTree.push(item) ;
}
}else{
this.scenarioDefinition.push(item);
}
})
@ -1297,9 +1308,14 @@ export default {
if (referenced === 'REF' && request.hashTree) {
this.recursiveSorting(request.hashTree);
}
if (this.selectedTreeNode !== undefined) {
this.selectedTreeNode.hashTree.push(request);
} else {
if(this.selectedTreeNode !== undefined){
if(this.stepFilter.get("AllSamplerProxy").indexOf(this.selectedTreeNode.type) !== -1){
this.scenarioDefinition.splice(this.selectedTreeNode.index,0,request);
this.$store.state.forceRerenderIndex = getUUID();
}else{
this.selectedTreeNode.hashTree.push(request) ;
}
}else{
this.scenarioDefinition.push(request);
}
},

View File

@ -145,56 +145,56 @@ export function buttons(this_) {
];
return buttons.filter(btn => btn.show);
}
export function setNode(_this,node) {
if(_this.selectedTreeNode !== undefined){
if(_this.stepFilter.get("AllSamplerProxy").indexOf(_this.selectedTreeNode.type) !== -1){
_this.scenarioDefinition.splice(_this.selectedTreeNode.index,0,node);
_this.$store.state.forceRerenderIndex = getUUID();
}else{
_this.selectedTreeNode.hashTree.push(node) ;
}
}else{
_this.scenarioDefinition.push(node);
}
}
export function setComponent(type, _this, plugin) {
switch (type) {
case ELEMENT_TYPE.IfController:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new IfController()) :
_this.scenarioDefinition.push(new IfController());
setNode(_this,new IfController());
break;
case ELEMENT_TYPE.ConstantTimer:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new ConstantTimer({label: "SCENARIO-REF-STEP"})) :
_this.scenarioDefinition.push(new ConstantTimer());
setNode(_this,new ConstantTimer({label: "SCENARIO-REF-STEP"}));
break;
case ELEMENT_TYPE.JSR223Processor:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({label: "SCENARIO-REF-STEP"})) :
_this.scenarioDefinition.push(new JSR223Processor());
setNode(_this,new JSR223Processor({label: "SCENARIO-REF-STEP"}));
break;
case ELEMENT_TYPE.JSR223PreProcessor:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PreProcessor", label: "SCENARIO-REF-STEP"})) :
_this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PreProcessor"}));
setNode(_this, new JSR223Processor({type: "JSR223PreProcessor", label: "SCENARIO-REF-STEP"}));
break;
case ELEMENT_TYPE.JSR223PostProcessor:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JSR223Processor({type: "JSR223PostProcessor", label: "SCENARIO-REF-STEP"})) :
_this.scenarioDefinition.push(new JSR223Processor({type: "JSR223PostProcessor"}));
setNode(_this, new JSR223Processor({type: "JSR223PostProcessor", label: "SCENARIO-REF-STEP"}));
break;
case ELEMENT_TYPE.JDBCPreProcessor:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPreProcessor", label: "SCENARIO-REF-STEP"})) :
_this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPreProcessor"}));
setNode(_this, new JDBCProcessor({type: "JDBCPreProcessor", label: "SCENARIO-REF-STEP"}));
break;
case ELEMENT_TYPE.JDBCPostProcessor:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new JDBCProcessor({type: "JDBCPostProcessor", label: "SCENARIO-REF-STEP"})) :
_this.scenarioDefinition.push(new JDBCProcessor({type: "JDBCPostProcessor"}));
setNode(_this, new JDBCProcessor({type: "JDBCPostProcessor", label: "SCENARIO-REF-STEP"}));
break;
case ELEMENT_TYPE.Assertions:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Assertions({label: "SCENARIO-REF-STEP", id: getUUID()})) :
_this.scenarioDefinition.push(new Assertions());
setNode(_this, new Assertions({label: "SCENARIO-REF-STEP", id: getUUID()}));
break;
case ELEMENT_TYPE.Extract:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new Extract({label: "SCENARIO-REF-STEP", id: getUUID()})) :
_this.scenarioDefinition.push(new Extract());
setNode(_this, new Extract({label: "SCENARIO-REF-STEP", id: getUUID()}));
break;
case ELEMENT_TYPE.CustomizeReq:
_this.customizeRequest = {protocol: "HTTP", type: "API", hashTree: [], referenced: 'Created', active: false};
_this.customizeVisible = true;
break;
case ELEMENT_TYPE.LoopController:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new LoopController()) :
_this.scenarioDefinition.push(new LoopController());
setNode(_this, new LoopController());
break;
case ELEMENT_TYPE.TransactionController:
_this.selectedTreeNode !== undefined ? _this.selectedTreeNode.hashTree.push(new TransactionController()) :
_this.scenarioDefinition.push(new TransactionController());
setNode(_this, new TransactionController());
break;
case ELEMENT_TYPE.scenario:
_this.isBtnHide = true;