diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-19 15:10:29 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-25 09:20:30 +0200 |
commit | c86db4ee3737107b738e2bd83d5cfbad5d3575f2 (patch) | |
tree | 11267bf2cb1f5a957547164cd7c13aa25e7b5731 /tests | |
parent | 5990dc0b10ad7cdd3e09b9eb8d0b636795d94c7b (diff) | |
download | sonarqube-c86db4ee3737107b738e2bd83d5cfbad5d3575f2.tar.gz sonarqube-c86db4ee3737107b738e2bd83d5cfbad5d3575f2.zip |
SONAR-9566 Add Issues link at organization level navbar
Diffstat (limited to 'tests')
4 files changed, 118 insertions, 0 deletions
diff --git a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java index 342d2635462..6bdf9be6156 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/Navigation.java @@ -31,6 +31,7 @@ import javax.annotation.Nullable; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.html5.WebStorage; +import org.sonarqube.pageobjects.issues.Issue; import org.sonarqube.tests.Tester; import org.sonarqube.pageobjects.issues.IssuesPage; import org.sonarqube.pageobjects.licenses.LicensesPage; @@ -88,6 +89,10 @@ public class Navigation { return open("/issues", IssuesPage.class); } + public IssuesPage openIssues(String organization) { + return open("/organizations/" + organization + "/issues", IssuesPage.class); + } + public IssuesPage openComponentIssues(String component) { return open("/component_issues?id=" + component, IssuesPage.class); } diff --git a/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java b/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java index d09c894f9d9..572b69b8454 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/issues/IssuesPage.java @@ -25,6 +25,7 @@ import java.util.stream.Collectors; import static com.codeborne.selenide.CollectionCondition.sizeGreaterThan; import static com.codeborne.selenide.Condition.exist; +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.$$; @@ -39,6 +40,10 @@ public class IssuesPage { return $$(".issues .issue"); } + private ElementsCollection getIssuesPathComponents() { + return $$(".issues-workspace-list-component"); + } + public List<Issue> getIssues() { return getIssuesElements() .stream() @@ -46,11 +51,21 @@ public class IssuesPage { .collect(Collectors.toList()); } + public IssuesPage issuesCount(Integer count) { + this.getIssuesElements().shouldHaveSize(count); + return this; + } + public Issue getFirstIssue() { getIssuesElements().shouldHave(sizeGreaterThan(0)); return new Issue(getIssuesElements().first()); } + public IssuesPage componentsShouldContain(String path) { + this.getIssuesPathComponents().forEach(element -> element.shouldHave(text(path))); + return this; + } + public IssuesPage bulkChangeOpen() { $("#issues-bulk-change").shouldBe(visible).click(); $("#bulk-change-form").shouldBe(visible); diff --git a/tests/src/test/java/org/sonarqube/tests/Category6Suite.java b/tests/src/test/java/org/sonarqube/tests/Category6Suite.java index 40e1f20930f..69ea5870d25 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category6Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category6Suite.java @@ -28,6 +28,7 @@ import org.junit.runners.Suite; import org.sonarqube.tests.authorisation.PermissionTemplateTest; import org.sonarqube.tests.issue.IssueTagsTest; import org.sonarqube.tests.issue.OrganizationIssueAssignTest; +import org.sonarqube.tests.issue.OrganizationIssuesPageTest; import org.sonarqube.tests.organization.BillingTest; import org.sonarqube.tests.organization.OrganizationMembershipTest; import org.sonarqube.tests.organization.OrganizationMembershipUiTest; @@ -57,6 +58,7 @@ import static util.ItUtils.xooPlugin; @Suite.SuiteClasses({ OrganizationIdentityProviderTest.class, OrganizationIssueAssignTest.class, + OrganizationIssuesPageTest.class, OrganizationMembershipTest.class, OrganizationMembershipUiTest.class, OrganizationQualityProfilesUiTest.class, diff --git a/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java new file mode 100644 index 00000000000..f6f5a1dcaeb --- /dev/null +++ b/tests/src/test/java/org/sonarqube/tests/issue/OrganizationIssuesPageTest.java @@ -0,0 +1,96 @@ +/* + * 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.issue; + +import com.sonar.orchestrator.Orchestrator; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.sonarqube.pageobjects.Navigation; +import org.sonarqube.tests.Category6Suite; +import org.sonarqube.tests.Tester; +import org.sonarqube.ws.Organizations; +import org.sonarqube.ws.WsUsers; +import util.issue.IssueRule; + +import static util.ItUtils.restoreProfile; +import static util.ItUtils.runProjectAnalysis; + +public class OrganizationIssuesPageTest { + + @ClassRule + public static Orchestrator orchestrator = Category6Suite.ORCHESTRATOR; + + @Rule + public Tester tester = new Tester(orchestrator); + + @Rule + public IssueRule issueRule = IssueRule.from(orchestrator); + + private Organizations.Organization org1; + private Organizations.Organization org2; + private WsUsers.CreateWsResponse.User user1; + private WsUsers.CreateWsResponse.User user2; + + @Before + public void setUp() throws Exception { + org1 = tester.organizations().generate(); + org2 = tester.organizations().generate(); + user1 = tester.users().generate(); + user2 = tester.users().generate(); + tester.organizations().addMember(org1, user1); + tester.organizations().addMember(org2, user2); + restoreProfile(orchestrator, getClass().getResource("/issue/with-many-rules.xml"), org1.getKey()); + restoreProfile(orchestrator, getClass().getResource("/issue/with-many-rules.xml"), org2.getKey()); + } + + @Test + public void display_organization_rules_only() { + String project1 = provisionProject(org1); + analyseProject(project1, org1.getKey()); + String project2 = provisionProject(org2); + analyseProject(project2, org2.getKey()); + Navigation nav = tester.openBrowser().logIn().submitCredentials(user1.getLogin()); + + nav.openIssues(org1.getKey()) + .issuesCount(2) + .componentsShouldContain(org1.getName()); + + nav.openIssues() + .issuesCount(4); + } + + private String provisionProject(Organizations.Organization organization) { + return tester.projects().generate(organization).getKey(); + } + + private void analyseProject(String projectKey, String organization) { + runProjectAnalysis(orchestrator, "shared/xoo-multi-modules-sample", + "sonar.projectKey", projectKey, + "sonar.organization", organization, + "sonar.login", "admin", + "sonar.password", "admin", + "sonar.scm.disabled", "false", + "sonar.scm.provider", "xoo"); + } + +} |