From c0246bda2818ad794eeeb13afdc6eccac04c736d Mon Sep 17 00:00:00 2001 From: Whisperity Date: Wed, 27 Mar 2024 09:56:21 +0100 Subject: [PATCH] test(gui): Add front-end test for checked status in AnalysisInfo dialog --- web/server/vue-cli/e2e/pages/runs.js | 10 ++- web/server/vue-cli/e2e/specs/runs.js | 90 +++++++++++++++++-- .../src/components/AnalysisInfo/Checker.vue | 2 + .../components/AnalysisInfo/CheckerGroup.vue | 7 +- .../src/components/AnalysisInfoDialog.vue | 52 ++++++----- .../{ => api}/analysis-info-handling.mixin.js | 10 ++- web/server/vue-cli/src/mixins/api/index.js | 5 ++ web/server/vue-cli/src/mixins/index.js | 4 +- 8 files changed, 135 insertions(+), 45 deletions(-) rename web/server/vue-cli/src/mixins/{ => api}/analysis-info-handling.mixin.js (96%) create mode 100644 web/server/vue-cli/src/mixins/api/index.js diff --git a/web/server/vue-cli/e2e/pages/runs.js b/web/server/vue-cli/e2e/pages/runs.js index c3dd7b7588..7d9c38a86c 100644 --- a/web/server/vue-cli/e2e/pages/runs.js +++ b/web/server/vue-cli/e2e/pages/runs.js @@ -34,7 +34,7 @@ module.exports = { showDescriptionBtn: "button.description", showHistoryBtn: "a.show-history", showStatisticsBtn: "a.show-statistics", - showCheckCommandBtn: "button.show-analysis-info", + showAnalysisInfoBtn: "button.show-analysis-info", openDetectionStatus: "a.detection-status-count", descriptionMenu: ".menuable__content__active.run-description-menu .v-card__text", @@ -61,10 +61,12 @@ module.exports = { storedBefore: ".stored-before", } }, - checkCommandDialog: { + analysisInfoDialog: { selector: ".v-dialog__content--active .analysis-info", elements: { - content: ".container", + command: ".analyze-command", + checkerStatuses: ".checker-statuses", + checkerStatusError: ".checker-status-unavailable", closeBtn: ".v-card__title button" } }, @@ -89,7 +91,7 @@ module.exports = { elements: { date: ".date", showStatisticsBtn: "a.show-statistics", - showCheckCommandBtn: "button.show-analysis-info", + showAnalysisInfoBtn: "button.show-analysis-info", historyEvent: ".v-timeline-item.run-history", baseline: ".compare-events .v-input--checkbox:nth-child(1)", compareTo: ".compare-events .v-input--checkbox:nth-child(2)" diff --git a/web/server/vue-cli/e2e/specs/runs.js b/web/server/vue-cli/e2e/specs/runs.js index 715894e3d4..e07ec2a11f 100644 --- a/web/server/vue-cli/e2e/specs/runs.js +++ b/web/server/vue-cli/e2e/specs/runs.js @@ -79,19 +79,86 @@ module.exports = { .waitForElementNotPresent("@descriptionMenu"); }, - "show check command of a run" (browser) { + async "show check command of a run" (browser) { const checkCommand = "cli.py analyze"; const runsPage = browser.page.runs(); - const dialogSection = runsPage.section.checkCommandDialog; + const dialogSection = runsPage.section.analysisInfoDialog; - runsPage.click("@showCheckCommandBtn"); + runsPage.click("@showAnalysisInfoBtn"); runsPage.expect.section(dialogSection) .to.be.visible.before(5000); - dialogSection.assert.containsText("@content", checkCommand); + dialogSection.assert.containsText("@command", checkCommand); - // Close check command dialog. + dialogSection.expect.element("@checkerStatuses") + .to.be.present.before(5000); + dialogSection.expect.element("@checkerStatusError") + .to.not.be.present.before(5000); + + dialogSection.pause(1000); + await (async () => { + const analyzerPanelBtnSelector = ".analysis-info " + + ".analyzer-checkers-panel" + + ".v-expansion-panel" + + ":not(.v-expansion-panel--active) " + + "button"; + + dialogSection.expect.element(analyzerPanelBtnSelector) + .to.be.present.before(5000); + + const analyzerPanelBtns = await runsPage.api.findElements( + analyzerPanelBtnSelector); + analyzerPanelBtns.value.forEach(async btnId => + await runsPage.api.elementIdClick(btnId.getId())); + + dialogSection.expect.element(analyzerPanelBtnSelector) + .to.not.be.present.before(5000); + })(); + await (async () => { + const checkerGroupPanelBtnSelector = ".analysis-info " + + ".analyzer-checker-group-panel" + + ".v-expansion-panel" + + ":not(.v-expansion-panel--active) " + + "button"; + + dialogSection.expect.element(checkerGroupPanelBtnSelector) + .to.be.present.before(5000); + + const checkerGroupPanelBtns = await runsPage.api.findElements( + checkerGroupPanelBtnSelector); + checkerGroupPanelBtns.value.forEach(async btnId => + await runsPage.api.elementIdClick(btnId.getId())); + + dialogSection.expect.element(checkerGroupPanelBtnSelector) + .to.not.be.present.before(5000); + })(); + dialogSection.pause(1000); + + const assertCheckerStatus = (analyzer, group, checker, enabled) => { + const checkerSelector = ".analysis-info " + + ".analyzer-checkers-panel[data-analyzer-name='" + analyzer + "'] " + + (group === "" ? "" : + ".analyzer-checker-group-panel[data-group-name='" + group +"'] ") + + ".analysis-info-checker[data-checker-name='" + checker + "'] " + + ".checker-" + (enabled ? "enabled" : "disabled"); + + dialogSection.expect.element(checkerSelector).to.be.present.before(1000); + dialogSection.expect.element(checkerSelector).text.to.equal(checker); + }; + const assertChecker = (analyzer, group, checker) => + assertCheckerStatus(analyzer, group, checker, true); + const assertNotChecker = (analyzer, group, checker) => + assertCheckerStatus(analyzer, group, checker, false); + + assertChecker("clangsa", "core", "core.DivideZero"); + assertChecker("clangsa", "cplusplus", "cplusplus.NewDelete"); + assertNotChecker("clangsa", "osx", "osx.cocoa.Loops"); + + assertChecker("clang-tidy", "clang-diagnostic", "clang-diagnostic-switch"); + assertNotChecker("clang-tidy", "llvm", "llvm-header-guard"); + + // Close analysis info dialog. dialogSection.pause(100).click("@closeBtn"); runsPage.expect.section(dialogSection) @@ -277,16 +344,21 @@ module.exports = { const runsPage = browser.page.runs(); const expandedSection = runsPage.section.expanded; const timelineSection = expandedSection.section.timeline; - const dialogSection = runsPage.section.checkCommandDialog; + const dialogSection = runsPage.section.analysisInfoDialog; - timelineSection.click("@showCheckCommandBtn"); + timelineSection.click("@showAnalysisInfoBtn"); runsPage.expect.section(dialogSection) .to.be.visible.before(5000); - dialogSection.assert.containsText("@content", checkCommand); + dialogSection.assert.containsText("@command", checkCommand); + + dialogSection.expect.element("@checkerStatuses") + .to.be.present.before(5000); + dialogSection.expect.element("@checkerStatusError") + .to.not.be.present.before(5000); - // Close check command dialog. + // Close analysis info dialog. dialogSection.click("@closeBtn"); runsPage.expect.section(dialogSection) diff --git a/web/server/vue-cli/src/components/AnalysisInfo/Checker.vue b/web/server/vue-cli/src/components/AnalysisInfo/Checker.vue index 0d356a0f27..9dff93c7fc 100644 --- a/web/server/vue-cli/src/components/AnalysisInfo/Checker.vue +++ b/web/server/vue-cli/src/components/AnalysisInfo/Checker.vue @@ -2,6 +2,8 @@ - + @@ -76,7 +79,7 @@