diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-26 22:43:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-26 22:43:17 +0200 |
commit | 80706fcaec0e458ef2e3d05ee2086582577149ef (patch) | |
tree | 1788b50fd821ff26cdd68abcc1261aface3e72df | |
parent | 47e73abe2717a0b673f15fefcdfa6e71907e1a09 (diff) | |
download | sonarqube-80706fcaec0e458ef2e3d05ee2086582577149ef.tar.gz sonarqube-80706fcaec0e458ef2e3d05ee2086582577149ef.zip |
fix displaying rule profiles (#2764)
7 files changed, 113 insertions, 21 deletions
diff --git a/server/sonar-web/src/main/js/api/rules.ts b/server/sonar-web/src/main/js/api/rules.ts index f7b1c0bdab0..82273da860e 100644 --- a/server/sonar-web/src/main/js/api/rules.ts +++ b/server/sonar-web/src/main/js/api/rules.ts @@ -43,14 +43,14 @@ export interface GetRuleDetailsParameters { organization?: string; } -export function getRuleDetails({ key }: GetRuleDetailsParameters): Promise<any> { - return getJSON('/api/rules/show', { key }).catch(throwGlobalError); +export function getRuleDetails(parameters: GetRuleDetailsParameters): Promise<any> { + return getJSON('/api/rules/show', parameters).catch(throwGlobalError); } export function getRuleTags(parameters: { organization?: string }): Promise<string[]> { return getJSON('/api/rules/tags', parameters).then(r => r.tags, throwGlobalError); } -export function deleteRule({ key }: { key: string }) { - return post('/api/rules/delete', { key }).catch(throwGlobalError); +export function deleteRule(parameters: { key: string }) { + return post('/api/rules/delete', parameters).catch(throwGlobalError); } diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index dfa7b4532c2..11440377ec6 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1171,6 +1171,7 @@ coding_rules.bulk_change=Bulk Change coding_rules.bulk_change.success={2} rule(s) changed in profile {0} - {1} coding_rules.bulk_change.warning={2} rule(s) changed, {3} rule(s) ignored in profile {0} - {1} coding_rules.can_not_deactivate=This rule is inherited and can not be deactivated. +coding_rules.change_details=Change Details of Quality Profile coding_rules.create=Create coding_rules.create_custom_rule=Create Custom Rule coding_rules.custom_rule=Custom Rule diff --git a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java index 546d420b6d0..b85f3a79566 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java @@ -220,9 +220,8 @@ public class Navigation { return this; } - public RulesPage clickOnRules() { - $(By.linkText("Rules")).click(); - return page(RulesPage.class); + public RulesPage openRules() { + return open("/coding_rules", RulesPage.class); } public SelenideElement clickOnQualityProfiles() { diff --git a/tests/src/test/java/org/sonarqube/pageobjects/RuleDetails.java b/tests/src/test/java/org/sonarqube/pageobjects/RuleDetails.java new file mode 100644 index 00000000000..fda58ded977 --- /dev/null +++ b/tests/src/test/java/org/sonarqube/pageobjects/RuleDetails.java @@ -0,0 +1,40 @@ +/* + * 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.SelenideElement; + +import static com.codeborne.selenide.Condition.text; +import static com.codeborne.selenide.Selenide.$; + +public class RuleDetails { + + private final SelenideElement elt; + + public RuleDetails(SelenideElement elt) { + this.elt = elt; + } + + public RuleDetails shouldBeActivatedOn(String profileName) { + $("#coding-rules-detail-quality-profiles").shouldHave(text(profileName)); + return this; + } + +} diff --git a/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java b/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java index 0122ae842da..e3f5afbac66 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/RulesPage.java @@ -22,11 +22,10 @@ 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.Condition.visible; import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; @@ -36,17 +35,6 @@ public class RulesPage extends Navigation { $(By.cssSelector(".coding-rules")).should(Condition.exist); } - public ElementsCollection getRules() { - return $$(".coding-rules .coding-rule"); - } - - public List<RuleItem> getRulesAsItems() { - return getRules() - .stream() - .map(elt -> new RuleItem(elt)) - .collect(Collectors.toList()); - } - public int getTotal() { // warning - number is localized return Integer.parseInt($("#coding-rules-total").text()); @@ -61,4 +49,22 @@ public class RulesPage extends Navigation { $("#coding-rules-total").shouldHave(text(total.toString())); return this; } + + public RulesPage openFacet(String facet) { + $(".search-navigator-facet-box[data-property=\"" + facet + "\"] .js-facet-toggle").click(); + return this; + } + + public RulesPage selectFacetItemByText(String facet, String itemText) { + $$(".search-navigator-facet-box[data-property=\"" + facet + "\"] .js-facet") + .findBy(text(itemText)).click(); + return this; + } + + public RuleDetails openFirstRule() { + $$(".js-rule").first().click(); + $(".coding-rules-details").shouldBe(visible); + return new RuleDetails($(".coding-rules-details")); + } + } diff --git a/tests/src/test/java/org/sonarqube/tests/Category2Suite.java b/tests/src/test/java/org/sonarqube/tests/Category2Suite.java index ab558497243..b5b27ac1d4b 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category2Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category2Suite.java @@ -47,9 +47,10 @@ import org.sonarqube.tests.qualityModel.MaintainabilityRatingMeasureTest; import org.sonarqube.tests.qualityModel.NewDebtRatioMeasureTest; import org.sonarqube.tests.qualityModel.ReliabilityMeasureTest; import org.sonarqube.tests.qualityModel.SecurityMeasureTest; -import org.sonarqube.tests.qualityModel.TechnicalDebtInIssueChangelogTest; import org.sonarqube.tests.qualityModel.TechnicalDebtAndIssueNewMeasuresTest; +import org.sonarqube.tests.qualityModel.TechnicalDebtInIssueChangelogTest; import org.sonarqube.tests.qualityModel.TechnicalDebtTest; +import org.sonarqube.tests.rule.RulesPageTest; import org.sonarqube.tests.scm.ScmTest; import org.sonarqube.tests.test.CoverageTest; import org.sonarqube.tests.test.CoverageTrackingTest; @@ -97,6 +98,8 @@ import static util.ItUtils.xooPlugin; TechnicalDebtTest.class, // ui IssuesPageTest.class, + // rule + RulesPageTest.class, // branch BranchTest.class }) diff --git a/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java b/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java new file mode 100644 index 00000000000..07e76dcc2c6 --- /dev/null +++ b/tests/src/test/java/org/sonarqube/tests/rule/RulesPageTest.java @@ -0,0 +1,43 @@ +/* + * 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.tests.rule; + +import com.sonar.orchestrator.Orchestrator; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.sonarqube.pageobjects.RulesPage; +import org.sonarqube.tests.Category2Suite; +import org.sonarqube.tests.Tester; + +public class RulesPageTest { + @ClassRule + public static Orchestrator ORCHESTRATOR = Category2Suite.ORCHESTRATOR; + + @Rule + public Tester tester = new Tester(ORCHESTRATOR).disableOrganizations(); + + @Test + public void should_display_rule_profiles() { + RulesPage page = tester.openBrowser().openRules(); + page.openFacet("qprofile").selectFacetItemByText("qprofile", "Basic").shouldHaveTotalRules(1); + page.openFirstRule().shouldBeActivatedOn("Basic"); + } +} |