diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-24 14:13:34 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-07-25 09:20:30 +0200 |
commit | 935ecc809124f311ecb17ee42ae82896b5028293 (patch) | |
tree | 78647833062d2086c2296a968c9e491898e0869c /tests | |
parent | 10a850b95d08ecb8efe911cd23570fef3ab5733e (diff) | |
download | sonarqube-935ecc809124f311ecb17ee42ae82896b5028293.tar.gz sonarqube-935ecc809124f311ecb17ee42ae82896b5028293.zip |
SONAR-9565 Display quality gate directly if there is only one and the user can't edit
Diffstat (limited to 'tests')
5 files changed, 47 insertions, 12 deletions
diff --git a/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java b/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java index 673e037c193..f1d150e2c16 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/ProjectDashboardPage.java @@ -101,8 +101,9 @@ public class ProjectDashboardPage { } public ProjectDashboardPage hasQualityGateLink(String name, String link) { - SelenideElement elem = $(".overview-meta-header").should(exist) - .parent().find(By.linkText(name)).should(exist); + SelenideElement elem = $$(".overview-meta-card") + .findBy(text("Quality Gate")).should(exist) + .find(By.linkText(name)).should(exist); assertThat(elem.attr("href")).endsWith(link); return this; } diff --git a/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java b/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java index 3d7162f898d..4133bbfeb92 100644 --- a/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java +++ b/tests/src/test/java/org/sonarqube/pageobjects/QualityGatePage.java @@ -26,11 +26,11 @@ import static com.codeborne.selenide.Selenide.$$; public class QualityGatePage { public QualityGatePage() { - $(".quality-gates-results").shouldBe(Condition.visible); + $("#quality-gates-page").shouldBe(Condition.visible); } public QualityGatePage countQualityGates(Integer count) { - $$(".quality-gates-results .list-group-item").shouldHaveSize(count); + $$("#quality-gates-page .list-group-item").shouldHaveSize(count); return this; } @@ -43,4 +43,14 @@ public class QualityGatePage { $("#quality-gate-add").shouldNot(Condition.exist); return this; } + + public QualityGatePage displayIntro() { + $(".search-navigator-intro").should(Condition.exist).shouldBe(Condition.visible); + return this; + } + + public QualityGatePage displayQualityGateDetail(String qualityGateName) { + $(".layout-page-main-header").shouldHave(Condition.text(qualityGateName)); + return this; + } } diff --git a/tests/src/test/java/org/sonarqube/tests/OrganizationTester.java b/tests/src/test/java/org/sonarqube/tests/OrganizationTester.java index 2072e87822a..5550cd527c5 100644 --- a/tests/src/test/java/org/sonarqube/tests/OrganizationTester.java +++ b/tests/src/test/java/org/sonarqube/tests/OrganizationTester.java @@ -74,6 +74,13 @@ public class OrganizationTester { return this; } + public Organizations.Organization getDefaultOrganization() { + return service().search(SearchWsRequest.builder().build()).getOrganizationsList() + .stream() + .filter(o -> o.getKey().equals("default-organization")) + .findFirst().orElseThrow(() -> new IllegalStateException("Can't find default organization")); + } + public OrganizationTester assertThatOrganizationDoesNotExist(String organizationKey) { SearchWsRequest request = new SearchWsRequest.Builder().setOrganizations(organizationKey).build(); Organizations.SearchWsResponse searchWsResponse = service().search(request); diff --git a/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java index 01ab1189d87..fc846cb244f 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateUiTest.java @@ -52,10 +52,14 @@ public class OrganizationQualityGateUiTest { private Organizations.Organization organization; private WsUsers.CreateWsResponse.User user; + private WsUsers.CreateWsResponse.User gateAdmin; @Before public void setUp() throws Exception { organization = tester.organizations().generate(); + gateAdmin = tester.users().generate(); + tester.organizations().addMember(tester.organizations().getDefaultOrganization(), gateAdmin); + tester.wsClient().permissions().addUser(new org.sonarqube.ws.client.permission.AddUserWsRequest().setLogin(gateAdmin.getLogin()).setPermission("gateadmin")); user = tester.users().generate(); tester.organizations().addMember(organization, user); restoreProfile(orchestrator, getClass().getResource("/issue/with-many-rules.xml"), organization.getKey()); @@ -67,7 +71,7 @@ public class OrganizationQualityGateUiTest { .logIn().submitCredentials(user.getLogin()) .openQualityGates(organization.getKey()); - SelenideElement element = $(".navbar-context .navbar-nav") + SelenideElement element = $(".navbar-context .navbar-tabs") .find(By.linkText("Quality Gates")) .should(Condition.exist); assertThat(element.attr("href")).endsWith("/organizations/" + organization.getKey() + "/quality_gates"); @@ -76,9 +80,9 @@ public class OrganizationQualityGateUiTest { @Test public void should_display_available_quality_gates() { QualityGatePage page = tester.openBrowser() - .logIn().submitCredentials(user.getLogin()) + .logIn().submitCredentials(gateAdmin.getLogin()) .openQualityGates(organization.getKey()); - page.countQualityGates(1); + page.countQualityGates(1).displayIntro(); } @Test @@ -88,7 +92,7 @@ public class OrganizationQualityGateUiTest { .openQualityGates(organization.getKey()) .canNotCreateQG(); tester.openBrowser() - .logIn().submitCredentials("admin") + .logIn().submitCredentials(gateAdmin.getLogin()) .openQualityGates(organization.getKey()) .canCreateQG(); } @@ -110,4 +114,12 @@ public class OrganizationQualityGateUiTest { .openProjectDashboard(project); page.hasQualityGateLink("SonarQube way", link); } + + @Test + public void should_redirect_to_display_quality_gate_detail() { + QualityGatePage page = tester.openBrowser() + .logIn().submitCredentials(user.getLogin()) + .openQualityGates(organization.getKey()); + page.countQualityGates(1).displayQualityGateDetail("SonarQube way"); + } } diff --git a/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java b/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java index acb207f5271..59fd4cbe738 100644 --- a/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java +++ b/tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java @@ -42,6 +42,8 @@ import org.sonar.wsclient.qualitygate.UpdateCondition; import org.sonarqube.pageobjects.Navigation; import org.sonarqube.pageobjects.ProjectActivityPage; import org.sonarqube.tests.Tester; +import org.sonarqube.ws.Organizations; +import org.sonarqube.ws.WsUsers; import static com.codeborne.selenide.Selenide.$; import static org.apache.commons.lang.time.DateUtils.addDays; @@ -119,7 +121,7 @@ public class QualityGateUiTest { .logIn().submitCredentials(login) .openQualityGates(); - SelenideElement element = $(".navbar-global .navbar-nav") + SelenideElement element = $(".navbar-global .global-navbar-menu") .find(By.linkText("Quality Gates")) .should(Condition.exist); assertThat(element.attr("href")).endsWith("/quality_gates"); @@ -128,14 +130,17 @@ public class QualityGateUiTest { @Test public void should_not_allow_random_user_to_create() { String login = tester.users().generate().getLogin(); + String admin = tester.users().generateAdministrator().getLogin(); tester.openBrowser() .logIn().submitCredentials(login) .openQualityGates() - .canNotCreateQG(); + .canNotCreateQG() + .displayQualityGateDetail("SonarQube way"); tester.openBrowser() - .logIn().submitCredentials("admin") + .logIn().submitCredentials(admin) .openQualityGates() - .canCreateQG(); + .canCreateQG() + .displayIntro(); } private void scanSampleWithDate(String date) { |