fix(接口自动化): 跨项目添加场景兼容历史数据
This commit is contained in:
parent
6417a131b0
commit
c9e4e32fca
|
@ -15,6 +15,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
|
|||
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
@ -93,7 +94,14 @@ public class MsScenario extends MsTestElement {
|
|||
config.setStep(this.getName());
|
||||
config.setStepType("SCENARIO");
|
||||
config.setEnableCookieShare(enableCookieShare);
|
||||
Map<String,EnvironmentConfig> envConfig = new HashMap<>();
|
||||
Map<String,EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||
// 兼容历史数据
|
||||
if (environmentMap == null || environmentMap.isEmpty()) {
|
||||
environmentMap = new HashMap<>(16);
|
||||
if (StringUtils.isNotBlank(environmentId)) {
|
||||
environmentMap.put(SessionUtils.getCurrentProjectId(), environmentId);
|
||||
}
|
||||
}
|
||||
if (environmentMap != null && !environmentMap.isEmpty()) {
|
||||
environmentMap.keySet().forEach(projectId -> {
|
||||
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
|
||||
|
|
|
@ -922,7 +922,12 @@ export default {
|
|||
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||
if (obj) {
|
||||
this.currentEnvironmentId = obj.environmentId;
|
||||
this.projectEnvMap = this.objToStrMap(obj.environmentMap);
|
||||
if (obj.environmentMap) {
|
||||
this.projectEnvMap = this.objToStrMap(obj.environmentMap);
|
||||
} else {
|
||||
// 兼容历史数据
|
||||
this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId);
|
||||
}
|
||||
this.currentScenario.variables = [];
|
||||
let index = 1;
|
||||
if (obj.variables) {
|
||||
|
|
Loading…
Reference in New Issue