diff options
author | Stas Vilchik <stas-vilchik@users.noreply.github.com> | 2017-03-03 17:15:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-03 17:15:37 +0100 |
commit | ba93a1a0ed121bd331d87636b733e3e31f0b2d89 (patch) | |
tree | d8577faa316ff0f357c5e8d3641152e2d48be698 /it/it-tests | |
parent | 85f7fcad4280c797f580dc2ceaf5d029092cd9c1 (diff) | |
download | sonarqube-ba93a1a0ed121bd331d87636b733e3e31f0b2d89.tar.gz sonarqube-ba93a1a0ed121bd331d87636b733e3e31f0b2d89.zip |
refactor source viewer (#1744)
Diffstat (limited to 'it/it-tests')
5 files changed, 186 insertions, 1 deletions
diff --git a/it/it-tests/src/test/java/it/Category2Suite.java b/it/it-tests/src/test/java/it/Category2Suite.java index 8a4bd9db03e..2f59c261c95 100644 --- a/it/it-tests/src/test/java/it/Category2Suite.java +++ b/it/it-tests/src/test/java/it/Category2Suite.java @@ -36,6 +36,7 @@ import it.issue.IssuePurgeTest; import it.issue.IssueSearchTest; import it.issue.IssueTrackingTest; import it.issue.IssueWorkflowTest; +import it.issue.IssuesPageTest; import it.issue.NewIssuesMeasureTest; import it.qualityModel.MaintainabilityMeasureTest; import it.qualityModel.MaintainabilityRatingMeasureTest; @@ -92,7 +93,9 @@ import static util.ItUtils.xooPlugin; SecurityMeasureTest.class, TechnicalDebtInIssueChangelogTest.class, TechnicalDebtMeasureVariationTest.class, - TechnicalDebtTest.class + TechnicalDebtTest.class, + // ui + IssuesPageTest.class }) public class Category2Suite { diff --git a/it/it-tests/src/test/java/it/issue/IssuesPageTest.java b/it/it-tests/src/test/java/it/issue/IssuesPageTest.java new file mode 100644 index 00000000000..bf869acb3be --- /dev/null +++ b/it/it-tests/src/test/java/it/issue/IssuesPageTest.java @@ -0,0 +1,72 @@ +/* + * 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 it.issue; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.locator.FileLocation; +import it.Category2Suite; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import pageobjects.Navigation; +import pageobjects.issues.Issue; +import pageobjects.issues.IssuesPage; +import util.user.UserRule; + +import static util.ItUtils.runProjectAnalysis; + +public class IssuesPageTest { + private static final String PROJECT_KEY = "sample"; + + @ClassRule + public static Orchestrator ORCHESTRATOR = Category2Suite.ORCHESTRATOR; + + @ClassRule + public static UserRule userRule = UserRule.from(ORCHESTRATOR); + + @Rule + public Navigation nav = Navigation.get(ORCHESTRATOR); + + @BeforeClass + public static void prepareData() { + ORCHESTRATOR.resetData(); + + ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/with-many-rules.xml")); + + ORCHESTRATOR.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY); + ORCHESTRATOR.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "with-many-rules"); + runProjectAnalysis(ORCHESTRATOR, "shared/xoo-multi-modules-sample"); + } + + @Test + public void should_display_actions() { + IssuesPage page = nav.logIn().asAdmin().openIssues(); + Issue issue = page.getFirstIssue(); + issue.shouldAllowAssign().shouldAllowChangeType(); + } + + @Test + public void should_not_display_actions() { + IssuesPage page = nav.openIssues(); + Issue issue = page.getFirstIssue(); + issue.shouldNotAllowAssign().shouldNotAllowChangeType(); + } +} diff --git a/it/it-tests/src/test/java/pageobjects/Navigation.java b/it/it-tests/src/test/java/pageobjects/Navigation.java index 59dee222b86..14480cb0e62 100644 --- a/it/it-tests/src/test/java/pageobjects/Navigation.java +++ b/it/it-tests/src/test/java/pageobjects/Navigation.java @@ -29,6 +29,7 @@ import java.net.URLEncoder; import javax.annotation.Nullable; import org.junit.rules.ExternalResource; import org.openqa.selenium.By; +import pageobjects.issues.IssuesPage; import pageobjects.licenses.LicensesPage; import pageobjects.projects.ProjectsPage; import pageobjects.settings.SettingsPage; @@ -61,6 +62,10 @@ public class Navigation extends ExternalResource { return open("/projects", ProjectsPage.class); } + public IssuesPage openIssues() { + return open("/issues", IssuesPage.class); + } + public ProjectDashboardPage openProjectDashboard(String projectKey) { // TODO encode projectKey String url = "/dashboard?id=" + projectKey; diff --git a/it/it-tests/src/test/java/pageobjects/issues/Issue.java b/it/it-tests/src/test/java/pageobjects/issues/Issue.java new file mode 100644 index 00000000000..32e79351b6d --- /dev/null +++ b/it/it-tests/src/test/java/pageobjects/issues/Issue.java @@ -0,0 +1,53 @@ +/* + * 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 pageobjects.issues; + +import com.codeborne.selenide.SelenideElement; + +import static com.codeborne.selenide.Condition.visible; + +public class Issue { + + private final SelenideElement elt; + + public Issue(SelenideElement elt) { + this.elt = elt; + } + + public Issue shouldAllowAssign() { + elt.find(".js-issue-assign").shouldBe(visible); + return this; + } + + public Issue shouldAllowChangeType() { + elt.find(".js-issue-set-type").shouldBe(visible); + return this; + } + + public Issue shouldNotAllowAssign() { + elt.find(".js-issue-assign").shouldNotBe(visible); + return this; + } + + public Issue shouldNotAllowChangeType() { + elt.find(".js-issue-set-type").shouldNotBe(visible); + return this; + } +} diff --git a/it/it-tests/src/test/java/pageobjects/issues/IssuesPage.java b/it/it-tests/src/test/java/pageobjects/issues/IssuesPage.java new file mode 100644 index 00000000000..13fa9b41434 --- /dev/null +++ b/it/it-tests/src/test/java/pageobjects/issues/IssuesPage.java @@ -0,0 +1,52 @@ +/* + * 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 pageobjects.issues; + +import com.codeborne.selenide.ElementsCollection; +import java.util.List; +import java.util.stream.Collectors; + +import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan; +import static com.codeborne.selenide.Condition.exist; +import static com.codeborne.selenide.Selenide.$; +import static com.codeborne.selenide.Selenide.$$; + +public class IssuesPage { + + public IssuesPage() { + $(".issues").should(exist); + } + + private ElementsCollection getIssuesElements() { + return $$(".issues .issue"); + } + + public List<Issue> getIssues() { + return getIssuesElements() + .stream() + .map(Issue::new) + .collect(Collectors.toList()); + } + + public Issue getFirstIssue() { + getIssuesElements().shouldHave(sizeGreaterThan(0)); + return new Issue(getIssuesElements().first()); + } +} |