refactor(接口测试): 场景列表补充按照环境筛选功能
--bug=1017922 --user=赵勇 【接口测试】接口自动化场景列表的运行环境不可筛选-接口case列表运行环境可以筛选 https://www.tapd.cn/55049933/s/1260705
This commit is contained in:
parent
b60b9c3b04
commit
04daa53a00
|
@ -448,7 +448,7 @@ public class ElementUtil {
|
|||
ApiTestEnvironmentWithBLOBs environment = apiTestEnvironmentService.get(finalEnvironmentMap.get(projectId));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
env.setApiEnvironmentid(environment.getId());
|
||||
env.setEnvironmentId(environment.getId());
|
||||
envConfig.put(projectId, env);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -243,7 +243,7 @@ public class MsScenario extends MsTestElement {
|
|||
ApiTestEnvironmentWithBLOBs environment = apiTestEnvironmentService.get(this.environmentMap.get(projectId));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
env.setApiEnvironmentid(environment.getId());
|
||||
env.setEnvironmentId(environment.getId());
|
||||
envConfig.put(projectId, env);
|
||||
if (StringUtils.equals(environment.getName(), MockConfigStaticData.MOCK_EVN_NAME)) {
|
||||
this.setMockEnvironment(true);
|
||||
|
@ -261,7 +261,7 @@ public class MsScenario extends MsTestElement {
|
|||
ApiTestEnvironmentWithBLOBs environment = apiTestEnvironmentService.get(environmentMap.get(projectId));
|
||||
if (environment != null && StringUtils.isNotEmpty(environment.getConfig())) {
|
||||
EnvironmentConfig env = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
env.setApiEnvironmentid(environment.getId());
|
||||
env.setEnvironmentId(environment.getId());
|
||||
envConfig.put(projectId, env);
|
||||
if (StringUtils.equals(environment.getName(), MockConfigStaticData.MOCK_EVN_NAME)) {
|
||||
this.setMockEnvironment(true);
|
||||
|
|
|
@ -36,13 +36,13 @@ public class MsJSR223Processor extends MsTestElement {
|
|||
if (StringUtils.isEmpty(this.getEnvironmentId())) {
|
||||
if (config.getConfig() != null) {
|
||||
if (config.getProjectId() != null) {
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getEnvironmentId();
|
||||
this.setEnvironmentId(evnId);
|
||||
} else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if (evnConfigList != null && !evnConfigList.isEmpty()) {
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
String evnId = configItem.getEnvironmentId();
|
||||
this.setEnvironmentId(evnId);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -118,8 +118,8 @@ public class MsJDBCPostProcessor extends MsTestElement {
|
|||
if (config.isEffective(this.getProjectId()) && CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())
|
||||
&& isDataSource(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())) {
|
||||
EnvironmentConfig environmentConfig = config.getConfig().get(this.getProjectId());
|
||||
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getApiEnvironmentid())) {
|
||||
this.environmentId = environmentConfig.getApiEnvironmentid();
|
||||
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getEnvironmentId())) {
|
||||
this.environmentId = environmentConfig.getEnvironmentId();
|
||||
}
|
||||
this.initDataSource();
|
||||
} else {
|
||||
|
|
|
@ -34,13 +34,13 @@ public class MsJSR223PostProcessor extends MsTestElement {
|
|||
if (StringUtils.isEmpty(this.getEnvironmentId())) {
|
||||
if (config.getConfig() != null) {
|
||||
if (config.getProjectId() != null && config.getConfig().containsKey(config.getProjectId())) {
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getEnvironmentId();
|
||||
this.setEnvironmentId(evnId);
|
||||
} else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if (evnConfigList != null && !evnConfigList.isEmpty()) {
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
String evnId = configItem.getEnvironmentId();
|
||||
this.setEnvironmentId(evnId);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -107,8 +107,8 @@ public class MsJDBCPreProcessor extends MsTestElement {
|
|||
if (config.isEffective(this.getProjectId()) && CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())
|
||||
&& isDataSource(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())) {
|
||||
EnvironmentConfig environmentConfig = config.getConfig().get(this.getProjectId());
|
||||
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getApiEnvironmentid())) {
|
||||
this.environmentId = environmentConfig.getApiEnvironmentid();
|
||||
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getEnvironmentId())) {
|
||||
this.environmentId = environmentConfig.getEnvironmentId();
|
||||
}
|
||||
this.initDataSource();
|
||||
} else {
|
||||
|
|
|
@ -39,13 +39,13 @@ public class MsJSR223PreProcessor extends MsTestElement {
|
|||
if (StringUtils.isEmpty(this.getEnvironmentId())) {
|
||||
if (config.getConfig() != null) {
|
||||
if (config.getProjectId() != null) {
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getApiEnvironmentid();
|
||||
String evnId = config.getConfig().get(config.getProjectId()).getEnvironmentId();
|
||||
this.setEnvironmentId(evnId);
|
||||
} else {
|
||||
Collection<EnvironmentConfig> evnConfigList = config.getConfig().values();
|
||||
if (evnConfigList != null && !evnConfigList.isEmpty()) {
|
||||
for (EnvironmentConfig configItem : evnConfigList) {
|
||||
String evnId = configItem.getApiEnvironmentid();
|
||||
String evnId = configItem.getEnvironmentId();
|
||||
this.setEnvironmentId(evnId);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class MsDubboSampler extends MsTestElement {
|
|||
String environmentId = this.getEnvironmentId();
|
||||
if (environmentId == null) {
|
||||
if (StringUtils.isEmpty(this.useEnvironment) && envConfig != null) {
|
||||
environmentId = envConfig.getApiEnvironmentid();
|
||||
environmentId = envConfig.getEnvironmentId();
|
||||
} else {
|
||||
environmentId = this.useEnvironment;
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
|
||||
private void initConnectAndResponseTimeout(ParameterConfig config) {
|
||||
if (config.isEffective(this.getProjectId())) {
|
||||
String useEvnId = config.getConfig().get(this.getProjectId()).getApiEnvironmentid();
|
||||
String useEvnId = config.getConfig().get(this.getProjectId()).getEnvironmentId();
|
||||
if (StringUtils.isNotEmpty(useEvnId) && !StringUtils.equals(useEvnId, this.getEnvironmentId())) {
|
||||
this.setEnvironmentId(useEvnId);
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
if (config.isEffective(this.getProjectId())) {
|
||||
EnvironmentConfig environmentConfig = config.getConfig().get(this.getProjectId());
|
||||
if (environmentConfig != null) {
|
||||
String useEvnId = environmentConfig.getApiEnvironmentid();
|
||||
String useEvnId = environmentConfig.getEnvironmentId();
|
||||
if (this.authManager == null && environmentConfig.getAuthManager() != null && environmentConfig.getAuthManager().getAuthManager() != null) {
|
||||
this.authManager = environmentConfig.getAuthManager().getAuthManager();
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
MSException.throwException(this.getName() + "接口,对应的环境无协议,请完善环境信息");
|
||||
}
|
||||
if (StringUtils.isEmpty(this.useEnvironment)) {
|
||||
this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid();
|
||||
this.useEnvironment = config.getConfig().get(this.getProjectId()).getEnvironmentId();
|
||||
}
|
||||
String url = httpConfig.getProtocol() + "://" + httpConfig.getSocket();
|
||||
if (isUrl()) {
|
||||
|
|
|
@ -115,8 +115,8 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
if (config.isEffective(this.getProjectId()) && CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())
|
||||
&& isDataSource(config.getConfig().get(this.getProjectId()).getDatabaseConfigs())) {
|
||||
EnvironmentConfig environmentConfig = config.getConfig().get(this.getProjectId());
|
||||
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getApiEnvironmentid())) {
|
||||
this.environmentId = environmentConfig.getApiEnvironmentid();
|
||||
if (environmentConfig.getDatabaseConfigs() != null && StringUtils.isNotEmpty(environmentConfig.getEnvironmentId())) {
|
||||
this.environmentId = environmentConfig.getEnvironmentId();
|
||||
}
|
||||
this.dataSource = null;
|
||||
envConfig = this.initDataSource();
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
public class EnvironmentConfig {
|
||||
private String apiEnvironmentid;
|
||||
private String environmentId;
|
||||
private CommonConfig commonConfig;
|
||||
private HttpConfig httpConfig;
|
||||
private List<DatabaseConfig> databaseConfigs;
|
||||
|
|
|
@ -179,7 +179,7 @@ public class ApiExecuteService {
|
|||
ApiTestEnvironmentWithBLOBs environment = apiTestEnvironmentService.get(map.get(key));
|
||||
if (environment != null) {
|
||||
EnvironmentConfig env = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
env.setApiEnvironmentid(environment.getId());
|
||||
env.setEnvironmentId(environment.getId());
|
||||
envConfig.put(key, env);
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class ApiExecuteService {
|
|||
Map<String, EnvironmentConfig> envConfig = new HashMap<>(16);
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig environmentConfig = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
environmentConfig.setApiEnvironmentid(environment.getId());
|
||||
environmentConfig.setEnvironmentId(environment.getId());
|
||||
envConfig.put(testCaseWithBLOBs.getProjectId(), environmentConfig);
|
||||
parameterConfig.setConfig(envConfig);
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ public class ApiScenarioEnvService {
|
|||
ApiTestEnvironmentWithBLOBs environment = apiTestEnvironmentService.get(environmentMap.get(projectId));
|
||||
if (environment != null && environment.getConfig() != null) {
|
||||
EnvironmentConfig env = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||
env.setApiEnvironmentid(environment.getId());
|
||||
env.setEnvironmentId(environment.getId());
|
||||
envConfig.put(projectId, env);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -392,6 +392,14 @@
|
|||
#{value}
|
||||
</foreach>
|
||||
</when>
|
||||
|
||||
<when test="key=='environment_map'">
|
||||
and api_scenario.environment_json REGEXP CONCAT_WS('|',
|
||||
<foreach collection="values" item="item" open="" close="" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
</foreach>
|
||||
|
|
|
@ -154,6 +154,7 @@
|
|||
<ms-table-column
|
||||
:field="item"
|
||||
:fields-width="fieldsWidth"
|
||||
:filters="environmentsFilters"
|
||||
prop="environmentMap"
|
||||
:label="$t('commons.environment')"
|
||||
min-width="180">
|
||||
|
@ -375,6 +376,7 @@ import {getEnvironmentByProjectId} from "metersphere-frontend/src/api/environmen
|
|||
import {REPORT_STATUS} from "@/business/commons/js/commons";
|
||||
import {usePerformanceStore} from "@/store";
|
||||
import {request} from "metersphere-frontend/src/plugins/request"
|
||||
import {parseEnvironment} from "@/business/environment/model/EnvironmentModel";
|
||||
|
||||
const performanceStore = usePerformanceStore();
|
||||
export default {
|
||||
|
@ -454,6 +456,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
environmentsFilters: [],
|
||||
projectName: "",
|
||||
result: false,
|
||||
tableHeaderKey: "API_SCENARIO",
|
||||
|
@ -464,6 +467,7 @@ export default {
|
|||
condition: {
|
||||
components: this.trashEnable ? API_SCENARIO_CONFIGS_TRASH : API_SCENARIO_CONFIGS
|
||||
},
|
||||
projectId: "",
|
||||
scenarioId: "",
|
||||
isMoveBatch: true,
|
||||
currentScenario: {},
|
||||
|
@ -636,7 +640,7 @@ export default {
|
|||
this.getProjectName();
|
||||
}
|
||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||
|
||||
this.initEnvironment();
|
||||
if (this.trashEnable) {
|
||||
this.condition.filters = {status: ["Trash"]};
|
||||
this.condition.moduleIds = [];
|
||||
|
@ -738,9 +742,18 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
selectByParam() {
|
||||
this.changeSelectDataRangeAll();
|
||||
this.search();
|
||||
initEnvironment() {
|
||||
if (this.projectId) {
|
||||
getEnvironmentByProjectId(this.projectId).then(response => {
|
||||
this.environments = response.data;
|
||||
this.environments.forEach(environment => {
|
||||
parseEnvironment(environment);
|
||||
});
|
||||
this.environmentsFilters = response.data.map(u => {
|
||||
return {text: u.name, value: u.id};
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
search(projectId) {
|
||||
if (this.needRefreshModule()) {
|
||||
|
@ -945,16 +958,6 @@ export default {
|
|||
});
|
||||
}
|
||||
},
|
||||
getEnvsOptions(option) {
|
||||
getEnvironmentByProjectId(this.projectId).then(response => {
|
||||
option.push(...response.data);
|
||||
option.forEach(environment => {
|
||||
if (!(environment.config instanceof Object)) {
|
||||
environment.config = JSON.parse(environment.config);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
cancel() {
|
||||
this.planVisible = false;
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<ms-container>
|
||||
<ms-aside-container :height="'calc(100vh - 90px)'">
|
||||
<div @click="showAll">
|
||||
<div @click="showAll" style="overflow-x: hidden">
|
||||
<div class="tip">{{ $t('test_track.plan_view.base_info') }}</div>
|
||||
<el-form :model="currentScenario" label-position="right" label-width="80px" size="small" :rules="rules"
|
||||
ref="currentScenario">
|
||||
|
|
Loading…
Reference in New Issue