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);
}
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
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() {
--- /dev/null
+/*
+ * 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;
+ }
+
+}
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.$$;
$(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());
$("#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"));
+ }
+
}
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;
TechnicalDebtTest.class,
// ui
IssuesPageTest.class,
+ // rule
+ RulesPageTest.class,
// branch
BranchTest.class
})
--- /dev/null
+/*
+ * 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");
+ }
+}