@@ -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")); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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> |
@@ -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(); |