From: Grégoire Aubert Date: Fri, 30 Jun 2017 14:29:01 +0000 (+0200) Subject: SONAR-9483 Add IT for the ui X-Git-Tag: 6.5-M2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fe4a05861141582059920895e0002639e2a2877a;p=sonarqube.git SONAR-9483 Add IT for the ui --- diff --git a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java index 54363129fec..342d2635462 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java @@ -127,6 +127,11 @@ public class Navigation { return open(url, MembersPage.class); } + public QualityProfilePage openQualityProfile(String language, String name, String organization) { + String profileUrl = "/quality_profiles/show?language=" + language + "&name=" + name; + return open("/organizations/" + organization + profileUrl , QualityProfilePage.class); + } + public BackgroundTasksPage openBackgroundTasksPage() { return open("/background_tasks", BackgroundTasksPage.class); } diff --git a/tests/src/test/java/org/sonarqube/pageobjects/QualityProfilePage.java b/tests/src/test/java/org/sonarqube/pageobjects/QualityProfilePage.java new file mode 100644 index 00000000000..9c21c692d36 --- /dev/null +++ b/tests/src/test/java/org/sonarqube/pageobjects/QualityProfilePage.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.pageobjects; + +import com.codeborne.selenide.Condition; + +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.page; + +public class QualityProfilePage { + public QualityProfilePage() { + $("#quality-profile").shouldBe(Condition.visible); + } + + public QualityProfilePage shouldHaveMissingSonarWayRules(Integer nbRules) { + $(".quality-profile-rules-sonarway-missing") + .shouldBe(Condition.visible) + .$("a").shouldHave(Condition.text(nbRules.toString())); + return this; + } + + public RulesPage showMissingSonarWayRules() { + $(".quality-profile-rules-sonarway-missing") + .shouldBe(Condition.visible).$("a").click(); + $(".coding-rules").shouldBe(Condition.visible); + return page(RulesPage.class); + } +} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java b/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java index 35eda0b68e3..0122ae842da 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java @@ -21,10 +21,12 @@ package org.sonarqube.pageobjects; import com.codeborne.selenide.Condition; import com.codeborne.selenide.ElementsCollection; +import com.codeborne.selenide.SelenideElement; import java.util.List; import java.util.stream.Collectors; import org.openqa.selenium.By; +import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; @@ -49,4 +51,14 @@ public class RulesPage extends Navigation { // warning - number is localized return Integer.parseInt($("#coding-rules-total").text()); } + + public ElementsCollection getSelectedFacetItems(String facetName) { + SelenideElement facet = $(".search-navigator-facet-box[data-property='"+ facetName+"']").shouldBe(Condition.visible); + return facet.$$(".js-facet.active"); + } + + public RulesPage shouldHaveTotalRules(Integer total) { + $("#coding-rules-total").shouldHave(text(total.toString())); + return this; + } } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java index 1d9b9c1e420..83f63e34439 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityProfile/OrganizationQualityProfilesUiTest.java @@ -22,6 +22,8 @@ package org.sonarqube.tests.qualityProfile; import com.codeborne.selenide.Condition; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; +import org.sonarqube.pageobjects.QualityProfilePage; +import org.sonarqube.pageobjects.RulesPage; import org.sonarqube.tests.Category6Suite; import org.junit.Before; import org.junit.ClassRule; @@ -30,6 +32,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonarqube.tests.Tester; import org.sonarqube.ws.Organizations; +import org.sonarqube.ws.QualityProfiles; import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.qualityprofile.AddProjectRequest; import org.sonarqube.ws.client.qualityprofile.ChangeParentRequest; @@ -137,6 +140,21 @@ public class OrganizationQualityProfilesUiTest { tester.runHtmlTests("/organization/OrganizationQualityProfilesUiTest/should_restore.html"); } + @Test + public void testSonarWayComparison() { + QualityProfiles.CreateWsResponse.QualityProfile xooProfile = tester.qProfiles().createXooProfile(organization); + tester.qProfiles().activateRule(xooProfile, "xoo:OneBugIssuePerLine"); + tester.qProfiles().activateRule(xooProfile, "xoo:OneIssuePerLine"); + Navigation nav = tester.openBrowser(); + QualityProfilePage qpPage = nav.openQualityProfile(xooProfile.getLanguage(), xooProfile.getName(), organization.getKey()); + qpPage.shouldHaveMissingSonarWayRules(2); + RulesPage rPage = qpPage.showMissingSonarWayRules(); + rPage.shouldHaveTotalRules(2); + rPage.getSelectedFacetItems("qprofile") + .shouldHaveSize(2) + .findBy(Condition.cssClass("compare")).has(Condition.text("Sonar way")); + } + private void createProfile(String language, String name) { tester.wsClient().wsConnector().call( new PostRequest("api/qualityprofiles/create")