fix(测试跟踪): 测试计划修改用例状态日志记录错误处理

--bug=1027232 --user=王旭 【测试跟踪】github#24999,功能用例的变更记录不可读,内容展示错乱 https://www.tapd.cn/55049933/s/1387651
This commit is contained in:
WangXu10 2023-06-29 14:57:22 +08:00 committed by fit2-zhao
parent 65e1f9b8af
commit 8eb82df44d
4 changed files with 16 additions and 3 deletions

View File

@ -80,6 +80,9 @@ public class StatusReference {
statusMap.put("TRACK_TEST_CASE_TASK", "测试跟踪用例任务");
statusMap.put("TRACK_HOME_TASK", "测试跟踪主页任务");
statusMap.put("TRACK_REPORT_TASK", "测试跟踪报告任务");
statusMap.put("Failure", "失败");
statusMap.put("Blocking", "阻塞");
statusMap.put("Skip", "跳过");
}
}

View File

@ -252,7 +252,6 @@ public class TestCaseController {
}
@PostMapping(value = "/edit/testPlan", consumes = {"multipart/form-data"})
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogBeforeDetails(#request.id)", title = "#request.name", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseService.class)
@RequiresPermissions(value = {PermissionConstants.PROJECT_TRACK_CASE_READ_EDIT, PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN}, logical = Logical.OR)
public String editTestCaseByTestPlan(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
return testCaseService.editTestCase(request, files);

View File

@ -123,7 +123,7 @@ public class TestPlanTestCaseController {
@PostMapping("/edit")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_PLAN_READ_RUN)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanTestCase.id)", msClass = TestPlanTestCaseService.class)
@MsAuditLog(module = OperLogModule.TRACK_TEST_CASE_REVIEW, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanTestCase.id)", content = "#msClass.getLogDetails(#testPlanTestCase.id)", msClass = TestPlanTestCaseService.class)
public void editTestCase(@RequestBody TestPlanFuncCaseEditRequest testPlanTestCase) {
testPlanTestCaseService.editTestCase(testPlanTestCase);
}

View File

@ -18,6 +18,7 @@ import io.metersphere.dto.*;
import io.metersphere.excel.constants.TestPlanTestCaseStatus;
import io.metersphere.log.vo.DetailColumn;
import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.log.vo.StatusReference;
import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import io.metersphere.plan.dto.TestPlanReportDataStruct;
import io.metersphere.plan.request.function.*;
@ -481,7 +482,17 @@ public class TestPlanTestCaseService {
if (planTestCaseWithBLOBs != null) {
TestCase testCase = testCaseMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getCaseId());
TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getPlanId());
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testCase.getProjectId(), testCase.getName(), planTestCaseWithBLOBs.getCreateUser(), new LinkedList<>());
List<DetailColumn> columns = new LinkedList<>();
DetailColumn executeStatusColumn = new DetailColumn("状态", "lastExecuteResult", StatusReference.statusMap.get(testCase.getLastExecuteResult()), null);
columns.add(executeStatusColumn);
// 增加评论内容
List<TestCaseCommentDTO> dtos = testCaseCommentService.getCaseComments(planTestCaseWithBLOBs.getCaseId());
if (CollectionUtils.isNotEmpty(dtos)) {
List<String> names = dtos.stream().map(TestCaseCommentDTO::getDescription).collect(Collectors.toList());
DetailColumn detailColumn = new DetailColumn("评论", "comment", String.join(StringUtils.LF, names), null);
columns.add(detailColumn);
}
OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(testCase.getId()), testCase.getProjectId(), testCase.getName(), planTestCaseWithBLOBs.getCreateUser(), columns);
return JSON.toJSONString(details);
}
return null;