fix(场景自动化): 禁用场景步骤仍要求选择环境
This commit is contained in:
parent
491dd7fc27
commit
ab0f6d33c0
|
@ -392,9 +392,11 @@ public class ApiAutomationService {
|
||||||
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
|
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
|
||||||
http.setUrl(apiDefinition.getPath());
|
http.setUrl(apiDefinition.getPath());
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(http.getUrl()) || !isURL(http.getUrl())) {
|
if (http.isEnable()) {
|
||||||
env.getProjectIds().add(http.getProjectId());
|
if (StringUtils.isBlank(http.getUrl()) || !isURL(http.getUrl())) {
|
||||||
env.setFullUrl(false);
|
env.getProjectIds().add(http.getProjectId());
|
||||||
|
env.setFullUrl(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equals(tr.getType(), "TCPSampler")) {
|
} else if (StringUtils.equals(tr.getType(), "TCPSampler")) {
|
||||||
if (StringUtils.equals(tr.getRefType(), "CASE")) {
|
if (StringUtils.equals(tr.getRefType(), "CASE")) {
|
||||||
|
@ -405,11 +407,13 @@ public class ApiAutomationService {
|
||||||
env.getProjectIds().add(apiDefinition.getProjectId());
|
env.getProjectIds().add(apiDefinition.getProjectId());
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equals(tr.getType(), "scenario")) {
|
} else if (StringUtils.equals(tr.getType(), "scenario")) {
|
||||||
ApiScenarioDTO apiScenario = getApiScenario(tr.getId());
|
if (tr.isEnable()) {
|
||||||
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
ApiScenarioDTO apiScenario = getApiScenario(tr.getId());
|
||||||
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
||||||
LinkedList<MsTestElement> hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>(){});
|
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
||||||
tr.setHashTree(hashTree1);
|
LinkedList<MsTestElement> hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>(){});
|
||||||
|
tr.setHashTree(hashTree1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) {
|
if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) {
|
||||||
|
@ -425,6 +429,9 @@ public class ApiAutomationService {
|
||||||
env.getProjectIds().add(tr.getProjectId());
|
env.getProjectIds().add(tr.getProjectId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!tr.isEnable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (CollectionUtils.isNotEmpty(tr.getHashTree())) {
|
if (CollectionUtils.isNotEmpty(tr.getHashTree())) {
|
||||||
getHashTree(tr.getHashTree(), env);
|
getHashTree(tr.getHashTree(), env);
|
||||||
}
|
}
|
||||||
|
@ -452,9 +459,11 @@ public class ApiAutomationService {
|
||||||
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
|
ApiDefinition apiDefinition = apiDefinitionService.get(tr.getId());
|
||||||
http.setUrl(apiDefinition.getPath());
|
http.setUrl(apiDefinition.getPath());
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(http.getUrl()) || !this.isURL(http.getUrl())) {
|
if (http.isEnable()) {
|
||||||
env.setFullUrl(false);
|
if (StringUtils.isBlank(http.getUrl()) || !this.isURL(http.getUrl())) {
|
||||||
env.getProjectIds().add(http.getProjectId());
|
env.setFullUrl(false);
|
||||||
|
env.getProjectIds().add(http.getProjectId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equals(tr.getType(), "TCPSampler")) {
|
} else if (StringUtils.equals(tr.getType(), "TCPSampler")) {
|
||||||
if (StringUtils.equals(tr.getRefType(), "CASE")) {
|
if (StringUtils.equals(tr.getRefType(), "CASE")) {
|
||||||
|
@ -465,11 +474,13 @@ public class ApiAutomationService {
|
||||||
env.getProjectIds().add(apiDefinition.getProjectId());
|
env.getProjectIds().add(apiDefinition.getProjectId());
|
||||||
}
|
}
|
||||||
} else if (StringUtils.equals(tr.getType(), "scenario")) {
|
} else if (StringUtils.equals(tr.getType(), "scenario")) {
|
||||||
ApiScenarioDTO apiScenario = getApiScenario(tr.getId());
|
if (tr.isEnable()) {
|
||||||
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
ApiScenarioDTO apiScenario = getApiScenario(tr.getId());
|
||||||
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
String scenarioDefinition = apiScenario.getScenarioDefinition();
|
||||||
LinkedList<MsTestElement> hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>(){});
|
JSONObject element1 = JSON.parseObject(scenarioDefinition);
|
||||||
tr.setHashTree(hashTree1);
|
LinkedList<MsTestElement> hashTree1 = mapper.readValue(element1.getString("hashTree"), new TypeReference<LinkedList<MsTestElement>>(){});
|
||||||
|
tr.setHashTree(hashTree1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) {
|
if (StringUtils.equals(tr.getType(), "HTTPSamplerProxy")) {
|
||||||
|
@ -485,6 +496,9 @@ public class ApiAutomationService {
|
||||||
env.getProjectIds().add(tr.getProjectId());
|
env.getProjectIds().add(tr.getProjectId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!tr.isEnable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (CollectionUtils.isNotEmpty(tr.getHashTree())) {
|
if (CollectionUtils.isNotEmpty(tr.getHashTree())) {
|
||||||
getHashTree(tr.getHashTree(), env);
|
getHashTree(tr.getHashTree(), env);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="5">
|
<el-col :span="5">
|
||||||
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
<env-popover :env-map="projectEnvMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
||||||
:project-list="projectList" ref="envPopover"/>
|
@showPopover="showPopover" :project-list="projectList" ref="envPopover"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||||
|
@ -205,8 +205,8 @@
|
||||||
<!--步骤最大化-->
|
<!--步骤最大化-->
|
||||||
<ms-drawer :visible="drawer" :size="100" @close="close" direction="right" :show-full-screen="false" :is-show-close="false" style="overflow: hidden">
|
<ms-drawer :visible="drawer" :size="100" @close="close" direction="right" :show-full-screen="false" :is-show-close="false" style="overflow: hidden">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<scenario-header :currentScenario="currentScenario" :projectEnvMap="projectEnvMap" :projectIds="projectIds" :projectList="projectList" :scenarioDefinition="scenarioDefinition" :enableCookieShare="enableCookieShare"
|
<scenario-header :currentScenario="currentScenario" :projectEnvMap="projectEnvMap" :projectIds.sync="projectIds" :projectList="projectList" :scenarioDefinition="scenarioDefinition" :enableCookieShare="enableCookieShare"
|
||||||
@closePage="close" @unFullScreen="unFullScreen" @showAllBtn="showAllBtn" @runDebug="runDebug" @setProjectEnvMap="setProjectEnvMap" @showScenarioParameters="showScenarioParameters" @setCookieShare="setCookieShare" ref="maximizeHeader"/>
|
:isFullUrl.sync="isFullUrl" @closePage="close" @unFullScreen="unFullScreen" @showAllBtn="showAllBtn" @runDebug="runDebug" @setProjectEnvMap="setProjectEnvMap" @showScenarioParameters="showScenarioParameters" @setCookieShare="setCookieShare" ref="maximizeHeader"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<maximize-scenario :scenario-definition="scenarioDefinition" :envMap="projectEnvMap" :moduleOptions="moduleOptions"
|
<maximize-scenario :scenario-definition="scenarioDefinition" :envMap="projectEnvMap" :moduleOptions="moduleOptions"
|
||||||
|
@ -778,9 +778,9 @@
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
});
|
});
|
||||||
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
// let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||||
definition.hashTree = this.scenarioDefinition;
|
// definition.hashTree = this.scenarioDefinition;
|
||||||
this.getEnv(JSON.stringify(definition));
|
// this.getEnv(JSON.stringify(definition));
|
||||||
},
|
},
|
||||||
runDebug() {
|
runDebug() {
|
||||||
/*触发执行操作*/
|
/*触发执行操作*/
|
||||||
|
@ -789,24 +789,28 @@
|
||||||
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||||
definition.hashTree = this.scenarioDefinition;
|
definition.hashTree = this.scenarioDefinition;
|
||||||
this.getEnv(JSON.stringify(definition)).then(() => {
|
this.getEnv(JSON.stringify(definition)).then(() => {
|
||||||
let sign = this.$refs.envPopover.checkEnv(this.isFullUrl);
|
let promise = this.$refs.envPopover.initEnv();
|
||||||
if (!sign) {
|
promise.then(() => {
|
||||||
return;
|
let sign = this.$refs.envPopover.checkEnv(this.isFullUrl);
|
||||||
}
|
if (!sign) {
|
||||||
this.editScenario().then(() => {
|
return;
|
||||||
this.debugData = {
|
}
|
||||||
id: this.currentScenario.id,
|
this.editScenario().then(() => {
|
||||||
name: this.currentScenario.name,
|
this.debugData = {
|
||||||
type: "scenario",
|
id: this.currentScenario.id,
|
||||||
variables: this.currentScenario.variables,
|
name: this.currentScenario.name,
|
||||||
referenced: 'Created',
|
type: "scenario",
|
||||||
enableCookieShare: this.enableCookieShare,
|
variables: this.currentScenario.variables,
|
||||||
headers: this.currentScenario.headers,
|
referenced: 'Created',
|
||||||
environmentMap: this.projectEnvMap,
|
enableCookieShare: this.enableCookieShare,
|
||||||
hashTree: this.scenarioDefinition
|
headers: this.currentScenario.headers,
|
||||||
};
|
environmentMap: this.projectEnvMap,
|
||||||
this.reportId = getUUID().substring(0, 8);
|
hashTree: this.scenarioDefinition
|
||||||
|
};
|
||||||
|
this.reportId = getUUID().substring(0, 8);
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1002,7 +1006,7 @@
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
this.path = "/api/automation/update";
|
this.path = "/api/automation/update";
|
||||||
if (response.data.scenarioDefinition != null) {
|
if (response.data.scenarioDefinition != null) {
|
||||||
this.getEnv(response.data.scenarioDefinition);
|
// this.getEnv(response.data.scenarioDefinition);
|
||||||
let obj = JSON.parse(response.data.scenarioDefinition);
|
let obj = JSON.parse(response.data.scenarioDefinition);
|
||||||
if (obj) {
|
if (obj) {
|
||||||
this.currentEnvironmentId = obj.environmentId;
|
this.currentEnvironmentId = obj.environmentId;
|
||||||
|
@ -1138,6 +1142,13 @@
|
||||||
close(name) {
|
close(name) {
|
||||||
this.drawer = false;
|
this.drawer = false;
|
||||||
this.$emit('closePage', name);
|
this.$emit('closePage', name);
|
||||||
|
},
|
||||||
|
showPopover() {
|
||||||
|
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||||
|
definition.hashTree = this.scenarioDefinition;
|
||||||
|
this.getEnv(JSON.stringify(definition)).then(() => {
|
||||||
|
this.$refs.envPopover.openEnvSelect();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,17 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showPopover() {
|
showPopover() {
|
||||||
this.$refs.envSelect.open();
|
this.$emit("showPopover");
|
||||||
|
},
|
||||||
|
openEnvSelect() {
|
||||||
|
return this.$refs.envSelect.open();
|
||||||
},
|
},
|
||||||
setProjectEnvMap(map) {
|
setProjectEnvMap(map) {
|
||||||
this.$emit("setProjectEnvMap", map);
|
this.$emit("setProjectEnvMap", map);
|
||||||
},
|
},
|
||||||
|
initEnv() {
|
||||||
|
return this.$refs.envSelect.initEnv();
|
||||||
|
},
|
||||||
checkEnv(data) {
|
checkEnv(data) {
|
||||||
return this.$refs.envSelect.checkEnv(data);
|
return this.$refs.envSelect.checkEnv(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,14 @@
|
||||||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||||
:value="environment.id"/>
|
:value="environment.id"/>
|
||||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
<el-button class="ms-scenario-button" size="mini" type="primary"
|
||||||
|
@click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<template v-slot:empty>
|
<template v-slot:empty>
|
||||||
<div class="empty-environment">
|
<div class="empty-environment">
|
||||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
<el-button class="ms-scenario-button" size="mini" type="primary"
|
||||||
|
@click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
{{ $t('api_test.environment.environment_config') }}
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,35 +31,37 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
|
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
|
||||||
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
|
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
|
||||||
import {ELEMENTS} from "./Setting";
|
import {ELEMENTS} from "./Setting";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "EnvironmentSelect",
|
name: "EnvironmentSelect",
|
||||||
components: {ApiEnvironmentConfig},
|
components: {ApiEnvironmentConfig},
|
||||||
props: {
|
props: {
|
||||||
envMap: Map,
|
envMap: Map,
|
||||||
projectIds: Set,
|
projectIds: Set,
|
||||||
projectList: Array
|
projectList: Array
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
data: [],
|
data: [],
|
||||||
result: {},
|
result: {},
|
||||||
projects: [],
|
projects: [],
|
||||||
environments: [],
|
environments: [],
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
isFullUrl: true,
|
isFullUrl: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
this.projectIds.forEach(id => {
|
let arr = [];
|
||||||
const project = this.projectList.find(p => p.id === id);
|
this.projectIds.forEach(id => {
|
||||||
if (project) {
|
const project = this.projectList.find(p => p.id === id);
|
||||||
let item = {id: id, envs: [], selectEnv: ""};
|
if (project) {
|
||||||
this.data.push(item);
|
let item = {id: id, envs: [], selectEnv: ""};
|
||||||
|
this.data.push(item);
|
||||||
|
let p = new Promise(resolve => {
|
||||||
this.result = this.$get('/api/environment/list/' + id, res => {
|
this.result = this.$get('/api/environment/list/' + id, res => {
|
||||||
let envs = res.data;
|
let envs = res.data;
|
||||||
envs.forEach(environment => {
|
envs.forEach(environment => {
|
||||||
|
@ -69,220 +73,228 @@
|
||||||
let envId = this.envMap.get(id);
|
let envId = this.envMap.get(id);
|
||||||
// 选中环境是否存在
|
// 选中环境是否存在
|
||||||
temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId;
|
temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId;
|
||||||
|
resolve();
|
||||||
})
|
})
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
open() {
|
|
||||||
this.data = [];
|
|
||||||
if (this.projectIds.size > 0) {
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getProjectName(id) {
|
|
||||||
const project = this.projectList.find(p => p.id === id);
|
|
||||||
return project ? project.name : "";
|
|
||||||
},
|
|
||||||
openEnvironmentConfig(projectId, envId) {
|
|
||||||
if (!projectId) {
|
|
||||||
this.$error(this.$t('api_test.select_project'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$refs.environmentConfig.open(projectId, envId);
|
|
||||||
},
|
|
||||||
handleConfirm() {
|
|
||||||
let map = new Map();
|
|
||||||
let sign = true;
|
|
||||||
this.data.forEach(dt => {
|
|
||||||
if (!dt.selectEnv) {
|
|
||||||
sign = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
map.set(dt.id, dt.selectEnv);
|
|
||||||
})
|
|
||||||
if (!sign) {
|
|
||||||
this.$warning("请为每个项目选择一个运行环境!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.$emit('setProjectEnvMap', map);
|
|
||||||
this.$emit('close');
|
|
||||||
},
|
|
||||||
getApiInfo(request) {
|
|
||||||
if (request.id && request.referenced === 'REF') {
|
|
||||||
let requestResult = request.requestResult;
|
|
||||||
let url = request.refType && request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
|
|
||||||
let enable = request.enable;
|
|
||||||
this.$get(url + request.id, response => {
|
|
||||||
if (response.data) {
|
|
||||||
Object.assign(request, JSON.parse(response.data.request));
|
|
||||||
request.name = response.data.name;
|
|
||||||
request.enable = enable;
|
|
||||||
if (response.data.path && response.data.path != null) {
|
|
||||||
request.path = response.data.path;
|
|
||||||
request.url = response.data.url;
|
|
||||||
this.setUrl(request.path);
|
|
||||||
}
|
|
||||||
if (response.data.method && response.data.method != null) {
|
|
||||||
request.method = response.data.method;
|
|
||||||
}
|
|
||||||
request.requestResult = requestResult;
|
|
||||||
request.id = response.data.id;
|
|
||||||
request.disabled = true;
|
|
||||||
request.root = true;
|
|
||||||
if (!request.projectId) {
|
|
||||||
request.projectId = response.data.projectId;
|
|
||||||
}
|
|
||||||
this.reload();
|
|
||||||
this.sort();
|
|
||||||
} else {
|
|
||||||
request.referenced = "Deleted";
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
arr.push(p);
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
getScenario(scenario) {
|
return arr;
|
||||||
this.result = this.$get("/api/automation/getApiScenario/" + scenario.id, response => {
|
},
|
||||||
|
open() {
|
||||||
|
this.data = [];
|
||||||
|
if (this.projectIds.size > 0) {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
initEnv() {
|
||||||
|
this.data = [];
|
||||||
|
return Promise.all(this.init());
|
||||||
|
},
|
||||||
|
getProjectName(id) {
|
||||||
|
const project = this.projectList.find(p => p.id === id);
|
||||||
|
return project ? project.name : "";
|
||||||
|
},
|
||||||
|
openEnvironmentConfig(projectId, envId) {
|
||||||
|
if (!projectId) {
|
||||||
|
this.$error(this.$t('api_test.select_project'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$refs.environmentConfig.open(projectId, envId);
|
||||||
|
},
|
||||||
|
handleConfirm() {
|
||||||
|
let map = new Map();
|
||||||
|
let sign = true;
|
||||||
|
this.data.forEach(dt => {
|
||||||
|
if (!dt.selectEnv) {
|
||||||
|
sign = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map.set(dt.id, dt.selectEnv);
|
||||||
|
})
|
||||||
|
if (!sign) {
|
||||||
|
this.$warning("请为每个项目选择一个运行环境!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$emit('setProjectEnvMap', map);
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
getApiInfo(request) {
|
||||||
|
if (request.id && request.referenced === 'REF') {
|
||||||
|
let requestResult = request.requestResult;
|
||||||
|
let url = request.refType && request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
|
||||||
|
let enable = request.enable;
|
||||||
|
this.$get(url + request.id, response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
scenario.loaded = true;
|
Object.assign(request, JSON.parse(response.data.request));
|
||||||
let obj = {};
|
request.name = response.data.name;
|
||||||
if (response.data.scenarioDefinition) {
|
request.enable = enable;
|
||||||
obj = JSON.parse(response.data.scenarioDefinition);
|
if (response.data.path && response.data.path != null) {
|
||||||
scenario.hashTree = obj.hashTree;
|
request.path = response.data.path;
|
||||||
|
request.url = response.data.url;
|
||||||
|
this.setUrl(request.path);
|
||||||
}
|
}
|
||||||
//scenario.disabled = true;
|
if (response.data.method && response.data.method != null) {
|
||||||
scenario.name = response.data.name;
|
request.method = response.data.method;
|
||||||
if (!scenario.projectId) {
|
|
||||||
scenario.projectId = response.data.projectId;
|
|
||||||
}
|
}
|
||||||
scenario.headers = obj.headers;
|
request.requestResult = requestResult;
|
||||||
scenario.variables = obj.variables;
|
request.id = response.data.id;
|
||||||
scenario.environmentMap = obj.environmentMap;
|
request.disabled = true;
|
||||||
this.$emit('refReload');
|
request.root = true;
|
||||||
|
if (!request.projectId) {
|
||||||
|
request.projectId = response.data.projectId;
|
||||||
|
}
|
||||||
|
this.reload();
|
||||||
|
this.sort();
|
||||||
} else {
|
} else {
|
||||||
scenario.referenced = "Deleted";
|
request.referenced = "Deleted";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
recursiveSorting(arr) {
|
},
|
||||||
for (let i in arr) {
|
getScenario(scenario) {
|
||||||
if (arr[i].referenced === 'REF') {
|
this.result = this.$get("/api/automation/getApiScenario/" + scenario.id, response => {
|
||||||
// 分场景和接口
|
if (response.data) {
|
||||||
if (arr[i].type === "HTTPSamplerProxy") {
|
scenario.loaded = true;
|
||||||
// 获取源头内容
|
let obj = {};
|
||||||
this.getApiInfo(arr[i]);
|
if (response.data.scenarioDefinition) {
|
||||||
// 校验是否是全路径
|
obj = JSON.parse(response.data.scenarioDefinition);
|
||||||
|
scenario.hashTree = obj.hashTree;
|
||||||
|
}
|
||||||
|
//scenario.disabled = true;
|
||||||
|
scenario.name = response.data.name;
|
||||||
|
if (!scenario.projectId) {
|
||||||
|
scenario.projectId = response.data.projectId;
|
||||||
|
}
|
||||||
|
scenario.headers = obj.headers;
|
||||||
|
scenario.variables = obj.variables;
|
||||||
|
scenario.environmentMap = obj.environmentMap;
|
||||||
|
this.$emit('refReload');
|
||||||
|
} else {
|
||||||
|
scenario.referenced = "Deleted";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
recursiveSorting(arr) {
|
||||||
|
for (let i in arr) {
|
||||||
|
if (arr[i].referenced === 'REF') {
|
||||||
|
// 分场景和接口
|
||||||
|
if (arr[i].type === "HTTPSamplerProxy") {
|
||||||
|
// 获取源头内容
|
||||||
|
this.getApiInfo(arr[i]);
|
||||||
|
// 校验是否是全路径
|
||||||
|
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
|
||||||
|
this.isFullUrl = false;
|
||||||
|
}
|
||||||
|
} else if (arr[i].type === "scenario") {
|
||||||
|
this.getScenario(arr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (arr[i].type === "HTTPSamplerProxy") {
|
||||||
|
// 校验是否是全路径
|
||||||
|
if (arr[i].enable) {
|
||||||
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
|
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
|
||||||
this.isFullUrl = false;
|
this.isFullUrl = false;
|
||||||
}
|
}
|
||||||
} else if (arr[i].type === "scenario") {
|
|
||||||
this.getScenario(arr[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
if (arr[i].type === "HTTPSamplerProxy") {
|
|
||||||
// 校验是否是全路径
|
|
||||||
if (arr[i].enable) {
|
|
||||||
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
|
|
||||||
this.isFullUrl = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
|
||||||
this.recursiveSorting(arr[i].hashTree);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||||
checkFullUrl(scenarioDefinition) {
|
this.recursiveSorting(arr[i].hashTree);
|
||||||
for (let i in scenarioDefinition) {
|
}
|
||||||
// 设置项目ID
|
}
|
||||||
let request = scenarioDefinition[i];
|
},
|
||||||
if (request.referenced === 'REF') {
|
checkFullUrl(scenarioDefinition) {
|
||||||
if (request.type === "HTTPSamplerProxy") {
|
for (let i in scenarioDefinition) {
|
||||||
this.getApiInfo(request);
|
// 设置项目ID
|
||||||
// 校验是否是全路径
|
let request = scenarioDefinition[i];
|
||||||
|
if (request.referenced === 'REF') {
|
||||||
|
if (request.type === "HTTPSamplerProxy") {
|
||||||
|
this.getApiInfo(request);
|
||||||
|
// 校验是否是全路径
|
||||||
|
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
|
||||||
|
this.isFullUrl = false;
|
||||||
|
}
|
||||||
|
} else if (request.type === "scenario") {
|
||||||
|
this.getScenario(request);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (request.type === "HTTPSamplerProxy") {
|
||||||
|
// 校验是否是全路径
|
||||||
|
|
||||||
|
if (request.enable) {
|
||||||
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
|
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
|
||||||
this.isFullUrl = false;
|
this.isFullUrl = false;
|
||||||
}
|
}
|
||||||
} else if (request.type === "scenario") {
|
|
||||||
this.getScenario(request);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (request.type === "HTTPSamplerProxy") {
|
|
||||||
// 校验是否是全路径
|
|
||||||
|
|
||||||
if (request.enable) {
|
|
||||||
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
|
|
||||||
this.isFullUrl = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) {
|
|
||||||
this.recursiveSorting(scenarioDefinition[i].hashTree);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) {
|
||||||
checkEnv(data) {
|
this.recursiveSorting(scenarioDefinition[i].hashTree);
|
||||||
let sign = true;
|
}
|
||||||
this.isFullUrl = true;
|
}
|
||||||
if (this.data.length > 0) {
|
},
|
||||||
this.data.forEach(dt => {
|
checkEnv(data) {
|
||||||
if (!dt.selectEnv) {
|
let sign = true;
|
||||||
|
this.isFullUrl = true;
|
||||||
|
if (this.data.length > 0) {
|
||||||
|
this.data.forEach(dt => {
|
||||||
|
if (!dt.selectEnv) {
|
||||||
|
sign = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 如果有环境,检查环境
|
||||||
|
if (this.envMap && this.envMap.size > 0) {
|
||||||
|
this.projectIds.forEach(id => {
|
||||||
|
if (!this.envMap.get(id)) {
|
||||||
sign = false;
|
sign = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 如果有环境,检查环境
|
if (!data) {
|
||||||
if (this.envMap && this.envMap.size > 0) {
|
sign = false;
|
||||||
this.projectIds.forEach(id => {
|
|
||||||
if (!this.envMap.get(id)) {
|
|
||||||
sign = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
if (!data) {
|
|
||||||
sign = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 校验是否全是全路径
|
|
||||||
//this.checkFullUrl(data);
|
|
||||||
//sign = this.isFullUrl;
|
|
||||||
}
|
}
|
||||||
|
// 校验是否全是全路径
|
||||||
if (!sign) {
|
//this.checkFullUrl(data);
|
||||||
this.$warning("请为每个项目选择一个运行环境!");
|
//sign = this.isFullUrl;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
environmentConfigClose() {
|
|
||||||
// todo 关闭处理
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sign) {
|
||||||
|
this.$warning("请为每个项目选择一个运行环境!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
environmentConfigClose() {
|
||||||
|
// todo 关闭处理
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.ms-scenario-button {
|
.ms-scenario-button {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.env-confirm {
|
.env-confirm {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
width: 360px;
|
width: 360px;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-name {
|
.project-name {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<el-checkbox v-model="cookieShare" @change="setCookieShare" style="margin-right: 20px">共享cookie</el-checkbox>
|
<el-checkbox v-model="cookieShare" @change="setCookieShare" style="margin-right: 20px">共享cookie</el-checkbox>
|
||||||
|
|
||||||
<env-popover :env-map="envMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
<env-popover :env-map="envMap" :project-ids="projectIds" @setProjectEnvMap="setProjectEnvMap"
|
||||||
:project-list="projectList" ref="envPopover" class="ms-right"/>
|
@showPopover="showPopover" :project-list="projectList" ref="envPopover" class="ms-right"/>
|
||||||
|
|
||||||
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||||
|
|
||||||
|
@ -37,7 +37,12 @@
|
||||||
export default {
|
export default {
|
||||||
name: "ScenarioHeader",
|
name: "ScenarioHeader",
|
||||||
components: {EnvPopover},
|
components: {EnvPopover},
|
||||||
props: {currentScenario: {}, scenarioDefinition: Array, enableCookieShare: Boolean, projectEnvMap: Map, projectIds: Set, projectList: Array},
|
props: {currentScenario: {}, scenarioDefinition: Array, enableCookieShare: Boolean,
|
||||||
|
projectEnvMap: Map,
|
||||||
|
projectIds: Set,
|
||||||
|
projectList: Array,
|
||||||
|
isFullUrl: Boolean
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
envMap: new Map,
|
envMap: new Map,
|
||||||
|
@ -102,7 +107,25 @@
|
||||||
setProjectEnvMap(projectEnvMap) {
|
setProjectEnvMap(projectEnvMap) {
|
||||||
this.$emit('setProjectEnvMap', projectEnvMap);
|
this.$emit('setProjectEnvMap', projectEnvMap);
|
||||||
this.envMap = projectEnvMap;
|
this.envMap = projectEnvMap;
|
||||||
}
|
},
|
||||||
|
showPopover() {
|
||||||
|
let definition = JSON.parse(JSON.stringify(this.currentScenario));
|
||||||
|
definition.hashTree = this.scenarioDefinition;
|
||||||
|
this.getEnv(JSON.stringify(definition)).then(() => {
|
||||||
|
this.$refs.envPopover.openEnvSelect();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getEnv(definition) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
this.$post("/api/automation/getApiScenarioEnv", {definition: definition}, res => {
|
||||||
|
if (res.data) {
|
||||||
|
this.$emit("update:projectIds", new Set(res.data.projectIds))
|
||||||
|
this.$emit("update:isFullUrl", res.data.fullUrl)
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -152,9 +152,7 @@ import {TEST_PLAN_CONFIGS} from "../../../../common/components/search/search-com
|
||||||
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
|
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
|
||||||
import {getCurrentProjectID} from "../../../../../../common/js/utils";
|
import {getCurrentProjectID} from "../../../../../../common/js/utils";
|
||||||
import {_filter, _sort} from "@/common/js/tableUtils";
|
import {_filter, _sort} from "@/common/js/tableUtils";
|
||||||
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
|
import EnvPopover from "@/business/components/track/common/EnvPopover";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TestPlanList",
|
name: "TestPlanList",
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -41,8 +41,7 @@
|
||||||
<script>
|
<script>
|
||||||
import MsDialogFooter from "../../../common/components/MsDialogFooter";
|
import MsDialogFooter from "../../../common/components/MsDialogFooter";
|
||||||
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||||
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
|
import EnvPopover from "@/business/components/track/common/EnvPopover";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "BatchEdit",
|
name: "BatchEdit",
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
<template>
|
||||||
|
<el-popover
|
||||||
|
v-model="visible"
|
||||||
|
placement="bottom"
|
||||||
|
width="400"
|
||||||
|
:disabled="isReadOnly"
|
||||||
|
@show="showPopover"
|
||||||
|
trigger="click">
|
||||||
|
<env-select :project-ids="projectIds" :env-map="envMap" @close="visible = false"
|
||||||
|
ref="envSelect" @setProjectEnvMap="setProjectEnvMap" :project-list="projectList"/>
|
||||||
|
<el-button type="primary" slot="reference" size="mini" style="margin-top: 2px;">
|
||||||
|
{{ $t('api_test.definition.request.run_env') }}
|
||||||
|
<i class="el-icon-caret-bottom el-icon--right"></i>
|
||||||
|
</el-button>
|
||||||
|
</el-popover>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import EnvSelect from "@/business/components/track/common/EnvSelect";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "EnvPopover",
|
||||||
|
components: {EnvSelect},
|
||||||
|
props: {
|
||||||
|
envMap: Map,
|
||||||
|
projectIds: Set,
|
||||||
|
projectList: Array,
|
||||||
|
isReadOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showPopover() {
|
||||||
|
this.$refs.envSelect.open();
|
||||||
|
},
|
||||||
|
setProjectEnvMap(map) {
|
||||||
|
this.$emit("setProjectEnvMap", map);
|
||||||
|
},
|
||||||
|
checkEnv() {
|
||||||
|
return this.$refs.envSelect.checkEnv();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
|
@ -0,0 +1,285 @@
|
||||||
|
<template>
|
||||||
|
<div v-loading="result.loading">
|
||||||
|
<div v-for="pe in data" :key="pe.id" style="margin-left: 20px;">
|
||||||
|
<el-select v-model="pe['selectEnv']" placeholder="请选择环境" style="margin-top: 8px;width: 200px;" size="small">
|
||||||
|
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||||
|
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||||
|
:value="environment.id"/>
|
||||||
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
|
</el-button>
|
||||||
|
<template v-slot:empty>
|
||||||
|
<div class="empty-environment">
|
||||||
|
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||||
|
{{ $t('api_test.environment.environment_config') }}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-select>
|
||||||
|
<span class="project-name" :title="getProjectName(pe.id)">
|
||||||
|
{{ getProjectName(pe.id) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-button type="primary" @click="handleConfirm" size="small" class="env-confirm">确 定</el-button>
|
||||||
|
|
||||||
|
<!-- 环境配置 -->
|
||||||
|
<api-environment-config ref="environmentConfig" @close="environmentConfigClose"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
|
||||||
|
import ApiEnvironmentConfig from "@/business/components/api/definition/components/environment/ApiEnvironmentConfig";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "EnvironmentSelect",
|
||||||
|
components: {ApiEnvironmentConfig},
|
||||||
|
props: {
|
||||||
|
envMap: Map,
|
||||||
|
projectIds: Set,
|
||||||
|
projectList: Array
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
result: {},
|
||||||
|
projects: [],
|
||||||
|
environments: [],
|
||||||
|
dialogVisible: false,
|
||||||
|
isFullUrl: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
init() {
|
||||||
|
this.projectIds.forEach(id => {
|
||||||
|
const project = this.projectList.find(p => p.id === id);
|
||||||
|
if (project) {
|
||||||
|
let item = {id: id, envs: [], selectEnv: ""};
|
||||||
|
this.data.push(item);
|
||||||
|
this.result = this.$get('/api/environment/list/' + id, res => {
|
||||||
|
let envs = res.data;
|
||||||
|
envs.forEach(environment => {
|
||||||
|
parseEnvironment(environment);
|
||||||
|
});
|
||||||
|
// 固定环境列表渲染顺序
|
||||||
|
let temp = this.data.find(dt => dt.id === id);
|
||||||
|
temp.envs = envs;
|
||||||
|
let envId = this.envMap.get(id);
|
||||||
|
// 选中环境是否存在
|
||||||
|
temp.selectEnv = envs.filter(e => e.id === envId).length === 0 ? null : envId;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
open() {
|
||||||
|
this.data = [];
|
||||||
|
if (this.projectIds.size > 0) {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getProjectName(id) {
|
||||||
|
const project = this.projectList.find(p => p.id === id);
|
||||||
|
return project ? project.name : "";
|
||||||
|
},
|
||||||
|
openEnvironmentConfig(projectId, envId) {
|
||||||
|
if (!projectId) {
|
||||||
|
this.$error(this.$t('api_test.select_project'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$refs.environmentConfig.open(projectId, envId);
|
||||||
|
},
|
||||||
|
handleConfirm() {
|
||||||
|
let map = new Map();
|
||||||
|
let sign = true;
|
||||||
|
this.data.forEach(dt => {
|
||||||
|
if (!dt.selectEnv) {
|
||||||
|
sign = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map.set(dt.id, dt.selectEnv);
|
||||||
|
})
|
||||||
|
if (!sign) {
|
||||||
|
this.$warning("请为每个项目选择一个运行环境!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$emit('setProjectEnvMap', map);
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
getApiInfo(request) {
|
||||||
|
if (request.id && request.referenced === 'REF') {
|
||||||
|
let requestResult = request.requestResult;
|
||||||
|
let url = request.refType && request.refType === 'CASE' ? "/api/testcase/get/" : "/api/definition/get/";
|
||||||
|
let enable = request.enable;
|
||||||
|
this.$get(url + request.id, response => {
|
||||||
|
if (response.data) {
|
||||||
|
Object.assign(request, JSON.parse(response.data.request));
|
||||||
|
request.name = response.data.name;
|
||||||
|
request.enable = enable;
|
||||||
|
if (response.data.path && response.data.path != null) {
|
||||||
|
request.path = response.data.path;
|
||||||
|
request.url = response.data.url;
|
||||||
|
this.setUrl(request.path);
|
||||||
|
}
|
||||||
|
if (response.data.method && response.data.method != null) {
|
||||||
|
request.method = response.data.method;
|
||||||
|
}
|
||||||
|
request.requestResult = requestResult;
|
||||||
|
request.id = response.data.id;
|
||||||
|
request.disabled = true;
|
||||||
|
request.root = true;
|
||||||
|
if (!request.projectId) {
|
||||||
|
request.projectId = response.data.projectId;
|
||||||
|
}
|
||||||
|
this.reload();
|
||||||
|
this.sort();
|
||||||
|
} else {
|
||||||
|
request.referenced = "Deleted";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getScenario(scenario) {
|
||||||
|
this.result = this.$get("/api/automation/getApiScenario/" + scenario.id, response => {
|
||||||
|
if (response.data) {
|
||||||
|
scenario.loaded = true;
|
||||||
|
let obj = {};
|
||||||
|
if (response.data.scenarioDefinition) {
|
||||||
|
obj = JSON.parse(response.data.scenarioDefinition);
|
||||||
|
scenario.hashTree = obj.hashTree;
|
||||||
|
}
|
||||||
|
//scenario.disabled = true;
|
||||||
|
scenario.name = response.data.name;
|
||||||
|
if (!scenario.projectId) {
|
||||||
|
scenario.projectId = response.data.projectId;
|
||||||
|
}
|
||||||
|
scenario.headers = obj.headers;
|
||||||
|
scenario.variables = obj.variables;
|
||||||
|
scenario.environmentMap = obj.environmentMap;
|
||||||
|
this.$emit('refReload');
|
||||||
|
} else {
|
||||||
|
scenario.referenced = "Deleted";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
recursiveSorting(arr) {
|
||||||
|
for (let i in arr) {
|
||||||
|
if (arr[i].referenced === 'REF') {
|
||||||
|
// 分场景和接口
|
||||||
|
if (arr[i].type === "HTTPSamplerProxy") {
|
||||||
|
// 获取源头内容
|
||||||
|
this.getApiInfo(arr[i]);
|
||||||
|
// 校验是否是全路径
|
||||||
|
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
|
||||||
|
this.isFullUrl = false;
|
||||||
|
}
|
||||||
|
} else if (arr[i].type === "scenario") {
|
||||||
|
this.getScenario(arr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (arr[i].type === "HTTPSamplerProxy") {
|
||||||
|
// 校验是否是全路径
|
||||||
|
if (arr[i].enable) {
|
||||||
|
if (!arr[i].url || (!arr[i].url.startsWith("http://") && !arr[i].url.startsWith("https://"))) {
|
||||||
|
this.isFullUrl = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
|
||||||
|
this.recursiveSorting(arr[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkFullUrl(scenarioDefinition) {
|
||||||
|
for (let i in scenarioDefinition) {
|
||||||
|
// 设置项目ID
|
||||||
|
let request = scenarioDefinition[i];
|
||||||
|
if (request.referenced === 'REF') {
|
||||||
|
if (request.type === "HTTPSamplerProxy") {
|
||||||
|
this.getApiInfo(request);
|
||||||
|
// 校验是否是全路径
|
||||||
|
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
|
||||||
|
this.isFullUrl = false;
|
||||||
|
}
|
||||||
|
} else if (request.type === "scenario") {
|
||||||
|
this.getScenario(request);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (request.type === "HTTPSamplerProxy") {
|
||||||
|
// 校验是否是全路径
|
||||||
|
|
||||||
|
if (request.enable) {
|
||||||
|
if (!request.url || (!request.url.startsWith("http://") && !request.url.startsWith("https://"))) {
|
||||||
|
this.isFullUrl = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scenarioDefinition[i].hashTree != undefined && scenarioDefinition[i].hashTree.length > 0) {
|
||||||
|
this.recursiveSorting(scenarioDefinition[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
checkEnv() {
|
||||||
|
let sign = true;
|
||||||
|
this.isFullUrl = true;
|
||||||
|
if (this.data.length > 0) {
|
||||||
|
this.data.forEach(dt => {
|
||||||
|
if (!dt.selectEnv) {
|
||||||
|
sign = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 如果有环境,检查环境
|
||||||
|
if (this.envMap && this.envMap.size > 0) {
|
||||||
|
this.projectIds.forEach(id => {
|
||||||
|
if (!this.envMap.get(id)) {
|
||||||
|
sign = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
sign = false;
|
||||||
|
}
|
||||||
|
// 校验是否全是全路径
|
||||||
|
//this.checkFullUrl(data);
|
||||||
|
//sign = this.isFullUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sign) {
|
||||||
|
this.$warning("请为每个项目选择一个运行环境!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
environmentConfigClose() {
|
||||||
|
// todo 关闭处理
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.ms-scenario-button {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.env-confirm {
|
||||||
|
margin-left: 20px;
|
||||||
|
width: 360px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-name {
|
||||||
|
display: inline-block;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
width: 150px;
|
||||||
|
margin-left: 8px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -68,7 +68,7 @@
|
||||||
import MsTestPlanList from "../../../../../api/automation/scenario/testplan/TestPlanList";
|
import MsTestPlanList from "../../../../../api/automation/scenario/testplan/TestPlanList";
|
||||||
import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader";
|
import TestPlanScenarioListHeader from "./TestPlanScenarioListHeader";
|
||||||
import {_handleSelect, _handleSelectAll} from "../../../../../../../common/js/tableUtils";
|
import {_handleSelect, _handleSelectAll} from "../../../../../../../common/js/tableUtils";
|
||||||
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
|
import EnvPopover from "@/business/components/track/common/EnvPopover";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "RelevanceScenarioList",
|
name: "RelevanceScenarioList",
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<script>
|
<script>
|
||||||
import {_handleSelect, _handleSelectAll} from "@/common/js/tableUtils";
|
import {_handleSelect, _handleSelectAll} from "@/common/js/tableUtils";
|
||||||
import MsTag from "@/business/components/common/components/MsTag";
|
import MsTag from "@/business/components/common/components/MsTag";
|
||||||
import EnvPopover from "@/business/components/api/automation/scenario/EnvPopover";
|
import EnvPopover from "@/business/components/track/common/EnvPopover";
|
||||||
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
Loading…
Reference in New Issue