diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java index 74b0b7bcea..623bfe86bf 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/scenario/ApiScenarioReportService.java @@ -15,10 +15,12 @@ import io.metersphere.sdk.constants.ApiReportStatus; import io.metersphere.sdk.domain.Environment; import io.metersphere.sdk.domain.EnvironmentGroup; import io.metersphere.sdk.dto.api.result.RequestResult; -import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.mapper.EnvironmentGroupMapper; import io.metersphere.sdk.mapper.EnvironmentMapper; -import io.metersphere.sdk.util.*; +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.sdk.util.JSON; +import io.metersphere.sdk.util.SubListUtils; +import io.metersphere.sdk.util.Translator; import io.metersphere.system.mapper.TestResourcePoolMapper; import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.service.UserLoginService; @@ -195,37 +197,47 @@ public class ApiScenarioReportService { List deatilList = extApiScenarioReportMapper.selectStepDeatilByReportId(id); //根据stepId进行分组 Map> detailMap = deatilList.stream().collect(Collectors.groupingBy(ApiScenarioReportStepDTO::getStepId)); + //只处理请求的 + List stepTypes = Arrays.asList(ApiScenarioStepType.API_CASE.name(), + ApiScenarioStepType.API.name(), + ApiScenarioStepType.CUSTOM_REQUEST.name()); scenarioReportSteps.parallelStream().forEach(step -> { - List details = detailMap.get(step.getStepId()); - if (CollectionUtils.isNotEmpty(details)) { - details.sort(Comparator.comparingLong(ApiScenarioReportStepDTO::getLoopIndex)); - //需要重新处理sort - for (int i = 0; i < details.size(); i++) { - ApiScenarioReportStepDTO detail = details.get(i); - detail.setSort((long) i + 1); - detail.setStepId(step.getStepId() + SPLITTER + detail.getSort()); - detail.setStepType(step.getStepType()); - detail.setName(detail.getRequestName()); - } - step.setChildren(details); - //只处理请求的 - List stepTypes = Arrays.asList(ApiScenarioStepType.API_CASE.name(), - ApiScenarioStepType.API.name(), - ApiScenarioStepType.CUSTOM_REQUEST.name()); - if (stepTypes.contains(step.getStepType())) { - step.setRequestTime(details.stream().mapToLong(ApiScenarioReportStepDTO::getRequestTime).sum()); - step.setResponseSize(details.stream().mapToLong(ApiScenarioReportStepDTO::getResponseSize).sum()); - List requestStatus = details.stream().map(ApiScenarioReportStepDTO::getStatus).toList(); - List successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ApiReportStatus.SUCCESS.name(), status)).toList(); - if (requestStatus.contains(ApiReportStatus.ERROR.name())) { - step.setStatus(ApiReportStatus.ERROR.name()); - } else if (requestStatus.contains(ApiReportStatus.FAKE_ERROR.name())) { - step.setStatus(ApiReportStatus.FAKE_ERROR.name()); - } else if (successStatus.size() == details.size()) { - step.setStatus(ApiReportStatus.SUCCESS.name()); - } else { - step.setStatus(ApiReportStatus.PENDING.name()); + if (stepTypes.contains(step.getStepType())) { + List details = detailMap.get(step.getStepId()); + if (CollectionUtils.isNotEmpty(details) && details.size() > 1) { + details.sort(Comparator.comparingLong(ApiScenarioReportStepDTO::getLoopIndex)); + if (details.size() > 1) { + //需要重新处理sort + for (int i = 0; i < details.size(); i++) { + ApiScenarioReportStepDTO detail = details.get(i); + detail.setSort((long) i + 1); + detail.setStepId(step.getStepId() + SPLITTER + detail.getSort()); + detail.setStepType(step.getStepType()); + detail.setName(detail.getRequestName()); + } + + step.setRequestTime(details.stream().mapToLong(ApiScenarioReportStepDTO::getRequestTime).sum()); + step.setResponseSize(details.stream().mapToLong(ApiScenarioReportStepDTO::getResponseSize).sum()); + List requestStatus = details.stream().map(ApiScenarioReportStepDTO::getStatus).toList(); + List successStatus = requestStatus.stream().filter(status -> StringUtils.equals(ApiReportStatus.SUCCESS.name(), status)).toList(); + if (requestStatus.contains(ApiReportStatus.ERROR.name())) { + step.setStatus(ApiReportStatus.ERROR.name()); + } else if (requestStatus.contains(ApiReportStatus.FAKE_ERROR.name())) { + step.setStatus(ApiReportStatus.FAKE_ERROR.name()); + } else if (successStatus.size() == details.size()) { + step.setStatus(ApiReportStatus.SUCCESS.name()); + } else { + step.setStatus(ApiReportStatus.PENDING.name()); + } } + step.setChildren(details); + } else if (CollectionUtils.isNotEmpty(details)){ + step.setName(details.getFirst().getRequestName()); + step.setReportId(details.getFirst().getReportId()); + step.setRequestTime(details.getFirst().getRequestTime()); + step.setResponseSize(details.getFirst().getResponseSize()); + step.setStatus(details.getFirst().getStatus()); + step.setScriptIdentifier(details.getFirst().getScriptIdentifier()); } } }); @@ -235,6 +247,7 @@ public class ApiScenarioReportService { // TODO 查询修改 List steps = Optional.ofNullable(scenarioReportStepMap.get("NONE")).orElse(new ArrayList<>(0)); steps.sort(Comparator.comparingLong(ApiScenarioReportStepDTO::getSort)); + getStepTree(steps, scenarioReportStepMap); scenarioReportDTO.setStepTotal(steps.size()); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java index a32f5e7ba9..b595eecad7 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/log/constants/OperationLogModule.java @@ -24,10 +24,10 @@ public class OperationLogModule { public static final String API_TEST_MANAGEMENT_MOCK = "API_TEST_MANAGEMENT_MOCK"; public static final String API_TEST_MANAGEMENT_CASE = "API_TEST_MANAGEMENT_CASE"; // 场景管理 - public static final String API_SCENARIO_MANAGEMENT_SCENARIO = "API_SCENARIO_MANAGEMENT_SCENARIO"; + public static final String API_SCENARIO_MANAGEMENT_SCENARIO = "API_TEST_SCENARIO"; public static final String API_SCENARIO_MANAGEMENT_MODULE = "API_SCENARIO_MANAGEMENT_MODULE"; - public static final String API_REPORT = "API_REPORT"; + public static final String API_REPORT = "API_TEST_REPORT"; public static final String AUTH_TITLE = "AUTH_TITLE"; public static final String PROJECT_ENVIRONMENT_SETTING = "PROJECT_ENVIRONMENT_SETTING"; public static final String PROJECT_PROJECT_MANAGER = "PROJECT_PROJECT_MANAGER"; diff --git a/frontend/src/config/pathMap.ts b/frontend/src/config/pathMap.ts index f0ec5b684a..fbe86e52ba 100644 --- a/frontend/src/config/pathMap.ts +++ b/frontend/src/config/pathMap.ts @@ -95,7 +95,7 @@ export const pathMap: PathMapItem[] = [ }, { key: 'API_TEST_MANAGEMENT_RECYCLE', // 接口测试-回收站 - locale: 'menu.apiTest.management.bugRecycle', + locale: 'menu.bugManagement.bugRecycle', route: RouteEnum.API_TEST_MANAGEMENT_RECYCLE, permission: [], level: MENU_LEVEL[2], @@ -103,7 +103,7 @@ export const pathMap: PathMapItem[] = [ ], }, { - key: 'API_TEST_SCENARIO', // 接口测试-场景 + key: 'API_SCENARIO_MANAGEMENT_SCENARIO', // 接口测试-场景 locale: 'menu.apiTest.scenario', route: RouteEnum.API_TEST_SCENARIO, permission: [], @@ -111,7 +111,7 @@ export const pathMap: PathMapItem[] = [ children: [ { key: 'API_TEST_SCENARIO_RECYCLE', // 接口测试-回收站 - locale: 'menu.apiTest.scenario.bugRecycle', + locale: 'menu.bugManagement.bugRecycle', route: RouteEnum.API_TEST_SCENARIO_RECYCLE, permission: [], level: MENU_LEVEL[2],