]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10258 Missing information about uncovered conditions on a line
authorStas Vilchik <stas.vilchik@sonarsource.com>
Mon, 8 Jan 2018 16:52:43 +0000 (17:52 +0100)
committerStas Vilchik <stas.vilchik@sonarsource.com>
Wed, 10 Jan 2018 07:59:34 +0000 (08:59 +0100)
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectCodePage.java
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/SourceViewer.java [new file with mode: 0644]
server/sonar-web/src/main/js/components/SourceViewer/popups/templates/source-viewer-coverage-popup.hbs
tests/src/test/java/org/sonarqube/tests/test/CoverageTest.java

index fe622da11c5f3fed28e5d88827e7c8677c3ef2b7..eab80acfcc2d0333807e13f77559d665569f5ed2 100644 (file)
@@ -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 (file)
index 0000000..5da34d9
--- /dev/null
@@ -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);
+  }
+
+}
index 6238e9ffd392f36b67497a7c0a76349c9333e162..bad2779d285872421bab179fdf9aa03b5f03c1df 100644 (file)
@@ -1,11 +1,11 @@
 <div class="bubble-popup-container">
+  <div class="bubble-popup-title">
+    {{t 'source_viewer.covered'}}
+    {{#if row.conditions}}
+      ({{default row.coveredConditions 0}} of {{row.conditions}} {{t 'source_viewer.conditions'}})
+    {{/if}}
+  </div>
   {{#each testFiles}}
-    <div class="bubble-popup-title">
-      {{t 'source_viewer.covered'}}
-      {{#if row.conditions}}
-        ({{default row.coveredConditions 0}} of {{row.conditions}} {{t 'source_viewer.conditions'}})
-      {{/if}}
-    </div>
     <div class="bubble-popup-section">
       <a class="component-viewer-popup-test-file link-action" data-key="{{file.key}}" title="{{file.longName}}">
         <span>{{collapsePath file.longName}}</span>
@@ -16,7 +16,7 @@
             <i class="component-viewer-popup-test-status {{testStatusIconClass status}}"></i>
             <span class="component-viewer-popup-test-name">
               <a class="component-viewer-popup-test-file link-action" title="{{name}}"
-                 data-key="{{../file.key}}" data-method="{{name}}">
+                data-key="{{../file.key}}" data-method="{{name}}">
                 {{name}}
               </a>
             </span>
index cc73a204a40547f9a5e4e073c7e926d5b2ac19c6..b4ec83087223ec4efc343d66792ee044efbbef1b 100644 (file)
@@ -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();