From ca25efde6c94c21c83ed7eb074ae8edf9b18023e Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 14 Jul 2022 17:00:08 +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=E6=8A=A5=E5=91=8A=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=94=A8=E4=BE=8B=E5=A2=9E=E5=8A=A0=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E5=92=8C=E8=B7=B3=E8=BF=87=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1008184 --user=陈建星 测试计划优化 https://www.tapd.cn/55049933/s/1200949 --- .../mapper/ext/ExtTestPlanTestCaseMapper.java | 2 +- .../mapper/ext/ExtTestPlanTestCaseMapper.xml | 14 +- .../controller/ShareController.java | 13 +- .../TestPlanTestCaseController.java | 6 +- .../track/dto/TestPlanSimpleReportDTO.java | 1 - .../track/service/TestPlanReportService.java | 20 ++- .../track/service/TestPlanService.java | 36 +++-- .../service/TestPlanTestCaseService.java | 8 +- .../functional/TestPlanFunctionalExecute.vue | 7 +- .../detail/TestPlanFunctionalReport.vue | 153 +++++++++++++++--- .../report/detail/TestPlanReportContent.vue | 20 ++- .../detail/component/FunctionalCases.vue | 52 +++--- frontend/src/network/test-plan.js | 19 +-- 13 files changed, 231 insertions(+), 120 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java index c0dab12c9d..840a467abe 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.java @@ -57,7 +57,7 @@ public interface ExtTestPlanTestCaseMapper { List selectForPlanReport(String planId); - List getCases(@Param("planId") String planId, @Param("status") String status); + List getCasesByStatusList(@Param("planId") String planId, @Param("statusList") List statusList); List selectPlanIds(); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index d0c1fb68c1..3896c28387 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -485,7 +485,7 @@ on tc.id = tptc.case_id and tc.status != 'Trash' where tptc.plan_id = #{planId}; - select tptc.id, tc.id as caseId, tc.name, tc.priority, tc.num, tc.custom_num, tc.project_id, tc.node_id, tc.tags, tptc.actual_result, tptc.update_time, tptc.create_time, @@ -493,11 +493,15 @@ tptc.plan_id, tptc.executor from test_plan_test_case tptc inner join test_case tc on tptc.case_id = tc.id - - and tptc.status = 'Failure' - + where tptc.plan_id = #{planId} + + and tptc.status in + + #{status} + + and (tc.status != 'Trash' or tc.status is null) - where tptc.plan_id = #{planId} order by tptc.`order` desc + order by tptc.`order` desc update test_plan_test_case diff --git a/backend/src/main/java/io/metersphere/controller/ShareController.java b/backend/src/main/java/io/metersphere/controller/ShareController.java index bb3fa4c0b2..9b0f97e505 100644 --- a/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -93,16 +93,11 @@ public class ShareController { testPlanService.exportPlanReport(planId, lang, response); } - @GetMapping("/test/plan/case/list/failure/{shareId}/{planId}") - public List getFailureCases(@PathVariable String shareId, @PathVariable String planId) { + @PostMapping("/test/plan/case/list/all/{shareId}/{planId}") + public List getAllCases(@PathVariable String shareId, @PathVariable String planId, + @RequestBody(required = false) List statusList) { shareInfoService.validate(shareId, planId); - return testPlanTestCaseService.getFailureCases(planId); - } - - @GetMapping("/test/plan/case/list/all/{shareId}/{planId}") - public List getAllCases(@PathVariable String shareId, @PathVariable String planId) { - shareInfoService.validate(shareId, planId); - return testPlanTestCaseService.getAllCases(planId); + return testPlanTestCaseService.getAllCasesByStatusList(planId, statusList); } @GetMapping("/test/plan/load/case/list/failure/{shareId}/{planId}") diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java index 934902ebf0..c93b27298d 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java @@ -135,9 +135,9 @@ public class TestPlanTestCaseController { return testPlanTestCaseService.deleteTestCase(id); } - @GetMapping("/list/failure/{planId}") - public List getFailureCases(@PathVariable String planId) { - return testPlanTestCaseService.getFailureCases(planId); + @PostMapping("/list/all/{planId}") + public List getFailureCases(@PathVariable String planId, @RequestBody(required = false) List statusList) { + return testPlanTestCaseService.getAllCasesByStatusList(planId, statusList); } @GetMapping("/list/all/{planId}") diff --git a/backend/src/main/java/io/metersphere/track/dto/TestPlanSimpleReportDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestPlanSimpleReportDTO.java index 2fe669223a..1c3357f32b 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestPlanSimpleReportDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestPlanSimpleReportDTO.java @@ -40,7 +40,6 @@ public class TestPlanSimpleReportDTO extends TestPlanReportContent { private TestPlanApiResultReportDTO apiResult; private TestPlanLoadResultReportDTO loadResult; - List functionFailureCases; List functionAllCases; List issueList; List apiFailureCases; diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 2b9c513797..9231626284 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -636,9 +636,6 @@ public class TestPlanReportService { if (reportDTO.getFunctionAllCases() != null) { testPlanReportContentWithBLOBs.setFunctionAllCases(JSONObject.toJSONString(reportDTO.getFunctionAllCases())); } - if (reportDTO.getFunctionFailureCases() != null) { - testPlanReportContentWithBLOBs.setFunctionFailureCases(JSONObject.toJSONString(reportDTO.getFunctionFailureCases())); - } if (reportDTO.getIssueList() != null) { testPlanReportContentWithBLOBs.setIssueList(JSONObject.toJSONString(reportDTO.getIssueList())); } @@ -699,7 +696,7 @@ public class TestPlanReportService { if (reportDTO != null) { status = TestPlanReportStatus.SUCCESS.name(); try { - if (CollectionUtils.isNotEmpty(reportDTO.getFunctionFailureCases()) + if (hasFunctionFailedCases(reportDTO.getFunctionAllCases()) || CollectionUtils.isNotEmpty(reportDTO.getApiFailureCases()) || CollectionUtils.isNotEmpty(reportDTO.getScenarioFailureCases()) || CollectionUtils.isNotEmpty(reportDTO.getLoadFailureCases())) { @@ -717,6 +714,18 @@ public class TestPlanReportService { return status; } + private boolean hasFunctionFailedCases(List functionAllCases) { + if (functionAllCases == null) { + return false; + } + for (TestPlanCaseDTO functionAllCase : functionAllCases) { + if (StringUtils.equals(functionAllCase.getStatus(), TestPlanTestCaseStatus.Failure.name())) { + return true; + } + } + return false; + } + public TestPlanReport getTestPlanReport(String planId) { return testPlanReportMapper.selectByPrimaryKey(planId); } @@ -897,9 +906,6 @@ public class TestPlanReportService { if (StringUtils.isNotBlank(testPlanReportContent.getFunctionAllCases())) { testPlanReportDTO.setFunctionAllCases(JSONObject.parseArray(testPlanReportContent.getFunctionAllCases(), TestPlanCaseDTO.class)); } - if (StringUtils.isNotBlank(testPlanReportContent.getFunctionFailureCases())) { - testPlanReportDTO.setFunctionFailureCases(JSONObject.parseArray(testPlanReportContent.getFunctionFailureCases(), TestPlanCaseDTO.class)); - } if (StringUtils.isNotBlank(testPlanReportContent.getIssueList())) { testPlanReportDTO.setIssueList(JSONObject.parseArray(testPlanReportContent.getIssueList(), IssuesDao.class)); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 348471e898..cab4b91b68 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1316,22 +1316,17 @@ public class TestPlanService { public void buildFunctionalReport(TestPlanSimpleReportDTO report, JSONObject config, String planId) { if (checkReportConfig(config, "functional")) { List allCases = null; + List statusList = getFunctionalReportStatusList(config); + if (statusList != null) { + allCases = testPlanTestCaseService.getAllCasesByStatusList(planId, statusList); + report.setFunctionAllCases(allCases); + } + if (checkReportConfig(config, "functional", "all")) { allCases = testPlanTestCaseService.getAllCases(planId); report.setFunctionAllCases(allCases); } - if (checkReportConfig(config, "functional", "failure")) { - List failureCases = null; - if (!CollectionUtils.isEmpty(allCases)) { - failureCases = allCases.stream() - .filter(i -> StringUtils.isNotBlank(i.getStatus()) - && i.getStatus().equals("Failure")) - .collect(Collectors.toList()); - } else { - failureCases = testPlanTestCaseService.getFailureCases(planId); - } - report.setFunctionFailureCases(failureCases); - } + if (checkReportConfig(config, "functional", "issue")) { List issueList = issuesService.getIssuesByPlanId(planId); report.setIssueList(issueList); @@ -1339,6 +1334,23 @@ public class TestPlanService { } } + public List getFunctionalReportStatusList(JSONObject config) { + List statusList = new ArrayList<>(); + if (checkReportConfig(config, "functional", "all")) { + return statusList; + } + if (checkReportConfig(config, "functional", "failure")) { + statusList.add(TestPlanTestCaseStatus.Failure.name()); + } + if (checkReportConfig(config, "functional", "blocking")) { + statusList.add(TestPlanTestCaseStatus.Blocking.name()); + } + if (checkReportConfig(config, "functional", "skip")) { + statusList.add(TestPlanTestCaseStatus.Skip.name()); + } + return statusList.size() > 0 ? statusList : null; + } + public void buildApiReport(TestPlanSimpleReportDTO report, JSONObject config, String planId, boolean saveResponse) { if (checkReportConfig(config, "api")) { List apiAllCases = null; diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java index 466dfe7979..d5c6910fb9 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -480,14 +480,12 @@ public class TestPlanTestCaseService { functionResult.setCaseData(statusResult); } - public List getFailureCases(String planId) { - List allCases = extTestPlanTestCaseMapper.getCases(planId, "Failure"); - return buildCaseInfo(allCases); + public List getAllCasesByStatusList(String planId, List statusList) { + return buildCaseInfo(extTestPlanTestCaseMapper.getCasesByStatusList(planId, statusList)); } public List getAllCases(String planId) { - List allCases = extTestPlanTestCaseMapper.getCases(planId, null); - return buildCaseInfo(allCases); + return buildCaseInfo(this.getAllCasesByStatusList(planId, null)); } public List buildCaseInfo(List cases) { diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctionalExecute.vue b/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctionalExecute.vue index 578cf5ecdb..bf986e7cfa 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctionalExecute.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctionalExecute.vue @@ -41,12 +41,7 @@ export default { this.testCase.status = status; }, saveCase() { - // 从其他状态改成失败才需要写评论 - if (this.testCase.status === 'Failure' && this.originStatus !== 'Failure' && !this.testCase.comment) { - this.$refs.comment.inputLight(); - } else { - this.$emit('saveCase'); - } + this.$emit('saveCase'); } } } diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanFunctionalReport.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanFunctionalReport.vue index 265f51bb29..485f9eca94 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanFunctionalReport.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanFunctionalReport.vue @@ -4,23 +4,77 @@ - - - - - + - + - + - + + + + + + + + + + + + + @@ -37,6 +91,10 @@ import TestPlanReportContainer from "@/business/components/track/plan/view/comonents/report/detail/TestPlanReportContainer"; import TabPaneCount from "@/business/components/track/plan/view/comonents/report/detail/component/TabPaneCount"; import {hasPermission} from "@/common/js/utils"; +import { + getPlanFunctionAllCase, + getSharePlanFunctionAllCase, +} from "@/network/test-plan"; export default { name: "TestPlanFunctionalReport", components: { @@ -47,7 +105,10 @@ export default { activeName: 'first', failureSize: 0, issueSize: 0, + skipSize: 0, + blockingSize: 0, allSize: 0, + allTestCase: [] }; }, props: [ @@ -58,10 +119,6 @@ export default { let disable = this.report.config && this.report.config.functional.children.result.enable === false; return !disable; }, - failureEnable() { - let disable = this.report.config && this.report.config.functional.children.failure.enable === false; - return !disable; - }, issueEnable() { let disable = this.report.config && this.report.config.functional.children.issue.enable === false; return !disable; @@ -70,9 +127,22 @@ export default { let disable = this.report.config && this.report.config.functional.children.all.enable === false; return !disable; }, + failureEnable() { + let disable = this.report.config && this.report.config.functional.children.failure.enable === false; + return !disable; + }, + blockingEnable() { + let disable = this.report.config && this.report.config.functional.children.blocking.enable === false; + return !disable; + }, + skipEnable() { + let disable = this.report.config && this.report.config.functional.children.skip.enable === false; + return !disable; + }, }, mounted() { this.initActiveName(); + this.getAllFunctionalTestCase(); }, watch: { resultEnable() { @@ -87,22 +157,35 @@ export default { allEnable() { this.initActiveName(); }, + 'report.config'() { + this.getAllFunctionalTestCase(); + } }, methods: { initActiveName() { if (this.resultEnable) { this.activeName = 'first'; - } else if (this.failureEnable) { + }else if (this.issueEnable) { this.activeName = 'second'; - } else if (this.issueEnable) { - this.activeName = 'third'; } else if (this.allEnable) { + this.activeName = 'third'; + } else if (this.failureEnable) { this.activeName = 'fourth'; + } else if (this.blockingEnable) { + this.activeName = 'fifth'; + } else if (this.skipEnable) { + this.activeName = 'sixth'; } }, setFailureSize(size) { this.failureSize = size; }, + setBlockingSize(size) { + this.blockingSize = size; + }, + setSkipSize(size) { + this.skipSize = size; + }, setIssueSize(size) { this.issueSize = size; }, @@ -112,8 +195,42 @@ export default { handleClick(tab, event) { }, hasPermission, + getAllFunctionalTestCase() { + if (this.isTemplate || this.isDb) { + this.allTestCase = this.report.functionAllCases ? this.report.functionAllCases : []; + } else if (this.isShare) { + let param = this.getStatusList(); + if (param) { + getSharePlanFunctionAllCase(this.shareId, this.planId, param, (data) => { + this.allTestCase = data; + }); + } + } else { + let param = this.getStatusList(); + if (param) { + getPlanFunctionAllCase(this.planId, param, (data) => { + this.allTestCase = data; + }); + } + } + }, + getStatusList() { + let statusList = []; + if (this.allEnable) { + return statusList; + } + if (this.failureEnable) { + statusList.push('Failure'); + } + if (this.blockingEnable) { + statusList.push('Blocking'); + } + if (this.skipEnable) { + statusList.push('Skip'); + } + return statusList.length > 0 ? statusList : null; + } } - } diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue index 8cd20535bd..3b0fa5026b 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanReportContent.vue @@ -87,7 +87,7 @@ export default { if (this.planReportTemplate) { this.init(); } - } + }, }, created() { this.getReport(); @@ -181,10 +181,6 @@ export default { enable: true, name: this.$t('test_track.report.test_result'), }, - failure: { - enable: true, - name: this.$t('test_track.report.fail_case'), - }, issue: { enable: true, name: this.$t('test_track.report.issue_list'), @@ -192,7 +188,19 @@ export default { all: { enable: true, name: this.$t('test_track.report.all_case'), - } + }, + failure: { + enable: true, + name: this.$t('test_track.report.fail_case'), + }, + blocking: { + enable: true, + name: this.$t('test_track.plan_view.blocking') + this.$t('commons.track'), + }, + skip: { + enable: true, + name: this.$t('test_track.plan_view.skip') + this.$t('commons.track'), + }, } }, api: { diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/component/FunctionalCases.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/component/FunctionalCases.vue index 8f3ff1cd65..c761fd75ad 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/component/FunctionalCases.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/component/FunctionalCases.vue @@ -25,12 +25,6 @@ - - - - - - { - this.testCases = data; - }); - } else { - getSharePlanFunctionFailureCase(this.shareId, this.planId, (data) => { - this.testCases = data; - }); - } + this.testCases = []; + if (this.filterStatus) { + this.allTestCase.forEach(item => { + if (item.status === this.filterStatus) { + this.testCases.push(item); + } + }); } else { - if (this.isAll) { - getPlanFunctionAllCase(this.planId, (data) => { - this.testCases = data; - }); - } else { - getPlanFunctionFailureCase(this.planId, (data) => { - this.testCases = data; - }); - } + this.testCases = this.allTestCase; } } } diff --git a/frontend/src/network/test-plan.js b/frontend/src/network/test-plan.js index ca029d04f7..01a0de495e 100644 --- a/frontend/src/network/test-plan.js +++ b/frontend/src/network/test-plan.js @@ -2,7 +2,7 @@ import {post, get} from "@/common/js/ajax"; import {success} from "@/common/js/message"; import i18n from "@/i18n/i18n"; import {baseGet, basePost} from "@/network/base-network"; -import {getCurrentProjectID, getCurrentWorkspaceId} from "@/common/js/utils"; +import {getCurrentProjectID} from "@/common/js/utils"; export function getTestPlanReport(planId, callback) { if (planId) { @@ -55,21 +55,12 @@ export function getShareTestPlanReportContent(shareId, reportId, callback) { return reportId ? baseGet('/share/test/plan/report/db/' + shareId + '/' + reportId, callback) : {}; } -export function getPlanFunctionFailureCase(planId, callback) { - return planId ? baseGet('/test/plan/case/list/failure/' + planId, callback) : {}; +export function getPlanFunctionAllCase(planId, param, callback) { + return planId ? basePost('/test/plan/case/list/all/' + planId, param, callback) : {}; } -export function getPlanFunctionAllCase(planId, callback) { - return planId ? baseGet('/test/plan/case/list/all/' + planId, callback) : {}; -} - - -export function getSharePlanFunctionFailureCase(shareId, planId, callback) { - return planId ? baseGet('/share/test/plan/case/list/failure/' + shareId + '/' + planId, callback) : {}; -} - -export function getSharePlanFunctionAllCase(shareId, planId, callback) { - return planId ? baseGet('/share/test/plan/case/list/all/' + shareId + '/' + planId, callback) : {}; +export function getSharePlanFunctionAllCase(shareId, planId, param, callback) { + return planId ? basePost('/share/test/plan/case/list/all/' + shareId + '/' + planId, param, callback) : {}; } export function getPlanScenarioFailureCase(planId, callback) {