feat(接口自动化): 场景步骤跨项目添加接口
This commit is contained in:
parent
b5d7140aa8
commit
532007f25d
|
@ -437,11 +437,9 @@ public class ApiDefinitionService {
|
||||||
Map<String, EnvironmentConfig> envConfig = new HashMap<>();
|
Map<String, EnvironmentConfig> envConfig = new HashMap<>();
|
||||||
Map<String, String> map = request.getEnvironmentMap();
|
Map<String, String> map = request.getEnvironmentMap();
|
||||||
if (map != null && map.size() > 0) {
|
if (map != null && map.size() > 0) {
|
||||||
map.keySet().forEach(id -> {
|
ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(request.getProjectId()));
|
||||||
ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(id));
|
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
||||||
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
|
envConfig.put(request.getProjectId(), env);
|
||||||
envConfig.put(id, env);
|
|
||||||
});
|
|
||||||
config.setConfig(envConfig);
|
config.setConfig(envConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,14 +150,14 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
list() {
|
list(projectId) {
|
||||||
let url = undefined;
|
let url = undefined;
|
||||||
if (this.isPlanModel) {
|
if (this.isPlanModel) {
|
||||||
url = '/api/automation/module/list/plan/' + this.planId;
|
url = '/api/automation/module/list/plan/' + this.planId;
|
||||||
} else if (this.isRelevanceModel) {
|
} else if (this.isRelevanceModel) {
|
||||||
url = "/api/automation/module/list/" + this.relevanceProjectId;
|
url = "/api/automation/module/list/" + this.relevanceProjectId;
|
||||||
} else {
|
} else {
|
||||||
url = "/api/automation/module/list/" + this.projectId;
|
url = "/api/automation/module/list/" + (projectId ? projectId : this.projectId);
|
||||||
if (!this.projectId) {
|
if (!this.projectId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<relevance-dialog :title="$t('api_test.definition.api_import')" ref="relevanceDialog">
|
<test-case-relevance-base
|
||||||
|
@setProject="setProject"
|
||||||
|
:dialog-title="$t('api_test.definition.api_import')"
|
||||||
|
ref="baseRelevance">
|
||||||
<template v-slot:aside>
|
<template v-slot:aside>
|
||||||
<ms-api-module
|
<ms-api-module
|
||||||
|
style="margin-top: 5px;"
|
||||||
@nodeSelectEvent="nodeChange"
|
@nodeSelectEvent="nodeChange"
|
||||||
@protocolChange="handleProtocolChange"
|
@protocolChange="handleProtocolChange"
|
||||||
@refreshTable="refresh"
|
@refreshTable="refresh"
|
||||||
|
@ -13,6 +16,7 @@
|
||||||
|
|
||||||
<scenario-relevance-api-list
|
<scenario-relevance-api-list
|
||||||
v-if="isApiListEnable"
|
v-if="isApiListEnable"
|
||||||
|
:project-id="projectId"
|
||||||
:current-protocol="currentProtocol"
|
:current-protocol="currentProtocol"
|
||||||
:select-node-ids="selectNodeIds"
|
:select-node-ids="selectNodeIds"
|
||||||
:is-api-list-enable="isApiListEnable"
|
:is-api-list-enable="isApiListEnable"
|
||||||
|
@ -21,6 +25,7 @@
|
||||||
|
|
||||||
<scenario-relevance-case-list
|
<scenario-relevance-case-list
|
||||||
v-if="!isApiListEnable"
|
v-if="!isApiListEnable"
|
||||||
|
:project-id="projectId"
|
||||||
:current-protocol="currentProtocol"
|
:current-protocol="currentProtocol"
|
||||||
:select-node-ids="selectNodeIds"
|
:select-node-ids="selectNodeIds"
|
||||||
:is-api-list-enable="isApiListEnable"
|
:is-api-list-enable="isApiListEnable"
|
||||||
|
@ -33,8 +38,7 @@
|
||||||
{{ $t('api_test.scenario.reference') }}
|
{{ $t('api_test.scenario.reference') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
</test-case-relevance-base>
|
||||||
</relevance-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -45,10 +49,12 @@ import MsAsideContainer from "../../../../common/components/MsAsideContainer";
|
||||||
import MsMainContainer from "../../../../common/components/MsMainContainer";
|
import MsMainContainer from "../../../../common/components/MsMainContainer";
|
||||||
import ScenarioRelevanceApiList from "./RelevanceApiList";
|
import ScenarioRelevanceApiList from "./RelevanceApiList";
|
||||||
import RelevanceDialog from "../../../../track/plan/view/comonents/base/RelevanceDialog";
|
import RelevanceDialog from "../../../../track/plan/view/comonents/base/RelevanceDialog";
|
||||||
|
import TestCaseRelevanceBase from "@/business/components/track/plan/view/comonents/base/TestCaseRelevanceBase";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ApiRelevance",
|
name: "ApiRelevance",
|
||||||
components: {
|
components: {
|
||||||
|
TestCaseRelevanceBase,
|
||||||
RelevanceDialog,
|
RelevanceDialog,
|
||||||
ScenarioRelevanceApiList,
|
ScenarioRelevanceApiList,
|
||||||
MsMainContainer, MsAsideContainer, MsContainer, MsApiModule, ScenarioRelevanceCaseList
|
MsMainContainer, MsAsideContainer, MsContainer, MsApiModule, ScenarioRelevanceCaseList
|
||||||
|
@ -58,67 +64,82 @@ export default {
|
||||||
result: {},
|
result: {},
|
||||||
currentProtocol: null,
|
currentProtocol: null,
|
||||||
selectNodeIds: [],
|
selectNodeIds: [],
|
||||||
moduleOptions: {},
|
moduleOptions: {},
|
||||||
isApiListEnable: true,
|
isApiListEnable: true,
|
||||||
}
|
projectId: ""
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
reference() {
|
|
||||||
this.save('REF');
|
|
||||||
},
|
|
||||||
copy() {
|
|
||||||
this.save('Copy');
|
|
||||||
},
|
|
||||||
save(reference) {
|
|
||||||
if (this.isApiListEnable) {
|
|
||||||
this.$emit('save', this.$refs.apiList.selectRows, 'API', reference);
|
|
||||||
this.close();
|
|
||||||
} else {
|
|
||||||
let apiCases = this.$refs.apiCaseList.selectRows;
|
|
||||||
let ids = Array.from(apiCases).map(row => row.id);
|
|
||||||
this.result = this.$post("/api/testcase/get/request", {ids: ids}, (response) => {
|
|
||||||
apiCases.forEach((item) => {
|
|
||||||
item.request = response.data[item.id];
|
|
||||||
});
|
|
||||||
this.$emit('save', apiCases, 'CASE', reference);
|
|
||||||
this.close();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
close() {
|
|
||||||
this.refresh();
|
|
||||||
this.$refs.relevanceDialog.close();
|
|
||||||
},
|
|
||||||
open() {
|
|
||||||
if (this.$refs.apiList) {
|
|
||||||
this.$refs.apiList.clearSelection();
|
|
||||||
}
|
|
||||||
if (this.$refs.apiCaseList) {
|
|
||||||
this.$refs.apiCaseList.clearSelection();
|
|
||||||
}
|
|
||||||
this.$refs.relevanceDialog.open();
|
|
||||||
},
|
|
||||||
isApiListEnableChange(data) {
|
|
||||||
this.isApiListEnable = data;
|
|
||||||
},
|
|
||||||
nodeChange(node, nodeIds, pNodes) {
|
|
||||||
this.selectNodeIds = nodeIds;
|
|
||||||
},
|
|
||||||
handleProtocolChange(protocol) {
|
|
||||||
this.currentProtocol = protocol;
|
|
||||||
},
|
|
||||||
setModuleOptions(data) {
|
|
||||||
this.moduleOptions = data;
|
|
||||||
},
|
|
||||||
refresh() {
|
|
||||||
if (this.isApiListEnable) {
|
|
||||||
this.$refs.apiList.initTable();
|
|
||||||
} else {
|
|
||||||
this.$refs.apiCaseList.initTable();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
projectId() {
|
||||||
|
this.refresh();
|
||||||
|
this.$refs.nodeTree.list(this.projectId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
reference() {
|
||||||
|
this.save('REF');
|
||||||
|
},
|
||||||
|
copy() {
|
||||||
|
this.save('Copy');
|
||||||
|
},
|
||||||
|
save(reference) {
|
||||||
|
if (this.isApiListEnable) {
|
||||||
|
let apis = this.$refs.apiList.selectRows;
|
||||||
|
apis.forEach(api => {
|
||||||
|
api.projectId = this.projectId;
|
||||||
|
})
|
||||||
|
this.$emit('save', this.$refs.apiList.selectRows, 'API', reference);
|
||||||
|
this.$refs.baseRelevance.close();
|
||||||
|
} else {
|
||||||
|
let apiCases = this.$refs.apiCaseList.selectRows;
|
||||||
|
let ids = Array.from(apiCases).map(row => row.id);
|
||||||
|
this.result = this.$post("/api/testcase/get/request", {ids: ids}, (response) => {
|
||||||
|
apiCases.forEach((item) => {
|
||||||
|
item.request = response.data[item.id];
|
||||||
|
item.projectId = this.projectId;
|
||||||
|
});
|
||||||
|
this.$emit('save', apiCases, 'CASE', reference);
|
||||||
|
this.$refs.baseRelevance.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.refresh();
|
||||||
|
this.$refs.relevanceDialog.close();
|
||||||
|
},
|
||||||
|
open() {
|
||||||
|
if (this.$refs.apiList) {
|
||||||
|
this.$refs.apiList.clearSelection();
|
||||||
|
}
|
||||||
|
if (this.$refs.apiCaseList) {
|
||||||
|
this.$refs.apiCaseList.clearSelection();
|
||||||
|
}
|
||||||
|
this.$refs.baseRelevance.open();
|
||||||
|
},
|
||||||
|
isApiListEnableChange(data) {
|
||||||
|
this.isApiListEnable = data;
|
||||||
|
},
|
||||||
|
nodeChange(node, nodeIds, pNodes) {
|
||||||
|
this.selectNodeIds = nodeIds;
|
||||||
|
},
|
||||||
|
handleProtocolChange(protocol) {
|
||||||
|
this.currentProtocol = protocol;
|
||||||
|
},
|
||||||
|
setModuleOptions(data) {
|
||||||
|
this.moduleOptions = data;
|
||||||
|
},
|
||||||
|
refresh() {
|
||||||
|
if (this.isApiListEnable) {
|
||||||
|
this.$refs.apiList.initTable(this.projectId);
|
||||||
|
} else {
|
||||||
|
this.$refs.apiCaseList.initTable(this.projectId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setProject(projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
@ -178,18 +178,19 @@ export default {
|
||||||
isApiListEnableChange(data) {
|
isApiListEnableChange(data) {
|
||||||
this.$emit('isApiListEnableChange', data);
|
this.$emit('isApiListEnableChange', data);
|
||||||
},
|
},
|
||||||
initTable() {
|
initTable(projectId) {
|
||||||
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
|
||||||
this.condition.moduleIds = this.selectNodeIds;
|
this.condition.moduleIds = this.selectNodeIds;
|
||||||
if (this.trashEnable) {
|
if (this.trashEnable) {
|
||||||
this.condition.filters = {status: ["Trash"]};
|
this.condition.filters = {status: ["Trash"]};
|
||||||
this.condition.moduleIds = [];
|
this.condition.moduleIds = [];
|
||||||
}
|
}
|
||||||
if (this.projectId != null) {
|
if (projectId != null && typeof projectId === 'string') {
|
||||||
|
this.condition.projectId = projectId;
|
||||||
|
} else if (this.projectId != null) {
|
||||||
this.condition.projectId = this.projectId;
|
this.condition.projectId = this.projectId;
|
||||||
} else {
|
|
||||||
this.condition.projectId = getCurrentProjectID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentProtocol != null) {
|
if (this.currentProtocol != null) {
|
||||||
this.condition.protocol = this.currentProtocol;
|
this.condition.protocol = this.currentProtocol;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -164,14 +164,13 @@ export default {
|
||||||
isApiListEnableChange(data) {
|
isApiListEnableChange(data) {
|
||||||
this.$emit('isApiListEnableChange', data);
|
this.$emit('isApiListEnableChange', data);
|
||||||
},
|
},
|
||||||
initTable() {
|
initTable(projectId) {
|
||||||
this.condition.status = "";
|
this.condition.status = "";
|
||||||
this.condition.moduleIds = this.selectNodeIds;
|
this.condition.moduleIds = this.selectNodeIds;
|
||||||
if (this.projectId != null) {
|
if (projectId != null && typeof projectId === 'string') {
|
||||||
|
this.condition.projectId = projectId;
|
||||||
|
} else if (this.projectId != null) {
|
||||||
this.condition.projectId = this.projectId;
|
this.condition.projectId = this.projectId;
|
||||||
} else {
|
|
||||||
this.condition.projectId = getCurrentProjectID();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (this.currentProtocol != null) {
|
if (this.currentProtocol != null) {
|
||||||
this.condition.protocol = this.currentProtocol;
|
this.condition.protocol = this.currentProtocol;
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<test-case-relevance-base
|
<test-case-relevance-base
|
||||||
|
:dialog-title="$t('api_test.automation.scenario_import')"
|
||||||
@setProject="setProject"
|
@setProject="setProject"
|
||||||
ref="baseRelevance">
|
ref="baseRelevance">
|
||||||
<template v-slot:aside>
|
<template v-slot:aside>
|
||||||
<ms-api-scenario-module
|
<ms-api-scenario-module
|
||||||
|
style="margin-top: 5px;"
|
||||||
@nodeSelectEvent="nodeChange"
|
@nodeSelectEvent="nodeChange"
|
||||||
@refreshTable="refresh"
|
@refreshTable="refresh"
|
||||||
@setModuleOptions="setModuleOptions"
|
@setModuleOptions="setModuleOptions"
|
||||||
|
@ -27,12 +29,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ScenarioRelevanceCaseList from "./RelevanceCaseList";
|
|
||||||
import MsApiModule from "../../../definition/components/module/ApiModule";
|
|
||||||
import MsContainer from "../../../../common/components/MsContainer";
|
import MsContainer from "../../../../common/components/MsContainer";
|
||||||
import MsAsideContainer from "../../../../common/components/MsAsideContainer";
|
import MsAsideContainer from "../../../../common/components/MsAsideContainer";
|
||||||
import MsMainContainer from "../../../../common/components/MsMainContainer";
|
import MsMainContainer from "../../../../common/components/MsMainContainer";
|
||||||
import ScenarioRelevanceApiList from "./RelevanceApiList";
|
|
||||||
import MsApiScenarioModule from "../ApiScenarioModule";
|
import MsApiScenarioModule from "../ApiScenarioModule";
|
||||||
import MsApiScenarioList from "../ApiScenarioList";
|
import MsApiScenarioList from "../ApiScenarioList";
|
||||||
import {getUUID} from "../../../../../../common/js/utils";
|
import {getUUID} from "../../../../../../common/js/utils";
|
||||||
|
@ -63,6 +62,7 @@
|
||||||
watch: {
|
watch: {
|
||||||
projectId() {
|
projectId() {
|
||||||
this.$refs.apiScenarioList.search(this.projectId);
|
this.$refs.apiScenarioList.search(this.projectId);
|
||||||
|
this.$refs.nodeTree.list(this.projectId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -104,7 +104,10 @@
|
||||||
if (!this.request.requestResult) {
|
if (!this.request.requestResult) {
|
||||||
this.request.requestResult = {responseResult: {}};
|
this.request.requestResult = {responseResult: {}};
|
||||||
}
|
}
|
||||||
this.request.projectId = getCurrentProjectID();
|
// 跨项目关联,如果没有ID,则赋值本项目ID
|
||||||
|
if (!this.request.projectId) {
|
||||||
|
this.request.projectId = getCurrentProjectID();
|
||||||
|
}
|
||||||
// 加载引用对象数据
|
// 加载引用对象数据
|
||||||
this.getApiInfo();
|
this.getApiInfo();
|
||||||
if (this.request.protocol === 'HTTP') {
|
if (this.request.protocol === 'HTTP') {
|
||||||
|
|
|
@ -74,7 +74,7 @@ import {getUUID, getBodyUploadFiles, getCurrentProjectID, strMapToObj} from "@/c
|
||||||
// 场景步骤下接口调用
|
// 场景步骤下接口调用
|
||||||
projectId = this.runData.projectId;
|
projectId = this.runData.projectId;
|
||||||
}
|
}
|
||||||
let reqObj = {id: this.reportId, testElement: testPlan, type: this.type,projectId:getCurrentProjectID(), environmentMap: strMapToObj(this.envMap)};
|
let reqObj = {id: this.reportId, testElement: testPlan, type: this.type,projectId: projectId, environmentMap: strMapToObj(this.envMap)};
|
||||||
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
|
let bodyFiles = getBodyUploadFiles(reqObj, this.runData);
|
||||||
let url = "";
|
let url = "";
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
|
|
|
@ -107,14 +107,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
list() {
|
list(projectId) {
|
||||||
let url = undefined;
|
let url = undefined;
|
||||||
if (this.isPlanModel) {
|
if (this.isPlanModel) {
|
||||||
url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
|
url = '/api/module/list/plan/' + this.planId + '/' + this.condition.protocol;
|
||||||
} else if (this.isRelevanceModel) {
|
} else if (this.isRelevanceModel) {
|
||||||
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol;
|
url = "/api/module/list/" + this.relevanceProjectId + "/" + this.condition.protocol;
|
||||||
} else {
|
} else {
|
||||||
url = "/api/module/list/" + this.projectId + "/" + this.condition.protocol;
|
url = "/api/module/list/" + (projectId ? projectId : this.projectId) + "/" + this.condition.protocol;
|
||||||
if (!this.projectId) {
|
if (!this.projectId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<relevance-dialog :title="$t('test_track.plan_view.relevance_test_case')" ref="relevanceDialog">
|
<relevance-dialog :title="dialogTitle" ref="relevanceDialog">
|
||||||
|
|
||||||
<template v-slot:aside>
|
<template v-slot:aside>
|
||||||
<select-menu
|
<select-menu
|
||||||
|
@ -51,6 +51,12 @@
|
||||||
props: {
|
props: {
|
||||||
planId: {
|
planId: {
|
||||||
type: String
|
type: String
|
||||||
|
},
|
||||||
|
dialogTitle: {
|
||||||
|
type: String,
|
||||||
|
default() {
|
||||||
|
return this.$t('test_track.plan_view.relevance_test_case');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
Loading…
Reference in New Issue