diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue
index 7715aa7f2b..461f2d24b1 100644
--- a/frontend/src/business/components/api/definition/ApiDefinition.vue
+++ b/frontend/src/business/components/api/definition/ApiDefinition.vue
@@ -33,7 +33,7 @@
:middle-button-enable="false"
left-content="API"
right-content="CASE"
- >
+ >
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
@@ -233,6 +238,8 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
import MockConfig from "@/business/components/api/definition/components/mock/MockConfig";
import ApiSchedule from "@/business/components/api/definition/components/import/ApiSchedule";
+import MsEditCompleteContainer from "./components/EditCompleteContainer";
+
export default {
name: "ApiDefinition",
@@ -270,7 +277,8 @@ export default {
MsRunTestSqlPage,
MsRunTestDubboPage,
ApiDocumentsPage,
- MockConfig
+ MockConfig,
+ MsEditCompleteContainer
},
props: {
visible: {
@@ -322,10 +330,10 @@ export default {
this.activeDom = 'middle';
}
let dataType = this.$route.params.dataType;
- if(dataType){
- if(dataType === "api"){
+ if (dataType) {
+ if (dataType === "api") {
this.activeDom = 'left';
- }else {
+ } else {
this.activeDom = 'middle';
}
}
@@ -390,17 +398,19 @@ export default {
addTab(tab) {
if (tab.name === 'add') {
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
- }else if(tab.name === 'trash'){
- if(this.$refs.trashApiList){
+ } else if (tab.name === 'trash') {
+ if (this.$refs.trashApiList) {
this.$refs.trashApiList.initTable();
}
- if(this.$refs.trashCaseList){
+ if (this.$refs.trashCaseList) {
this.$refs.trashCaseList.initTable();
}
}
if (this.$refs.apiConfig) {
this.$refs.apiConfig.forEach(item => {
- item.removeListener();
+ if (item) {
+ item.removeListener();
+ }
}); // 删除所有tab的 ctrl + s 监听
let tabs = this.apiTabs;
let index = tabs.findIndex(item => item.name === tab.name); // 找到当前选中tab的index
@@ -526,9 +536,9 @@ export default {
name = "copy" + "-" + row.name;
row.name = "copy" + "-" + row.name;
} else {
- if(row.name){
+ if (row.name) {
name = this.$t('api_test.definition.request.edit_api') + "-" + row.name;
- }else {
+ } else {
name = this.$t('api_test.definition.request.title');
}
@@ -553,16 +563,16 @@ export default {
this.$refs.nodeTree.list();
},
refresh(data) {
- if(this.$refs.caseList && this.$refs.caseList[0]){
+ if (this.$refs.caseList && this.$refs.caseList[0]) {
this.$refs.caseList[0].initTable();
}
- if(this.$refs.trashApiList){
+ if (this.$refs.trashApiList) {
this.$refs.trashApiList.initTable();
}
- if(this.$refs.trashCaseList){
+ if (this.$refs.trashCaseList) {
this.$refs.trashCaseList.initTable();
}
- if(this.$refs.apiDefList && this.$refs.apiDefList[0]){
+ if (this.$refs.apiDefList && this.$refs.apiDefList[0]) {
this.$refs.apiDefList[0].initTable();
}
@@ -616,13 +626,13 @@ export default {
enableTrash(data) {
this.initApiTableOpretion = "trashEnable";
this.trashEnable = data;
- if(data){
+ if (data) {
this.apiDefaultTab = "trash";
- }else {
+ } else {
this.apiDefaultTab = "default"
}
},
- updateInitApiTableOpretion(param){
+ updateInitApiTableOpretion(param) {
this.initApiTableOpretion = param;
}
}
diff --git a/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue b/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue
new file mode 100644
index 0000000000..7c27f176fa
--- /dev/null
+++ b/frontend/src/business/components/api/definition/components/EditCompleteContainer.vue
@@ -0,0 +1,254 @@
+
+
+
+
+ API
+
+
+ {{ $t('commons.test') }}
+
+
+ CASE
+
+
+
+ Mock
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue
index c6dcba5b0c..aa0d69d653 100644
--- a/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue
+++ b/frontend/src/business/components/api/definition/components/case/ApiCaseList.vue
@@ -142,12 +142,12 @@ export default {
},
},
methods: {
- apiCaseSelected(){
+ apiCaseSelected() {
this.selectSize = 0;
if (this.apiCaseList.length > 0) {
this.apiCaseList.forEach(item => {
if (item.selected && item.id) {
- this.selectSize ++;
+ this.selectSize++;
}
});
}
@@ -160,6 +160,18 @@ export default {
this.getApiTest(true);
this.visible = true;
},
+ add(api) {
+ this.api = api;
+ this.condition = {components: API_CASE_CONFIGS};
+ this.sysAddition();
+ this.visible = true;
+ },
+ copy(apiCase) {
+ this.api.id = apiCase.apiDefinitionId;
+ this.condition = {components: API_CASE_CONFIGS};
+ this.sysAddition(apiCase);
+ this.visible = true;
+ },
runTestCase(api, testCaseId) {
this.api = api;
// testCaseId 不为空则为用例编辑页面
@@ -177,7 +189,7 @@ export default {
setEnvironment(environment) {
this.environment = environment;
},
- sysAddition() {
+ sysAddition(apiCase) {
this.condition.projectId = this.projectId;
this.condition.apiDefinitionId = this.api.id;
this.$post("/api/testcase/list", this.condition, response => {
@@ -195,7 +207,11 @@ export default {
}
});
this.apiCaseList = data;
- this.addCase();
+ if (apiCase) {
+ this.copyCase(apiCase);
+ } else {
+ this.addCase();
+ }
});
},
diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue
index 6543a6cdf0..1186521db1 100644
--- a/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue
+++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteHTTPApi.vue
@@ -9,7 +9,6 @@
{{ $t('operating_log.change_history') }}
{{ $t('commons.save') }}
- {{ $t('commons.test') }}
{{ $t('test_track.plan_view.base_info') }}
@@ -85,15 +84,12 @@
{{ $t('test_track.plan_view.mock_info') }}
-
+
Mock地址:
{{ this.getUrlPrefix }}
-
- Mock设置
-
@@ -322,21 +318,6 @@
}
});
},
- mockSetting() {
- if (this.httpForm.id == null) {
- this.$alert(this.$t('api_test.mock.create_error'));
- } else {
- let mockParam = {};
- mockParam.projectId = this.projectId;
- mockParam.apiId = this.httpForm.id;
-
- this.$post('/mockConfig/genMockConfig', mockParam, response => {
- let mockConfig = response.data;
- mockConfig.apiName = this.httpForm.name;
- this.$emit('mockConfig', mockConfig);
- });
- }
- }
},
created() {
diff --git a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue
index d0e3963ba7..50f32b24e5 100644
--- a/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue
+++ b/frontend/src/business/components/api/definition/components/list/ApiCaseSimpleList.vue
@@ -7,7 +7,7 @@
-
+ {{ $t('commons.add') }}
@@ -163,7 +163,7 @@ import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
-import {getBodyUploadFiles, getCurrentProjectID} from "@/common/js/utils";
+import {getBodyUploadFiles, getCurrentProjectID, getUUID} from "@/common/js/utils";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
import MsReferenceView from "../reference/ReferenceView";
@@ -248,6 +248,13 @@ export default {
exec: this.handleTestCase,
permissions: ['PROJECT_API_DEFINITION:READ+EDIT_CASE']
},
+ {
+ tip: this.$t('commons.copy'),
+ exec: this.handleCopy,
+ icon: "el-icon-document-copy",
+ type: "primary",
+ permissions: ['PROJECT_API_DEFINITION:READ+COPY_CASE']
+ },
{
tip: this.$t('commons.delete'),
exec: this.deleteToGc,
@@ -294,6 +301,7 @@ export default {
},
props: {
currentProtocol: String,
+ apiDefinitionId: String,
selectNodeIds: Array,
activeDom: String,
visible: {
@@ -406,6 +414,9 @@ export default {
this.condition.orders.splice(index, 1);
}
}
+ if (this.apiDefinitionId) {
+ this.condition.apiDefinitionId = this.apiDefinitionId;
+ }
this.condition.status = "";
this.condition.moduleIds = this.selectNodeIds;
if (this.trashEnable) {
@@ -537,6 +548,33 @@ export default {
this.$refs.caseList.open(selectApi, testCase.id);
});
},
+ addTestCase() {
+ this.$get('/api/definition/get/' + this.apiDefinitionId, (response) => {
+ let api = response.data;
+ let selectApi = api;
+ let request = {};
+ if (Object.prototype.toString.call(api.request).match(/\[object (\w+)\]/)[1].toLowerCase() === 'object') {
+ request = api.request;
+ } else {
+ request = JSON.parse(api.request);
+ }
+ if (!request.hashTree) {
+ request.hashTree = [];
+ }
+ selectApi.url = request.path;
+ this.$refs.caseList.add(selectApi);
+ });
+ },
+ handleCopy(row) {
+ this.$get('/api/testcase/findById/' + row.id, (response) => {
+ let data = response.data;
+ let uuid = getUUID();
+ let apiCaseRequest = JSON.parse(data.request);
+ apiCaseRequest.id = uuid;
+ let obj = {name: "copy_" + data.name, apiDefinitionId: row.apiDefinitionId, priority: data.priority, active: true, tags: data.tags, request: apiCaseRequest, uuid: uuid};
+ this.$refs.caseList.copy(obj);
+ });
+ },
handleDeleteBatch() {
this.$alert(this.$t('api_test.definition.request.delete_case_confirm') + "?", '', {
confirmButtonText: this.$t('commons.confirm'),
@@ -594,8 +632,6 @@ export default {
}
});
});
-
-
},
handleEditBatch() {
if (this.currentProtocol == 'HTTP') {
@@ -640,7 +676,6 @@ export default {
return;
},
deleteToGc(apiCase) {
-
let obj = {};
obj.projectId = this.projectId;
obj.selectAllDate = false;