From 3cfc0e5547344fff30373f4c92d347cfa364e518 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 18 Nov 2022 18:28:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=BB=9F=E8=AE=A1=E6=95=B0=E9=87=8F=E9=94=99=E8=AF=AF?= =?UTF-8?q?=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=1019799 --user=宋天阳 【接口测试】首页-场景用例数量统计,开启url可重复后,复制和引用case,场景的接口覆盖率没增加 https://www.tapd.cn/55049933/s/1298583 --- .../mapper/ext/ExtApiScenarioReportMapper.xml | 10 ++------- .../ApiDefinitionExecResultService.java | 7 +++--- .../service/scenario/ApiScenarioService.java | 22 +++++-------------- .../frontend/src/business/home/ApiHome.vue | 6 ++--- .../home/components/chart/CountChart.vue | 12 +++++----- 5 files changed, 19 insertions(+), 38 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index b5c88a2d05..3c6d72c494 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -368,10 +368,7 @@ SELECT count(id) AS countNumber FROM scenario_execution_info WHERE trigger_mode = 'SCHEDULE' - AND source_id IN (SELECT id - FROM api_scenario - WHERE project_id = #{projectId} - AND latest = 1) + AND project_id = #{projectId} AND version = #{version} @@ -382,10 +379,7 @@ SELECT count(id) AS countNumber, result AS groupField FROM scenario_execution_info WHERE trigger_mode = 'SCHEDULE' - AND source_id IN (SELECT id - FROM api_scenario - WHERE project_id = #{projectId} - AND latest = 1) + AND project_id = #{projectId} AND version = #{version} diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java index 34f55c7e00..f717df81cb 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionExecResultService.java @@ -303,13 +303,12 @@ public class ApiDefinitionExecResultService { if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) { TestPlanApiCase apiCase = testPlanApiCaseMapper.selectByPrimaryKey(dto.getTestId()); if (apiCase != null) { - TestPlan testPlan = testPlanService.get(apiCase.getTestPlanId()); - if (testPlan != null) { + if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("projectId")) { + String projectId = dto.getExtendedParameters().get("projectId").toString(); ApiDefinition apiDefinition = extApiTestCaseMapper.selectApiBasicInfoByCaseId(apiCase.getId()); String version = apiDefinition == null ? "" : apiDefinition.getVersionId(); - apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), status, triggerMode, testPlan.getProjectId(), ExecutionExecuteTypeEnum.TEST_PLAN.name(), version); + apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), status, triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version); } - apiCase.setStatus(status); apiCase.setUpdateTime(System.currentTimeMillis()); testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase); 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 c98238a9d1..773cce7f95 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 @@ -1768,26 +1768,14 @@ public class ApiScenarioService { public List getApiIdInScenario(String projectId, Map> scenarioUrlMap, List apiList) { List apiIdList = new ArrayList<>(); if (MapUtils.isNotEmpty(scenarioUrlMap) && CollectionUtils.isNotEmpty(apiList)) { - ProjectApplication urlRepeatableConfig = baseProjectApplicationService.getProjectApplication(projectId, ProjectApplicationType.URL_REPEATABLE.name()); - boolean isUrlRepeatable = BooleanUtils.toBoolean(urlRepeatableConfig.getTypeValue()); for (ApiDefinition model : apiList) { if (StringUtils.equalsIgnoreCase(model.getProtocol(), "http")) { Map stepIdAndUrlMap = scenarioUrlMap.get(model.getMethod()); if (stepIdAndUrlMap != null) { - if (isUrlRepeatable) { - String url = stepIdAndUrlMap.get(model.getId()); - if (StringUtils.isNotEmpty(url)) { - boolean urlMatched = MockApiUtils.isUrlMatch(model.getPath(), url); - if (urlMatched) { - apiIdList.add(model.getId()); - } - } - } else { - Collection scenarioUrlList = scenarioUrlMap.get(model.getMethod()).values(); - boolean matchedUrl = MockApiUtils.isUrlInList(model.getPath(), scenarioUrlList); - if (matchedUrl) { - apiIdList.add(model.getId()); - } + Collection scenarioUrlList = scenarioUrlMap.get(model.getMethod()).values(); + boolean matchedUrl = MockApiUtils.isUrlInList(model.getPath(), scenarioUrlList); + if (matchedUrl) { + apiIdList.add(model.getId()); } } } else { @@ -2194,7 +2182,7 @@ public class ApiScenarioService { if (returnMap.containsKey(method)) { returnMap.get(method).put(item.getReferenceId(), item.getUrl()); } else { - Map urlMap = new HashMap() {{ + Map urlMap = new HashMap<>() {{ this.put(item.getReferenceId(), item.getUrl()); }}; returnMap.put(method, urlMap); diff --git a/api-test/frontend/src/business/home/ApiHome.vue b/api-test/frontend/src/business/home/ApiHome.vue index 46976385ea..cacc5530bd 100644 --- a/api-test/frontend/src/business/home/ApiHome.vue +++ b/api-test/frontend/src/business/home/ApiHome.vue @@ -139,15 +139,15 @@ export default { } .api-home-layout :deep(.dashboard-card) { - height: 392px; + height: 408px; } .api-home-layout :deep(.main-info) { - height: 197px; + height: 208px; } .api-home-layout :deep(.main-info-card) { - height: 197px; + height: 208px; width: 100%; color: #646A73; background-color: #FFFFFF; diff --git a/api-test/frontend/src/business/home/components/chart/CountChart.vue b/api-test/frontend/src/business/home/components/chart/CountChart.vue index 5696eb7d9c..8a8de276ef 100644 --- a/api-test/frontend/src/business/home/components/chart/CountChart.vue +++ b/api-test/frontend/src/business/home/components/chart/CountChart.vue @@ -1,9 +1,9 @@