fix(测试跟踪): 测试计划允许重复用例,关联功能用例模块树依然被过滤

--bug=1016596 --user=陈建星 【测试跟踪】github #17675,2.1版本测试计划按模块重复关联测试用例失败 https://www.tapd.cn/55049933/s/1239696
This commit is contained in:
AnAngle 2022-09-06 22:49:47 +08:00 committed by f2c-ci-robot[bot]
parent 563d887ba3
commit 47b133b64d
2 changed files with 13 additions and 2 deletions

View File

@ -323,10 +323,14 @@
<select id="getTestPlanRelateCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO"> <select id="getTestPlanRelateCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">
select tcn.id, count(*) as caseNum, test_case.project_id select tcn.id, count(*) as caseNum, test_case.project_id
from test_case from test_case
<if test="!request.repeatCase">
left join test_plan_test_case tptc on tptc.case_id = test_case.id and tptc.plan_id = #{request.planId} left join test_plan_test_case tptc on tptc.case_id = test_case.id and tptc.plan_id = #{request.planId}
</if>
left join test_case_node tcn on test_case.node_id = tcn.id left join test_case_node tcn on test_case.node_id = tcn.id
<include refid="queryWhereCondition"/> <include refid="queryWhereCondition"/>
<if test="!request.repeatCase">
and tptc.case_id is null and tptc.case_id is null
</if>
group by tcn.id group by tcn.id
</select> </select>
<select id="getTestReviewRelateCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO"> <select id="getTestReviewRelateCountNodes" resultType="io.metersphere.track.dto.TestCaseNodeDTO">

View File

@ -36,6 +36,7 @@ import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils; import org.mybatis.spring.SqlSessionUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -66,6 +67,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
ProjectMapper projectMapper; ProjectMapper projectMapper;
@Resource @Resource
ExtTestReviewCaseMapper extTestReviewCaseMapper; ExtTestReviewCaseMapper extTestReviewCaseMapper;
@Resource
@Lazy
TestPlanService testPlanService;
public TestCaseNodeService() { public TestCaseNodeService() {
super(TestCaseNodeDTO.class); super(TestCaseNodeDTO.class);
@ -353,6 +357,9 @@ public class TestCaseNodeService extends NodeTreeService<TestCaseNodeDTO> {
public List<TestCaseNodeDTO> getRelatePlanNodes(QueryTestCaseRequest request) { public List<TestCaseNodeDTO> getRelatePlanNodes(QueryTestCaseRequest request) {
request.setNodeIds(null); request.setNodeIds(null);
if (testPlanService.isAllowedRepeatCase(request.getPlanId())) {
request.setRepeatCase(true);
}
List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getTestPlanRelateCountNodes(request); List<TestCaseNodeDTO> countMNodes = extTestCaseMapper.getTestPlanRelateCountNodes(request);
List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(request.getProjectId()); List<TestCaseNodeDTO> testCaseNodes = extTestCaseNodeMapper.getNodeTreeByProjectId(request.getProjectId());
return getNodeTreeWithPruningTreeByCaseCount(testCaseNodes, getCountMap(countMNodes)); return getNodeTreeWithPruningTreeByCaseCount(testCaseNodes, getCountMap(countMNodes));