fix(测试计划): 修复测试计划统计时没有过滤掉回收站里用例的缺陷

--bug=1041265 --user=宋天阳 【测试计划】计划内用例全部执行完成-计划状态为进行中 https://www.tapd.cn/55049933/s/1521607
This commit is contained in:
Jianguo-Genius 2024-05-27 17:30:26 +08:00 committed by Craftsman
parent c951ecc9fb
commit 5f4cbe3b36
6 changed files with 12 additions and 53 deletions

View File

@ -184,14 +184,6 @@ public class TestPlanFunctionalCaseController {
return testPlanFunctionalCaseService.getCaseExecHistory(request);
}
@PostMapping("/edit")
@Operation(summary = "测试计划-计划详情-功能用例-编辑执行结果")
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_EXECUTE)
@CheckOwner(resourceId = "#request.getTestPlanId()", resourceType = "test_plan")
public void editFunctionalCase(@Validated @RequestBody TestPlanCaseEditRequest request) {
testPlanFunctionalCaseService.editFunctionalCase(request, SessionUtils.getUserId());
}
@GetMapping("/user-option/{projectId}")
@Operation(summary = "测试计划-计划详情-功能用例-获取用户列表")
@RequiresPermissions(value = {PermissionConstants.TEST_PLAN_READ, PermissionConstants.TEST_PLAN_READ_UPDATE, PermissionConstants.TEST_PLAN_READ_ADD}, logical = Logical.OR)

View File

@ -70,9 +70,11 @@
LIMIT 1
</select>
<select id="selectCaseExecResultCount" resultType="io.metersphere.plan.dto.TestPlanCaseRunResultCount">
select last_exec_result as result, count(id) as resultCount
select test_plan_api_case.last_exec_result as result, count(test_plan_api_case.id) as resultCount
from test_plan_api_case
inner join api_test_case on test_plan_api_case.api_case_id = api_test_case.id
where test_plan_id = #{0}
group by last_exec_result;
and api_test_case.deleted = false
group by last_exec_result
</select>
</mapper>

View File

@ -68,9 +68,11 @@
LIMIT 1
</select>
<select id="selectCaseExecResultCount" resultType="io.metersphere.plan.dto.TestPlanCaseRunResultCount">
select last_exec_result as result, count(id) as resultCount
select test_plan_api_scenario.last_exec_result as result, count(test_plan_api_scenario.id) as resultCount
from test_plan_api_scenario
inner join api_scenario on test_plan_api_scenario.api_scenario_id = api_scenario.id
where test_plan_id = #{0}
group by last_exec_result;
AND api_scenario.deleted = false
group by last_exec_result
</select>
</mapper>

View File

@ -490,10 +490,12 @@
</where>
</select>
<select id="selectCaseExecResultCount" resultType="io.metersphere.plan.dto.TestPlanCaseRunResultCount">
select last_exec_result as result, count(id) as resultCount
select test_plan_functional_case.last_exec_result as result, count(test_plan_functional_case.id) as resultCount
from test_plan_functional_case
INNER JOIN functional_case ON test_plan_functional_case.functional_case_id = functional_case.id
where test_plan_id = #{0}
group by last_exec_result;
AND functional_case.deleted = false
group by last_exec_result
</select>

View File

@ -600,33 +600,6 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
}
}
public void editFunctionalCase(TestPlanCaseEditRequest request, String userId) {
TestPlanFunctionalCase planFunctionalCase = testPlanFunctionalCaseMapper.selectByPrimaryKey(request.getId());
TestPlanFunctionalCase functionalCase = new TestPlanFunctionalCase();
functionalCase.setId(request.getId());
functionalCase.setLastExecResult(request.getLastExecResult());
functionalCase.setLastExecTime(System.currentTimeMillis());
testPlanFunctionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
updateFunctionalCaseStatus(Arrays.asList(planFunctionalCase.getFunctionalCaseId()), request.getLastExecResult());
//执行历史
TestPlanCaseExecuteHistory executeHistory = new TestPlanCaseExecuteHistory();
executeHistory.setId(IDGenerator.nextStr());
executeHistory.setTestPlanCaseId(planFunctionalCase.getId());
executeHistory.setTestPlanId(planFunctionalCase.getTestPlanId());
executeHistory.setCaseId(planFunctionalCase.getFunctionalCaseId());
executeHistory.setStatus(request.getLastExecResult());
executeHistory.setDeleted(false);
executeHistory.setCreateUser(userId);
executeHistory.setCreateTime(System.currentTimeMillis());
testPlanCaseExecuteHistoryMapper.insert(executeHistory);
//通知
handleFileAndNotice(planFunctionalCase.getFunctionalCaseId(), null, null, userId, null, null, request.getTestPlanId(), request.getLastExecResult());
}
/**
* 获取项目下的所有用户
*

View File

@ -57,7 +57,6 @@ public class TestPlanCaseControllerTests extends BaseTest {
public static final String FUNCTIONAL_CASE_EXEC_HISTORY_URL = "/test-plan/functional/case/exec/history";
public static final String FUNCTIONAL_CASE_EDIT_URL = "/test-plan/functional/case/edit";
public static final String USER_URL = "/test-plan/functional/case/user-option/";
@Resource
private TestPlanFunctionalCaseMapper testPlanFunctionalCaseMapper;
@ -259,17 +258,6 @@ public class TestPlanCaseControllerTests extends BaseTest {
this.requestPostWithOk(FUNCTIONAL_CASE_EXEC_HISTORY_URL, request);
}
@Test
@Order(15)
public void testFunctionalCaseEdit() throws Exception {
TestPlanCaseEditRequest request = new TestPlanCaseEditRequest();
request.setId("relate_case_1");
request.setTestPlanId("plan_1");
request.setLastExecResult("SUCCESS");
this.requestPostWithOk(FUNCTIONAL_CASE_EDIT_URL, request);
}
@Test
@Order(16)
public void testGetDetail() throws Exception {