diff --git a/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java b/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java index 76b8171075..b78719870c 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/definition/ApiTestCaseController.java @@ -92,6 +92,11 @@ public class ApiTestCaseController { return apiTestCaseService.getApiCaseEnvironment(caseId); } + @PostMapping("/get/env") + public Map getApiCaseEnvironments(@RequestBody List caseIds) { + return apiTestCaseService.getApiCaseEnvironments(caseIds); + } + @PostMapping("/list-blobs") public List getCaseBLOBs(@RequestBody ApiTestCaseRequest request) { List returnList = apiTestCaseService.findApiTestCaseBLOBs(request); diff --git a/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java b/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java index 0e40c93167..054e796201 100644 --- a/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java +++ b/api-test/backend/src/main/java/io/metersphere/controller/scenario/ApiScenarioController.java @@ -36,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.Map; @RestController @RequestMapping(value = "/api/automation") @@ -417,6 +418,10 @@ public class ApiScenarioController { public List getEnvProjects(@RequestBody RunScenarioRequest request) { return apiAutomationService.getProjects(request); } + @PostMapping(value = "/env/map") + public Map> getProjectEnvMap(@RequestBody RunScenarioRequest request) { + return apiAutomationService.getProjectEnvMap(request); + } /** * 统计场景用例 diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java index 2f07f00095..59506ea43c 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiTestCaseService.java @@ -1055,12 +1055,15 @@ public class ApiTestCaseService { } public Map getApiCaseEnvironments(List caseIds) { + if (CollectionUtils.isEmpty(caseIds)){ + return null; + } List environments = extApiTestCaseMapper.getApiCaseEnvironments(caseIds); if (CollectionUtils.isEmpty(environments)) { return null; } try { - List envIds = environments.stream().map(ParamsDTO::getValue).collect(Collectors.toList()); + List envIds = environments.stream().filter(t->StringUtils.isNotBlank(t.getValue()) && !StringUtils.equalsIgnoreCase(t.getValue(),"null")).map(ParamsDTO::getValue).collect(Collectors.toList()); ApiTestEnvironmentExample example = new ApiTestEnvironmentExample(); example.createCriteria().andIdIn(envIds); List environmentList = apiTestEnvironmentMapper.selectByExample(example); @@ -1069,7 +1072,7 @@ public class ApiTestCaseService { } Map envMap = environmentList.stream().collect(Collectors.toMap(ApiTestEnvironment::getId, ApiTestEnvironment::getName)); - Map caseEnvMap = environments.stream().collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getValue()), HashMap::putAll); + Map caseEnvMap = environments.stream().filter(t->StringUtils.isNotBlank(t.getValue()) && !StringUtils.equalsIgnoreCase(t.getValue(),"null")).collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getValue()), HashMap::putAll); caseEnvMap.forEach((k, v) -> { if (envMap.containsKey(v)) { caseEnvMap.put(k, envMap.get(v)); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index 283f26e63c..dc879a2c43 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -2219,4 +2219,36 @@ public class ApiScenarioService { return extApiScenarioMapper.selectBaseCaseByProjectId(projectId); } + public Map> getProjectEnvMap(RunScenarioRequest request) { + ServiceUtils.getSelectAllIds(request, request.getCondition(), (query) -> extApiScenarioMapper.selectIdsByQuery(query)); + + List ids = request.getIds(); + ApiScenarioExample example = new ApiScenarioExample(); + example.createCriteria().andIdIn(ids); + List apiScenarios = apiScenarioMapper.selectByExampleWithBLOBs(example); + Map> projectEnvMap = new HashMap<>(); + apiScenarios.forEach(item -> { + if (StringUtils.isNotBlank(item.getEnvironmentJson())){ + JSONObject jsonObject = JSONUtil.parseObject(item.getEnvironmentJson()); + Map projectIdEnvMap = jsonObject.toMap(); + if (MapUtils.isNotEmpty(projectIdEnvMap)) { + Set projectIds = projectIdEnvMap.keySet(); + projectIds.forEach(t->{ + List envIds = projectEnvMap.get(t); + if (CollectionUtils.isNotEmpty(envIds)) { + if (!envIds.contains(projectIdEnvMap.get(t).toString())) { + envIds.add(projectIdEnvMap.get(t).toString()); + } + } else { + Object o = projectIdEnvMap.get(t); + ListenvIdList = new ArrayList<>(); + envIdList.add(o.toString()); + projectEnvMap.put(t,envIdList); + } + }); + } + } + }); + return projectEnvMap; + } } diff --git a/api-test/frontend/src/api/api-environment.js b/api-test/frontend/src/api/api-environment.js new file mode 100644 index 0000000000..51aeca5c5c --- /dev/null +++ b/api-test/frontend/src/api/api-environment.js @@ -0,0 +1,7 @@ +import {get, post} from "metersphere-frontend/src/plugins/request" + +const BASE_URL = '/environment/'; + +export function getEnvironmentByProjectId(projectId) { + return get(BASE_URL + `list/${projectId}`); +} diff --git a/api-test/frontend/src/api/api-test-case.js b/api-test/frontend/src/api/api-test-case.js index 92a5ef4617..12dee1f349 100644 --- a/api-test/frontend/src/api/api-test-case.js +++ b/api-test/frontend/src/api/api-test-case.js @@ -85,3 +85,7 @@ export function editApiCase(url, file, files, params) { export function apiTestCaseCount(param) { return post('/api/testcase/case-count',param); } + +export function getApiCaseEnvironments(param) { + return post('/api/testcase/get/env',param); +} diff --git a/api-test/frontend/src/api/scenario.js b/api-test/frontend/src/api/scenario.js index 67911815e5..6ffc09f4c4 100644 --- a/api-test/frontend/src/api/scenario.js +++ b/api-test/frontend/src/api/scenario.js @@ -74,6 +74,10 @@ export function apiScenarioEnv(params) { return post('/api/automation/env', params); } +export function apiScenarioEnvMap(params) { + return post('/api/automation/env/map', params); +} + export function getApiScenarioProjectIdByConditions(params) { return post('/api/automation/list-project-ids', params); } diff --git a/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue b/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue index 483475ba3c..06e6804c43 100644 --- a/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue +++ b/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue @@ -299,11 +299,12 @@ - + ref="apiBatchRun"/> import("../report/ApiReportStatus"), HeaderCustom: () => import("metersphere-frontend/src/components/head/HeaderCustom"), BatchMove: () => import("@/business/commons/BatchMove"), @@ -407,7 +410,6 @@ export default { MsScenarioExtendButtons: () => import("@/business/automation/scenario/ScenarioExtendBtns"), MsTestPlanList: () => import("./testplan/TestPlanList"), MsTableOperatorButton: () => import("metersphere-frontend/src/components/MsTableOperatorButton"), - MsRunMode: () => import("./common/RunMode"), MsTaskCenter: () => import("metersphere-frontend/src/components/task/TaskCenter"), MsRun: () => import("./DebugRun"), MxRelationshipGraphDrawer: () => import("metersphere-frontend/src/components/graph/MxRelationshipGraphDrawer") @@ -1002,8 +1004,9 @@ export default { run.projectId = this.projectId; run.condition = this.condition; this.runRequest = run; - this.$refs.runMode.open(); - + this.$nextTick(() => { + this.$refs.apiBatchRun.open(); + }); }, openSchedule(row) { let run = {}; @@ -1393,9 +1396,6 @@ export default { jmxObj.version = item.version; jmxObjList.push(jmxObj); }); - console.info("000000000"); - console.info(jmxObjList); - console.info("000000000"); performanceStore.$patch({ 'scenarioJmxs': { name: 'Scenarios', diff --git a/api-test/frontend/src/business/automation/scenario/EnvSelectPopover.vue b/api-test/frontend/src/business/automation/scenario/EnvSelectPopover.vue new file mode 100644 index 0000000000..c2a18ea02d --- /dev/null +++ b/api-test/frontend/src/business/automation/scenario/EnvSelectPopover.vue @@ -0,0 +1,180 @@ + + + + + + + diff --git a/api-test/frontend/src/business/automation/scenario/common/ApiRunMode.vue b/api-test/frontend/src/business/automation/scenario/common/ApiRunMode.vue new file mode 100644 index 0000000000..17fc82cc1c --- /dev/null +++ b/api-test/frontend/src/business/automation/scenario/common/ApiRunMode.vue @@ -0,0 +1,335 @@ + + + + + + + diff --git a/api-test/frontend/src/business/automation/scenario/common/RunMode.vue b/api-test/frontend/src/business/automation/scenario/common/RunMode.vue deleted file mode 100644 index a504ae62bd..0000000000 --- a/api-test/frontend/src/business/automation/scenario/common/RunMode.vue +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - diff --git a/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue b/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue index e99a2f27db..58b855ae26 100644 --- a/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue +++ b/api-test/frontend/src/business/definition/components/list/ApiCaseSimpleList.vue @@ -246,12 +246,13 @@ - + ref="apiBatchRun"/> @@ -305,11 +306,8 @@ import MsContainer from "metersphere-frontend/src/components/MsContainer"; import MsBottomContainer from "../BottomContainer"; import ShowMoreBtn from "@/business/commons/ShowMoreBtn"; import MsBatchEdit from "../basis/BatchEdit"; -import MsApiCaseRunModeWithEnv from "@/business/automation/scenario/common/RunMode"; import {getUUID, operationConfirm} from "metersphere-frontend/src/utils"; - import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData"; - import {getCurrentProjectID} from "metersphere-frontend/src/utils/token"; import {hasLicense} from "metersphere-frontend/src/utils/permission"; import {getBodyUploadFiles} from "@/business/definition/api-definition"; @@ -342,7 +340,7 @@ import SyncSetting from "@/business/definition/util/SyncSetting"; import {getEnvironmentByProjectId} from "metersphere-frontend/src/api/environment"; import {useApiStore, usePerformanceStore} from "@/store"; import {REPORT_STATUS} from "@/business/commons/js/commons"; - +import MsApiRunMode from "@/business/automation/scenario/common/ApiRunMode"; const performanceStore = usePerformanceStore(); const store = useApiStore(); @@ -370,7 +368,7 @@ export default { MsTable, MsTableColumn, MsRequestResultTail, - MsApiCaseRunModeWithEnv, + MsApiRunMode, MsSearch, SyncSetting, MsApiReportStatus: () => import("../../../automation/report/ApiReportStatus"), @@ -683,7 +681,10 @@ export default { } }, handleRunBatch() { - this.$refs.batchRun.open(); + this.runCaseIds = Array.from(this.selectRows).map(row => row.id); + this.$nextTick(() => { + this.$refs.apiBatchRun.open(); + }); }, runBatch(config) { let obj = {}; @@ -696,7 +697,7 @@ export default { obj.condition.status = ""; testCaseBatchRun(obj).then(() => { this.condition.ids = []; - this.$refs.batchRun.close(); + this.$refs.apiBatchRun.close(); if (store.currentApiCase) { store.currentApiCase.case = true; } else { diff --git a/test-track/frontend/src/business/plan/common/TestPlanRunModeWithEnv.vue b/test-track/frontend/src/business/plan/common/TestPlanRunModeWithEnv.vue index cda31adf5f..aaed4d9e69 100644 --- a/test-track/frontend/src/business/plan/common/TestPlanRunModeWithEnv.vue +++ b/test-track/frontend/src/business/plan/common/TestPlanRunModeWithEnv.vue @@ -434,12 +434,6 @@ export default { width: 163px; } -.wrap { - display: flex; - align-items: center; - padding: 5px 10px 5px 10px; -} - :deep(.content .el-popover__reference) { width: 100%; } @@ -448,28 +442,6 @@ export default { margin-top: 8px; } -.other-title { - height: 100%; - margin-top: 25px; - align-items: flex-start; -} - -.other-content { - height: 100%; -} - -.other-row { - height: 125px; -} -.project-name { - display: inline-block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - width: 150px; - margin-left: 8px; - vertical-align: middle; -}