From: Stas Vilchik Date: Mon, 8 Jan 2018 16:52:43 +0000 (+0100) Subject: SONAR-10258 Missing information about uncovered conditions on a line X-Git-Tag: 7.0-RC1~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=24ea33f13a2e47bf20a8ae2c922ce07be2458524;p=sonarqube.git SONAR-10258 Missing information about uncovered conditions on a line --- diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java index fe622da11c5..eab80acfcc2 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java @@ -22,6 +22,8 @@ package org.sonarqube.qa.util.pageobjects; import com.codeborne.selenide.Condition; import com.codeborne.selenide.Selenide; +import static com.codeborne.selenide.Selenide.$; + public class ProjectCodePage { public ProjectCodePage openFirstComponent() { @@ -30,29 +32,33 @@ public class ProjectCodePage { } public ProjectCodePage search(String query) { - Selenide.$(".code-search .search-box-input").val(query); + $(".code-search .search-box-input").val(query); return this; } public ProjectCodePage shouldHaveComponent(String name) { - Selenide.$(".code-components").shouldHave(Condition.text(name)); + $(".code-components").shouldHave(Condition.text(name)); return this; } public ProjectCodePage shouldHaveCode(String code) { - Selenide.$(".code-components .source-viewer").shouldHave(Condition.text(code)); + $(".code-components .source-viewer").shouldHave(Condition.text(code)); return this; } public ProjectCodePage shouldHaveBreadcrumbs(String... breadcrumbs) { for (String breadcrumb : breadcrumbs) { - Selenide.$(".code-breadcrumbs").shouldHave(Condition.text(breadcrumb)); + $(".code-breadcrumbs").shouldHave(Condition.text(breadcrumb)); } return this; } public ProjectCodePage shouldSearchResult(String name) { - Selenide.$(".code-search-with-results").shouldHave(Condition.text(name)); + $(".code-search-with-results").shouldHave(Condition.text(name)); return this; } + + public SourceViewer getSourceViewer() { + return new SourceViewer($(".code-components .source-viewer")); + } } diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java new file mode 100644 index 00000000000..5da34d9c7fd --- /dev/null +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2018 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarqube.qa.util.pageobjects; + +import com.codeborne.selenide.SelenideElement; + +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$; + +public class SourceViewer { + + private final SelenideElement el; + + SourceViewer(SelenideElement el) { + this.el = el; + } + + public SelenideElement openCoverageDetails(int line) { + this.el.$(".source-line-coverage[data-line-number=\"" + line + "\"").click(); + return $(".bubble-popup").shouldBe(visible); + } + +} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/popups/templates/source-viewer-coverage-popup.hbs b/server/sonar-web/src/main/js/components/SourceViewer/popups/templates/source-viewer-coverage-popup.hbs index 6238e9ffd39..bad2779d285 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/popups/templates/source-viewer-coverage-popup.hbs +++ b/server/sonar-web/src/main/js/components/SourceViewer/popups/templates/source-viewer-coverage-popup.hbs @@ -1,11 +1,11 @@
+
+ {{t 'source_viewer.covered'}} + {{#if row.conditions}} + ({{default row.coveredConditions 0}} of {{row.conditions}} {{t 'source_viewer.conditions'}}) + {{/if}} +
{{#each testFiles}} -
- {{t 'source_viewer.covered'}} - {{#if row.conditions}} - ({{default row.coveredConditions 0}} of {{row.conditions}} {{t 'source_viewer.conditions'}}) - {{/if}} -
{{collapsePath file.longName}} @@ -16,7 +16,7 @@ + data-key="{{../file.key}}" data-method="{{name}}"> {{name}} diff --git a/tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java b/tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java index cc73a204a40..b4ec8308722 100644 --- a/tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java +++ b/tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java @@ -35,6 +35,7 @@ import org.sonarqube.qa.util.Tester; import org.sonarqube.ws.client.GetRequest; import org.sonarqube.ws.client.WsRequest; +import static com.codeborne.selenide.Condition.text; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.getMeasuresAsDoubleByMetricKey; import static util.ItUtils.projectDir; @@ -217,6 +218,17 @@ public class CoverageTest { verifyComputeEngineTempDirIsEmpty(); } + @Test + public void component_viewer_should_show_uncovered_conditions() { + orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-new-coverage-v2"))); + + tester.openBrowser() + .openCode("sample-new-coverage", "sample-new-coverage:src/main/xoo/sample/Sample.xoo") + .getSourceViewer() + .openCoverageDetails(7) + .shouldHave(text("2 of 3")); + } + private void verifyComputeEngineTempDirIsEmpty() { File ceTempDirectory = new File(new File(orchestrator.getServer().getHome(), "temp"), "ce"); assertThat(FileUtils.listFiles(ceTempDirectory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)).isEmpty();