fix(接口自动化): 修复场景导入,切换条件数据查不到问题

This commit is contained in:
fit2-zhao 2021-06-29 13:35:24 +08:00 committed by fit2-zhao
parent 73bed3ccc1
commit 7911e24766
3 changed files with 16 additions and 10 deletions

View File

@ -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;
@ -589,6 +588,9 @@ public class ApiAutomationService {
List<MsTestElement> 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")) {
@ -603,7 +605,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);
}
@ -635,7 +637,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);
}
@ -644,9 +646,7 @@ public class ApiAutomationService {
env.getProjectIds().add(tr.getProjectId());
}
}
if (!tr.isEnable()) {
continue;
}
if (StringUtils.equals(tr.getType(), "scenario")) {
env.getProjectIds().add(tr.getProjectId());
}
@ -663,6 +663,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")) {
@ -675,7 +678,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());
}
@ -715,9 +718,6 @@ public class ApiAutomationService {
env.getProjectIds().add(tr.getProjectId());
}
}
if (!tr.isEnable()) {
continue;
}
if (StringUtils.equals(tr.getType(), "scenario")) {
env.getProjectIds().add(tr.getProjectId());
}

View File

@ -489,6 +489,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) {

View File

@ -10,6 +10,7 @@
@edit="editScenario"
@selection="setData"
:referenced="true"
:select-project-id="cuurentProjectId"
ref="apiScenarioList"/>
<el-button style="float: right;margin: 10px" @click="importApiScenario" type="primary">{{ $t('api_test.scenario.reference') }}</el-button>
@ -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) {