From 1294739df647d56f97aff4f43f79378fe6a8d724 Mon Sep 17 00:00:00 2001 From: q4speed Date: Thu, 23 Apr 2020 17:08:48 +0800 Subject: [PATCH] run button --- .../api/controller/APITestController.java | 10 ++--- .../api/service/ApiTestService.java | 4 ++ .../components/api/test/ApiTestConfig.vue | 43 ++++++++++++++----- .../components/api/test/ApiTestList.vue | 2 +- frontend/src/i18n/zh-CN.js | 1 + 5 files changed, 44 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index d045159cd3..06c8ee848d 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -60,9 +60,9 @@ public class APITestController { public void delete(@RequestBody DeleteAPITestRequest request) { apiTestService.delete(request); } -// -// @PostMapping("/run") -// public void run(@RequestBody RunTestPlanRequest request) { -// apiTestService.run(request); -// } + + @PostMapping("/run") + public void run(@RequestBody SaveAPITestRequest request) { + apiTestService.run(request); + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestService.java index c9480cd8d2..a29c96eec2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestService.java @@ -66,6 +66,10 @@ public class ApiTestService { apiTestMapper.deleteByPrimaryKey(request.getId()); } + public void run(SaveAPITestRequest request) { + save(request); + } + private ApiTestWithBLOBs updateTest(SaveAPITestRequest request) { final ApiTestWithBLOBs test = new ApiTestWithBLOBs(); test.setId(request.getId()); diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index ad2dfa3987..f0494e0184 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -11,7 +11,15 @@ - {{$t('commons.save')}} + + + {{$t('commons.save')}} + + + + {{$t('load_test.save_and_run')}} + + {{$t('commons.cancel')}} @@ -43,7 +51,7 @@ watch: { '$route'(to) { - if (to.params.type === "edit") { + if (to.query.id) { this.getTest(to.query.id); } else { this.test = new Test(); @@ -75,20 +83,35 @@ saveTest: function () { this.change = false; - let param = { - id: this.test.id, - projectId: this.test.projectId, - name: this.test.name, - scenarioDefinition: JSON.stringify(this.test.scenarioDefinition) - } - - this.result = this.$post("/api/save", param, response => { + this.result = this.$post("/api/save", this.getParam(), response => { this.test.id = response.data; this.$message({ message: this.$t('commons.save_success'), type: 'success' }); }); + }, + runTest: function () { + this.change = false; + + this.result = this.$post("/api/run", this.getParam(), response => { + this.test.id = response.data; + this.$message({ + message: this.$t('commons.save_success'), + type: 'success' + }); + }); + }, + clear: function () { + this.test = new Test(); + }, + getParam: function () { + return { + id: this.test.id, + projectId: this.test.projectId, + name: this.test.name, + scenarioDefinition: JSON.stringify(this.test.scenarioDefinition) + } } }, diff --git a/frontend/src/business/components/api/test/ApiTestList.vue b/frontend/src/business/components/api/test/ApiTestList.vue index 12d5d35a8c..6333996fe5 100644 --- a/frontend/src/business/components/api/test/ApiTestList.vue +++ b/frontend/src/business/components/api/test/ApiTestList.vue @@ -4,7 +4,7 @@