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 a1c9e4aed3..313901669b 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/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 78c24f661f..ffdc9e430b 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -619,7 +619,10 @@ } }, canExecWithOutEnv(type, path) { - return type !== ELEMENT_TYPE.HTTPSamplerProxy ? !this.checkCanExec(type) : this.isHTTPFullPath(path); + if (type === ELEMENT_TYPE.HTTPSamplerProxy) { + return this.isHTTPFullPath(path); + } + return type === ELEMENT_TYPE.JSR223Processor ? true : !this.checkCanExec(type); }, isHTTPFullPath(path) { return path ? path.startsWith("http://") || path.startsWith("https://") : false; diff --git a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue index 3cd0fa2ffd..77a8070542 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue @@ -531,7 +531,10 @@ } }, canExecWithOutEnv(type, path) { - return type !== ELEMENT_TYPE.HTTPSamplerProxy ? !this.checkCanExec(type) : this.isHTTPFullPath(path); + if (type === ELEMENT_TYPE.HTTPSamplerProxy) { + return this.isHTTPFullPath(path); + } + return type === ELEMENT_TYPE.JSR223Processor ? true : !this.checkCanExec(type); }, isHTTPFullPath(path) { return path ? path.startsWith("http://") || path.startsWith("https://") : false; 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 @@