refactor(工作台): 测试计划为空返回空数据

This commit is contained in:
guoyuqi 2024-12-05 19:18:57 +08:00 committed by Craftsman
parent 9e06b36f6f
commit 95eedaa556
2 changed files with 9 additions and 0 deletions

View File

@ -718,6 +718,9 @@ public class DashboardService {
if (Boolean.FALSE.equals(permissionCheckService.checkModule(projectId, TEST_PLAN_MODULE, currentUserId, PermissionConstants.TEST_PLAN_READ))) {
overViewCountDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());
}
if (StringUtils.isBlank(request.getPlanId())) {
return new OverViewCountDTO(new HashMap<>(), new ArrayList<>(), new ArrayList<>(), 0);
}
List<String> planIds = List.of(request.getPlanId());
List<TestPlanStatisticsResponse> testPlanStatisticsResponses = planStatisticsService.calculateRate(planIds);
TestPlanStatisticsResponse planCount = testPlanStatisticsResponses.getFirst();

View File

@ -178,6 +178,12 @@ public class DashboardFrontPageControllerTests extends BaseTest {
OverViewCountDTO.class);
Assertions.assertNotNull(moduleCountAll);
mvcResultAll = this.requestPostWithOkAndReturn(PROJECT_PLAN_VIEW, dashboardFrontPageRequest);
moduleCountAll = JSON.parseObject(JSON.toJSONString(
JSON.parseObject(mvcResultAll.getResponse().getContentAsString(StandardCharsets.UTF_8), ResultHolder.class).getData()),
OverViewCountDTO.class);
Assertions.assertNotNull(moduleCountAll);
dashboardFrontPageRequest.setPlanId("dashboard_test-plan-id");
mvcResultAll = this.requestPostWithOkAndReturn(PROJECT_PLAN_VIEW, dashboardFrontPageRequest);
moduleCountAll = JSON.parseObject(JSON.toJSONString(