diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
index 92d7c79ebf..007c129b2f 100644
--- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
+++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml
@@ -681,7 +681,7 @@
and test_case.project_id = #{request.projectId}
-
+
and test_case.id not in (
SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
api_test_case WHERE `STATUS` is null or status != 'Trash')
@@ -691,9 +691,24 @@
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
api_scenario WHERE `STATUS` != 'Trash')
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'uiAutomation' and test_id IN (select id FROM
+ ui_scenario WHERE `STATUS` != 'Trash')
+ )
+
+
+ and test_case.id in (
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
+ api_test_case WHERE `STATUS` is null or status != 'Trash')
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from
+ load_test)
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
+ api_scenario WHERE `STATUS` != 'Trash')
)
-
+
and test_case.id in (
SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
api_test_case WHERE `STATUS` is null or status != 'Trash')
@@ -703,6 +718,9 @@
UNION
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
api_scenario WHERE `STATUS` != 'Trash')
+ UNION
+ SELECT test_case_id FROM test_case_test WHERE test_type = 'uiAutomation' and test_id IN (select id FROM
+ ui_scenario WHERE `STATUS` != 'Trash')
)
@@ -863,13 +881,11 @@
FROM test_case_test
WHERE test_type = 'automation'
and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash')
-
UNION
SELECT test_case_id, test_id, test_type
FROM test_case_test
WHERE test_type = 'uiAutomation'
and test_id IN (select id FROM ui_scenario WHERE `STATUS` != 'Trash')
-
)
test_case_test
ON test_case.id = test_case_test.test_case_id
diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java b/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java
index 199a59bfb4..004586f4e5 100644
--- a/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java
+++ b/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java
@@ -9,10 +9,12 @@ import io.metersphere.commons.utils.Pager;
import io.metersphere.dto.*;
import io.metersphere.i18n.Translator;
import io.metersphere.plan.dto.ChartsData;
+import io.metersphere.request.testcase.TrackCount;
import io.metersphere.service.TestCaseService;
import io.metersphere.service.TrackService;
import io.metersphere.utils.DiscoveryUtil;
import jakarta.annotation.Resource;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -105,7 +107,15 @@ public class TrackController {
boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST);
List relevanceResults = trackService.countRelevance(projectId, queryUi);
- statistics.countRelevance(relevanceResults);
+ long uiCountNum = 0L;
+ if (!queryUi) {
+ List uiGroup =
+ relevanceResults.stream().filter(relevanceResult -> StringUtils.equals(relevanceResult.getGroupField(), TrackCount.UI_AUTOMATION)).toList();
+ if (CollectionUtils.isNotEmpty(uiGroup)) {
+ uiCountNum = uiGroup.get(0).getCountNumber();
+ }
+ }
+ statistics.countRelevance(relevanceResults, queryUi);
long size = trackService.countRelevanceCreatedThisWeek(projectId);
statistics.setThisWeekAddedCount(size);
@@ -114,7 +124,7 @@ public class TrackController {
long total = list.size();
int coverage = trackService.countCoverage(projectId, queryUi);
statistics.setCoverageCount(coverage);
- statistics.setUncoverageCount(total - coverage);
+ statistics.setUncoverageCount(total - coverage - uiCountNum);
if (total != 0) {
float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total;
diff --git a/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java b/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java
index 29d5869841..296b43e578 100644
--- a/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java
+++ b/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java
@@ -163,7 +163,7 @@ public class TrackStatisticsDTO {
}
}
- public void countRelevance(List relevanceResults) {
+ public void countRelevance(List relevanceResults, boolean queryUI) {
Map chartData = new HashMap<>();
for (TrackCountResult countResult : relevanceResults) {
if (StringUtils.equalsIgnoreCase(TrackCount.TESTCASE, countResult.getGroupField())) {
@@ -193,13 +193,15 @@ public class TrackStatisticsDTO {
chartData.put(Translator.get("scenario_case"), count);
}
}
- if (StringUtils.equalsIgnoreCase(TrackCount.UI_AUTOMATION, countResult.getGroupField())) {
- Integer count = chartData.get(Translator.get("ui_scenario_case"));
- if (count == null) {
- chartData.put(Translator.get("ui_scenario_case"), (int) countResult.getCountNumber());
- } else {
- count += (int) countResult.getCountNumber();
- chartData.put(Translator.get("ui_scenario_case"), count);
+ if (queryUI) {
+ if (StringUtils.equalsIgnoreCase(TrackCount.UI_AUTOMATION, countResult.getGroupField())) {
+ Integer count = chartData.get(Translator.get("ui_scenario_case"));
+ if (count == null) {
+ chartData.put(Translator.get("ui_scenario_case"), (int) countResult.getCountNumber());
+ } else {
+ count += (int) countResult.getCountNumber();
+ chartData.put(Translator.get("ui_scenario_case"), count);
+ }
}
}
this.allRelevanceCaseCount += countResult.getCountNumber();
@@ -210,6 +212,9 @@ public class TrackStatisticsDTO {
chartData.put(Translator.get("api_case"), 0);
chartData.put(Translator.get("performance_case"), 0);
chartData.put(Translator.get("scenario_case"), 0);
+ if (queryUI) {
+ chartData.put(Translator.get("ui_scenario_case"), 0);
+ }
}
this.chartData = chartData;
}
diff --git a/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java b/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java
index 66cd3acfde..eac4f6e564 100644
--- a/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java
+++ b/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java
@@ -63,4 +63,9 @@ public class QueryTestCaseRequest extends BaseQueryRequest {
private Boolean toBeUpdated;
private String apiCoverage;
private String scenarioCoverage;
+
+ /**
+ * 是否查询UI
+ */
+ private boolean queryUi;
}
diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java
index 8535a83bce..be12fc4adf 100644
--- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java
+++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java
@@ -792,6 +792,8 @@ public class TestCaseService {
}
public List listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) {
+ boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST);
+ request.setQueryUi(queryUi);
this.initRequest(request, true);
setDefaultOrder(request);
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);