From d8094b39076e50039d119e4b1dd087b1f8623b4a Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 27 Aug 2020 14:59:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=B8=80=E9=94=AE=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E9=A1=B9=E7=9B=AE=E6=8A=A5=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/business/components/api/test/OneClickOperation.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/business/components/api/test/OneClickOperation.vue b/frontend/src/business/components/api/test/OneClickOperation.vue index 7a1b3285bd..cc299f7879 100644 --- a/frontend/src/business/components/api/test/OneClickOperation.vue +++ b/frontend/src/business/components/api/test/OneClickOperation.vue @@ -75,12 +75,16 @@ checkedSaveAndRunTest() { if (this.selectNames.has(this.ruleForm.testName)) { this.selectIds.clear() + this.selectProjectNames.clear() + this.selectNames.clear() this.$warning(this.$t('load_test.already_exists')); this.oneClickOperationVisible = false; this.$emit('refresh') } else { if (this.selectProjectNames.size > 1) { this.selectIds.clear() + this.selectProjectNames.clear() + this.selectNames.clear() this.$warning(this.$t('load_test.same_project_test')); this.oneClickOperationVisible = false; this.$emit('refresh') From 98b039123459e8a41fccad941c98067eba6a172d Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 27 Aug 2020 15:51:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=B8=80=E9=94=AE=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E9=A1=B9=E7=9B=AE=E6=8A=A5=E9=94=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/api/test/ApiTestList.vue | 33 +++++++++++-------- .../components/api/test/OneClickOperation.vue | 9 ++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/frontend/src/business/components/api/test/ApiTestList.vue b/frontend/src/business/components/api/test/ApiTestList.vue index 4366a21153..b2050c22f0 100644 --- a/frontend/src/business/components/api/test/ApiTestList.vue +++ b/frontend/src/business/components/api/test/ApiTestList.vue @@ -128,23 +128,25 @@ export default { }, handleSelectAll(selection) { + this.selectIds.clear() + this.selectProjectNames.clear() + this.selectNames.clear() if (selection.length > 0) { - this.tableData.forEach(item => { - this.selectIds.add(item.id); - this.selectProjectNames.add(item.projectName) - }); - } else { - this.selectIds.clear() - this.selectProjectNames.clear() + selection.forEach(s => { + this.selectIds.add(s.id) + this.selectProjectNames.add(s.projectName) + }) } }, - selectionChange(selection, row) { - if (this.selectIds.has(row.id)) { - this.selectIds.delete(row.id); - this.selectProjectNames.delete(row.projectName) - } else { - this.selectIds.add(row.id); - this.selectProjectNames.add(row.projectName) + selectionChange(selection) { + this.selectIds.clear() + this.selectProjectNames.clear() + this.selectNames.clear() + if (selection.length > 0) { + selection.forEach(s => { + this.selectIds.add(s.id) + this.selectProjectNames.add(s.projectName) + }) } }, runTest() { @@ -200,6 +202,9 @@ export default { this.$refs.apiCopy.open(test); }, init() { + this.selectIds.clear() + this.selectProjectNames.clear() + this.selectNames.clear() this.projectId = this.$route.params.projectId; if (this.projectId && this.projectId !== "all") { this.$store.commit('setProjectId', this.projectId); diff --git a/frontend/src/business/components/api/test/OneClickOperation.vue b/frontend/src/business/components/api/test/OneClickOperation.vue index cc299f7879..adc2cbf317 100644 --- a/frontend/src/business/components/api/test/OneClickOperation.vue +++ b/frontend/src/business/components/api/test/OneClickOperation.vue @@ -74,17 +74,14 @@ }, checkedSaveAndRunTest() { if (this.selectNames.has(this.ruleForm.testName)) { - this.selectIds.clear() - this.selectProjectNames.clear() - this.selectNames.clear() this.$warning(this.$t('load_test.already_exists')); this.oneClickOperationVisible = false; this.$emit('refresh') } else { if (this.selectProjectNames.size > 1) { - this.selectIds.clear() - this.selectProjectNames.clear() - this.selectNames.clear() + + /* console.log(this.selectIds) + console.log(this.selectNames)*/ this.$warning(this.$t('load_test.same_project_test')); this.oneClickOperationVisible = false; this.$emit('refresh') From 00c269ff8d93b79e22333eb2e80fd1ca1a45f865 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Fri, 28 Aug 2020 10:30:42 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=E5=88=9B=E5=BB=BA=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=82=B9=E5=87=BB=E7=AA=97=E5=8F=A3=E5=A4=96?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E4=B8=8D=E5=85=B3=E9=97=AD=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=20fix:=E6=B5=8B=E8=AF=95=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/APITestController.java | 4 + .../api/service/APITestService.java | 7 + .../components/api/test/ApiTestList.vue | 332 +++++++++--------- .../components/api/test/OneClickOperation.vue | 35 +- .../track/case/components/TestCaseEdit.vue | 2 +- 5 files changed, 198 insertions(+), 182 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 d423ab0604..01d6fb3e53 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -94,6 +94,10 @@ public class APITestController { public String runDebug(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List bodyFiles) { return apiTestService.runDebug(request, file, bodyFiles); } + @PostMapping(value = "/checkName") + public void checkName(@RequestBody SaveAPITestRequest request) { + apiTestService.checkName(request); + } @PostMapping(value = "/import", consumes = {"multipart/form-data"}) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) 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 f1fc146c74..ea5690ecae 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -245,6 +245,13 @@ public class APITestService { MSException.throwException(Translator.get("load_test_already_exists")); } } + public void checkName(SaveAPITestRequest request) { + ApiTestExample example = new ApiTestExample(); + example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()); + if (apiTestMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("load_test_already_exists")); + } + } private ApiTest updateTest(SaveAPITestRequest request) { checkNameExist(request); diff --git a/frontend/src/business/components/api/test/ApiTestList.vue b/frontend/src/business/components/api/test/ApiTestList.vue index b2050c22f0..18779dc6fa 100644 --- a/frontend/src/business/components/api/test/ApiTestList.vue +++ b/frontend/src/business/components/api/test/ApiTestList.vue @@ -11,8 +11,9 @@ - + diff --git a/frontend/src/business/components/api/test/OneClickOperation.vue b/frontend/src/business/components/api/test/OneClickOperation.vue index adc2cbf317..9ea2c7e268 100644 --- a/frontend/src/business/components/api/test/OneClickOperation.vue +++ b/frontend/src/business/components/api/test/OneClickOperation.vue @@ -41,6 +41,7 @@ tests: [], ruleForm: {}, change: false, + projectId: "", rule: { testName: [ {required: true, message: this.$t('api_test.input_name'), trigger: 'blur'}, @@ -61,10 +62,10 @@ selectIds: { type: Set }, - selectNames: { + selectProjectNames: { type: Set }, - selectProjectNames: { + selectProjectId: { type: Set } }, @@ -73,23 +74,30 @@ this.oneClickOperationVisible = true; }, checkedSaveAndRunTest() { - if (this.selectNames.has(this.ruleForm.testName)) { - this.$warning(this.$t('load_test.already_exists')); - this.oneClickOperationVisible = false; - this.$emit('refresh') - } else { + if (this.ruleForm.testName) { if (this.selectProjectNames.size > 1) { - - /* console.log(this.selectIds) - console.log(this.selectNames)*/ this.$warning(this.$t('load_test.same_project_test')); this.oneClickOperationVisible = false; this.$emit('refresh') } else { - for (let x of this.selectIds) { - this.getTest(x) - } + this.checkNameResult(this.ruleForm.testName) } + } else { + this.$warning(this.$t('api_test.input_name')) + } + }, + checkNameResult() { + this.checkName(() => { + for (let x of this.selectIds) { + this.getTest(x) + } + }) + }, + checkName(callback) { + for (let i of this.selectProjectId) { + this.result = this.$post('/api/checkName', {name: this.ruleForm.testName, projectId: i}, response => { + if (callback) callback(); + }) } }, _getEnvironmentAndRunTest: function (item) { @@ -123,6 +131,7 @@ scenarioDefinition: JSON.parse(item.scenarioDefinition), schedule: {}, }); + console.log(test) this.test = this.test || test; if (this.tests.length > 1) { this.test.scenarioDefinition = this.test.scenarioDefinition.concat(test.scenarioDefinition); diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index bb33f1b561..1c5c4d3358 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -4,7 +4,7 @@ + :visible.sync="dialogFormVisible" width="65%" :close-on-click-modal="false">