From 8eb82df44d50c853e538cf9881115912a25baee5 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 29 Jun 2023 14:57:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E7=8A=B6=E6=80=81=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1027232 --user=王旭 【测试跟踪】github#24999,功能用例的变更记录不可读,内容展示错乱 https://www.tapd.cn/55049933/s/1387651 --- .../java/io/metersphere/log/vo/StatusReference.java | 3 +++ .../metersphere/controller/TestCaseController.java | 1 - .../controller/TestPlanTestCaseController.java | 2 +- .../plan/service/TestPlanTestCaseService.java | 13 ++++++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/vo/StatusReference.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/vo/StatusReference.java index 487febad81..a001eb5e86 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/vo/StatusReference.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/log/vo/StatusReference.java @@ -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", "跳过"); } } diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java index 6e5f09e151..93abd99a68 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestCaseController.java @@ -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 files) { return testCaseService.editTestCase(request, files); diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java index ea879e197c..5855516d25 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java @@ -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); } diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java index f9c655ac53..fc4a372f85 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanTestCaseService.java @@ -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 columns = new LinkedList<>(); + DetailColumn executeStatusColumn = new DetailColumn("状态", "lastExecuteResult", StatusReference.statusMap.get(testCase.getLastExecuteResult()), null); + columns.add(executeStatusColumn); + // 增加评论内容 + List dtos = testCaseCommentService.getCaseComments(planTestCaseWithBLOBs.getCaseId()); + if (CollectionUtils.isNotEmpty(dtos)) { + List 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;