From 95b66ed75acd1eddd2fe5c74b486cb13e697acd5 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 25 Jul 2022 18:50:47 +0800 Subject: [PATCH] =?UTF-8?q?style(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA=E4=B8=AD?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=94=A8=E4=BE=8B=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015004 --user=宋天阳 【接口测试】场景,列表执行或者调试生成报告,没有展示环境信息 https://www.tapd.cn/55049933/s/1210993 --- .../controller/ApiDefinitionController.java | 1 + .../api/service/ApiDefinitionService.java | 10 ++++++ .../ext/ExtApiScenarioReferenceIdMapper.xml | 2 +- .../track/service/TestPlanService.java | 16 +++++++-- .../comonents/load/LoadCaseReportView.vue | 35 +++++++++++++------ .../report/detail/TestPlanReportContent.vue | 2 +- 6 files changed, 51 insertions(+), 15 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index e0a331eb36..a4dd7b2462 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -69,6 +69,7 @@ public class ApiDefinitionController { request.setToBeUpdateTime(toBeUpdatedTime); } } + apiDefinitionService.checkFilterHasCoverage(request); Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, apiDefinitionService.list(request)); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 822cbe4fdc..a9f903f42d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -326,6 +326,16 @@ public class ApiDefinitionService { } } } + return request; + } + + /** + * 检查请求中是否含有覆盖率的查询 + * + * @param request + * @return + */ + public ApiDefinitionRequest checkFilterHasCoverage(ApiDefinitionRequest request) { if (StringUtils.isNotEmpty(request.getProjectId())) { List definitionList = null; if (StringUtils.equalsAnyIgnoreCase(request.getApiCoverage(), "uncoverage", "coverage")) { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml index c7e4eef303..367a4dec05 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReferenceIdMapper.xml @@ -10,7 +10,7 @@ != 'Trash' AND project_id = #{0} AND latest = 1) - AND reference_id IS NOT NULL; + AND reference_id IS NOT NULL \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 0a6fcb38ef..5dbd67092f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -36,9 +36,9 @@ import io.metersphere.performance.service.MetricQueryService; import io.metersphere.performance.service.PerformanceReportService; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.*; -import io.metersphere.track.factory.ReportComponentFactory; import io.metersphere.track.domain.ReportComponent; import io.metersphere.track.dto.*; +import io.metersphere.track.factory.ReportComponentFactory; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest; @@ -1441,7 +1441,17 @@ public class TestPlanService { ApiDefinitionExecResultWithBLOBs result = extApiDefinitionExecResultMapper.selectPlanApiMaxResultByTestIdAndType(apiCase.getId(), "API_PLAN"); if (result != null && StringUtils.isNotBlank(result.getContent())) { apiCase.setReportId(result.getId()); - apiCase.setResponse(result.getContent()); + String contentStr = result.getContent(); + try { + JSONObject content = JSONObject.parseObject(contentStr); + if (StringUtils.isNotEmpty(contentStr)) { + content.put("envName", apiDefinitionService.getEnvNameByEnvConfig(result.getProjectId(), result.getEnvConfig())); + } + contentStr = content.toString(); + apiCase.setResponse(contentStr); + } catch (Exception e) { + LogUtil.error("解析content失败!", e); + } } } else { reportIds.add(apiCase.getReportId()); @@ -1461,7 +1471,7 @@ public class TestPlanService { if (StringUtils.isNotEmpty(execResult.getEnvConfig())) { responseObj.put("envName", apiDefinitionService.getEnvNameByEnvConfig(execResult.getProjectId(), execResult.getEnvConfig())); } - item.setResponse(resultMap.get(item.getReportId()).getContent()); + item.setResponse(responseObj.toString()); } }); } diff --git a/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue b/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue index 820ae4c82b..2cfbc5b9f6 100644 --- a/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue +++ b/frontend/src/business/components/track/plan/view/comonents/load/LoadCaseReportView.vue @@ -63,30 +63,45 @@ - +
+
+ {{ $t('commons.environment') + ':' }} +
+ {{ key + ":" }} + +
+
+ +
+
+
+
+ {{ - $t('report.test_duration', [templateMinutes ? templateMinutes : minutes, - templateSeconds ? templateSeconds : seconds]) - }} + $t('report.test_duration', [templateMinutes ? templateMinutes : minutes, + templateSeconds ? templateSeconds : seconds]) + }} - + {{ $t('report.test_start_time') }}:{{ startTime | timestampFormatDate }} - + {{ $t('report.test_start_time') }}:{{ planReportTemplate.startTime | timestampFormatDate }} - + {{ $t('report.test_start_time') }}:- - + {{ $t('report.test_end_time') }}:{{ endTime | timestampFormatDate }} - + {{ $t('report.test_end_time') }}:{{ planReportTemplate.endTime | timestampFormatDate }} - + {{ $t('report.test_end_time') }}:- +
diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue index d7d708f651..bfa744634c 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue @@ -31,7 +31,6 @@ import TestPlanFunctionalReport from "@/business/components/track/plan/view/comonents/report/detail/TestPlanFunctionalReport"; import { - getExportReport, getShareTestPlanReport, getShareTestPlanReportContent, getTestPlanReport, @@ -50,6 +49,7 @@ import TestPlanReportNavigationBar from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportNavigationBar"; import MsContainer from "@/business/components/common/components/MsContainer"; import MsMainContainer from "@/business/components/common/components/MsMainContainer"; + export default { name: "TestPlanReportContent", components: {