From cc5ff944d1ed0ac524591553486cdc6a6effaadf Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 26 Mar 2021 17:06:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=90=9C=E7=B4=A2=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/service/TestCaseService.java | 11 +- .../automation/scenario/ApiScenarioModule.vue | 79 +++++---- .../components/module/ApiModuleHeader.vue | 161 +++++++++--------- .../common/components/search/MsSearchBar.vue | 78 +++++++++ .../track/common/TestCaseNodeTree.vue | 61 +++---- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 8 files changed, 236 insertions(+), 157 deletions(-) create mode 100644 frontend/src/business/components/common/components/search/MsSearchBar.vue diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 0829f73e25..fe7164524f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -533,12 +533,15 @@ public class TestCaseService { } } - for (int j = 0; j < jsonArray.size(); j++) { - int num = j + 1; - step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\r\n"); - result.append(num + "." + jsonArray.getJSONObject(j).getString("result") + "\r\n"); + if (CollectionUtils.isNotEmpty(jsonArray)) { + for (int j = 0; j < jsonArray.size(); j++) { + int num = j + 1; + step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\r\n"); + result.append(num + "." + jsonArray.getJSONObject(j).getString("result") + "\r\n"); + } } + data.setStepDesc(step.toString()); data.setStepResult(result.toString()); step.setLength(0); diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue index 34d27cba63..3208861566 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioModule.vue @@ -16,32 +16,9 @@ ref="nodeTree"> @@ -64,10 +41,12 @@ import {buildNodePath} from "../../definition/model/NodeTree"; import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton"; import ApiImport from "./common/ScenarioImport"; + import MsSearchBar from "@/business/components/common/components/search/MsSearchBar"; export default { name: 'MsApiScenarioModule', components: { + MsSearchBar, ApiImport, ModuleTrashButton, MsNodeTree, @@ -105,6 +84,33 @@ data: [], currentModule: undefined, moduleOptions: [], + operators: [ + { + label: this.$t('api_test.automation.add_scenario'), + callback: this.addScenario + }, + { + label: this.$t('api_test.api_import.label'), + callback: this.handleImport + }, + { + label: this.$t('report.export'), + children: [ + { + label: this.$t('report.export_to_ms_format') , + callback: () => { + this.$emit('exportAPI'); + } + }, + { + label: this.$t('report.export') + 'JMETER 格式', + callback: () => { + this.$emit('exportJmx'); + } + } + ] + } + ] } }, mounted() { @@ -151,14 +157,19 @@ break; } }, - chooseExportType(e) { - switch (e) { - case "export": - this.$emit('exportAPI'); - break; - case "exportJmx": - this.$emit('exportJmx'); - break; + handleImport() { + if (this.projectId) { + this.result = this.$get("/api/automation/module/list/" + this.projectId, response => { + if (response.data != undefined && response.data != null) { + this.data = response.data; + let moduleOptions = []; + this.data.forEach(node => { + buildNodePath(node, {path: ''}, moduleOptions); + }); + this.moduleOptions = moduleOptions + } + }); + this.$refs.apiImport.open(this.currentModule); } }, list(projectId) { diff --git a/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue b/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue index 2c100c9edf..c1a13a07fb 100644 --- a/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue +++ b/frontend/src/business/components/api/definition/components/module/ApiModuleHeader.vue @@ -1,46 +1,23 @@