diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index cd26921351..896e701068 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -76,7 +76,7 @@ public class MsJDBCSampler extends MsTestElement { if (config.getConfig() == null) { // 单独接口执行 this.setProjectId(config.getProjectId()); - config.setConfig(getEnvironmentConfig(useEnvironment)); + config.setConfig(getEnvironmentConfig(StringUtils.isNotEmpty(useEnvironment) ? useEnvironment : environmentId)); } // 数据兼容处理 diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 33c67ad0cc..77cf9319f6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -878,7 +878,7 @@ public class ApiAutomationService { } testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig()); // 生成集成报告 - if (request.getConfig() != null && request.getConfig().getMode().equals("serial")) { + if (request.getConfig() != null && request.getConfig().getMode().equals("serial") && StringUtils.isNotEmpty(request.getConfig().getReportName())) { request.getConfig().setReportId(UUID.randomUUID().toString()); APIScenarioReportResult report = createScenarioReport(request.getConfig().getReportId(), JSON.toJSONString(reportList), request.getConfig().getReportName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(), ExecuteType.Saved.name(), request.getProjectId(), request.getReportUserID(), request.getConfig()); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java index 3c33f855f2..f0a23ea6ce 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiModuleService.java @@ -240,12 +240,14 @@ public class ApiModuleService extends NodeTreeService { if (apiDefinition != null && StringUtils.isNotBlank(apiDefinition.getModulePath())) { StringBuilder path = new StringBuilder(apiDefinition.getModulePath()); List pathLists = Arrays.asList(path.toString().split("/")); - pathLists.set(request.getLevel(), request.getName()); - path.delete(0, path.length()); - for (int i = 1; i < pathLists.size(); i++) { - path = path.append("/").append(pathLists.get(i)); + if (pathLists.size() > request.getLevel()) { + pathLists.set(request.getLevel(), request.getName()); + path.delete(0, path.length()); + for (int i = 1; i < pathLists.size(); i++) { + path = path.append("/").append(pathLists.get(i)); + } + apiDefinition.setModulePath(path.toString()); } - apiDefinition.setModulePath(path.toString()); } }); batchUpdateApiDefinition(apiDefinitionResults); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index 8e3fec67f2..bdc552bbad 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -189,18 +189,20 @@ public class ApiScenarioModuleService extends NodeTreeService apiScenarios = queryByModuleIds(request); -// apiScenarios.forEach(apiScenario -> { -// StringBuilder path = new StringBuilder(apiScenario.getModulePath()); -// List pathLists = Arrays.asList(path.toString().split("/")); -// pathLists.set(request.getLevel(), request.getName()); -// path.delete(0, path.length()); -// for (int i = 1; i < pathLists.size(); i++) { -// path.append("/").append(pathLists.get(i)); -// } -// apiScenario.setModulePath(path.toString()); -// }); -// batchUpdateApiScenario(apiScenarios); + List apiScenarios = queryByModuleIds(request); + apiScenarios.forEach(apiScenario -> { + StringBuilder path = new StringBuilder(apiScenario.getModulePath()); + List pathLists = Arrays.asList(path.toString().split("/")); + if (pathLists.size() > request.getLevel()) { + pathLists.set(request.getLevel(), request.getName()); + path.delete(0, path.length()); + for (int i = 1; i < pathLists.size(); i++) { + path.append("/").append(pathLists.get(i)); + } + apiScenario.setModulePath(path.toString()); + } + }); + batchUpdateApiScenario(apiScenarios); return apiScenarioModuleMapper.updateByPrimaryKeySelective(request); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java index 889293966e..d49d9f1a03 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java @@ -117,6 +117,7 @@ public class TestPlanScenarioCaseService { request.setId(testPlanScenarioRequest.getId()); request.setExecuteType(ExecuteType.Saved.name()); request.setTriggerMode(testPlanScenarioRequest.getTriggerMode()); + request.setConfig(testPlanScenarioRequest.getConfig()); return apiAutomationService.run(request); } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index e435fe1d01..cd0ea7de5f 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit e435fe1d01a2495481efa58daf3875be07b2ac9b +Subproject commit cd0ea7de5f69a33830725e26e71e65b3345903fe diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index 96762966d4..85152d6f06 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -68,7 +68,7 @@ import MsAsideContainer from "@/business/components/common/components/MsAsideContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer"; import MsApiScenarioList from "@/business/components/api/automation/scenario/ApiScenarioList"; - import {getUUID, downloadFile, checkoutTestManagerOrTestUser,getCurrentUser} from "@/common/js/utils"; + import {getUUID, downloadFile, checkoutTestManagerOrTestUser, getCurrentUser} from "@/common/js/utils"; import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule"; import MsEditApiScenario from "./scenario/EditApiScenario"; @@ -114,7 +114,8 @@ loading: false, trashEnable: false, selectNodeIds: [], - nodeTree: [] + nodeTree: [], + currentModulePath: "", } }, watch: { @@ -180,14 +181,30 @@ this.redirectFlag = "none"; } }, + getPath(id, arr) { + if (id === null) { + return null; + } + if(arr) { + arr.forEach(item => { + if (item.id === id) { + this.currentModulePath = item.path; + } + if (item.children && item.children.length > 0) { + this.getPath(id, item.children); + } + }); + } + }, addTab(tab) { - if(tab.name==='default'){ + if (tab.name === 'default') { this.$refs.apiScenarioList.search(); } if (!this.projectId) { this.$warning(this.$t('commons.check_project_tip')); return; } + this.currentModulePath = ""; if (tab.name === 'add') { let label = this.$t('api_test.automation.add_scenario'); let name = getUUID().substring(0, 8); @@ -199,11 +216,14 @@ }; if (this.nodeTree && this.nodeTree.length > 0) { currentScenario.apiScenarioModuleId = this.nodeTree[0].id; - currentScenario.modulePath = this.nodeTree[0].path; + this.getPath(this.nodeTree[0].id, this.moduleOptions); + currentScenario.modulePath = this.currentModulePath; } if (this.selectNodeIds && this.selectNodeIds.length > 0) { currentScenario.apiScenarioModuleId = this.selectNodeIds[0]; + this.getPath(this.selectNodeIds[0], this.moduleOptions); + currentScenario.modulePath = this.currentModulePath; } this.tabs.push({label: label, name: name, currentScenario: currentScenario}); } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 750513e20b..256cf34a6d 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -877,15 +877,11 @@ this.reload(); } }, - nodeExpand(data) { - if (data.resourceId) { - this.expandedNode.push(data.resourceId); - } + nodeExpand(data, node) { + node.expanded = true; }, - nodeCollapse(data) { - if (data.resourceId) { - this.expandedNode.splice(this.expandedNode.indexOf(data.resourceId), 1); - } + nodeCollapse(data,node) { + node.expanded = false; }, setFiles(item, bodyUploadFiles, obj) { if (item.body) { diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index 1932b7ff6d..8fb2f567d0 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -161,6 +161,7 @@ import {API_CASE_LIST, API_LIST} from "@/common/js/constants"; import MockConfig from "@/business/components/api/definition/components/mock/MockConfig"; + export default { name: "ApiDefinition", computed: { @@ -228,7 +229,8 @@ }], activeDom: "left", syncTabs: [], - nodeTree: [] + nodeTree: [], + currentModulePath: "", } }, created() { @@ -269,7 +271,21 @@ }, methods: { - + getPath(id, arr) { + if (id === null) { + return null; + } + if(arr) { + arr.forEach(item => { + if (item.id === id) { + this.currentModulePath = item.path; + } + if (item.children && item.children.length > 0) { + this.getPath(id, item.children); + } + }); + } + }, changeRedirectParam(redirectIDParam) { this.redirectID = redirectIDParam; }, @@ -313,12 +329,17 @@ status: "Underway", method: "GET", userId: getCurrentUser().id, url: "", protocol: this.currentProtocol, environmentId: "", moduleId: 'default-module', modulePath: "/" + this.$t("commons.module_title") }; + this.currentModulePath = ""; if (this.nodeTree && this.nodeTree.length > 0) { api.moduleId = this.nodeTree[0].id; - api.modulePath = this.nodeTree[0].path; + this.getPath(this.nodeTree[0].id, this.moduleOptions); + api.modulePath = this.currentModulePath; } + if (this.selectNodeIds && this.selectNodeIds.length > 0) { api.moduleId = this.selectNodeIds[0]; + this.getPath(this.selectNodeIds[0], this.moduleOptions); + api.modulePath = this.currentModulePath; } this.handleTabsEdit(this.$t('api_test.definition.request.title'), e, api); }, diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue index 86634be31f..33eebf518e 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestHTTPPage.vue @@ -65,7 +65,7 @@ + @runRefresh="runRefresh" @errorRefresh="errorRefresh" ref="runTest"/> @@ -144,6 +144,9 @@ } }) }, + errorRefresh(){ + this.loading = false; + }, runRefresh(data) { this.responseData = {type: 'HTTP', responseResult: {responseCode: ""}, subRequestResults: []}; if (data) { diff --git a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue index eb77841309..9bca64756f 100644 --- a/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue +++ b/frontend/src/business/components/api/definition/components/runtest/RunTestSQLPage.vue @@ -38,7 +38,7 @@ + @runRefresh="runRefresh" @errorRefresh="errorRefresh" ref="runTest"/> @@ -108,6 +108,9 @@ export default { refresh(){ this.$emit('refresh'); }, + errorRefresh(){ + this.loading = false; + }, runTest() { this.loading = true; this.api.request.name = this.api.id;