aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-12-29 12:02:55 +0100
committerStas Vilchik <vilchiks@gmail.com>2016-12-29 17:26:40 +0100
commit2f078147320a3e05ff533b2ad533aac1faa18d11 (patch)
tree1ffd58bf3fd4c0ca393d2b1edd97ed69438ceb15 /it
parentf5ab57af4cfefd4a01f5839a23a652347e334e76 (diff)
downloadsonarqube-2f078147320a3e05ff533b2ad533aac1faa18d11.tar.gz
sonarqube-2f078147320a3e05ff533b2ad533aac1faa18d11.zip
SONAR-8563 Rewrite notifications page
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/user/MyAccountPageTest.java12
-rw-r--r--it/it-tests/src/test/java/pageobjects/Navigation.java4
-rw-r--r--it/it-tests/src/test/java/pageobjects/NotificationsPage.java118
3 files changed, 134 insertions, 0 deletions
diff --git a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java
index 01140a1b116..4fda2613b38 100644
--- a/it/it-tests/src/test/java/it/user/MyAccountPageTest.java
+++ b/it/it-tests/src/test/java/it/user/MyAccountPageTest.java
@@ -83,6 +83,18 @@ public class MyAccountPageTest {
runSelenese(orchestrator, "/user/MyAccountPageTest/should_display_projects.html");
}
+ @Test
+ public void notifications() {
+ nav.logIn().asAdmin().openNotifications()
+ .addGlobalNotification("ChangesOnMyIssue")
+ .addGlobalNotification("NewIssues")
+ .removeGlobalNotification("ChangesOnMyIssue");
+
+ nav.openNotifications()
+ .shouldHaveGlobalNotification("NewIssues")
+ .shouldNotHaveGlobalNotification("ChangesOnMyIssue");
+ }
+
private static void createUser(String login, String name, String email) {
adminWsClient.wsConnector().call(
new PostRequest("api/users/create")
diff --git a/it/it-tests/src/test/java/pageobjects/Navigation.java b/it/it-tests/src/test/java/pageobjects/Navigation.java
index e9c23d63f14..359cb5a8913 100644
--- a/it/it-tests/src/test/java/pageobjects/Navigation.java
+++ b/it/it-tests/src/test/java/pageobjects/Navigation.java
@@ -112,6 +112,10 @@ public class Navigation extends ExternalResource {
return open("/settings/server_id", ServerIdPage.class);
}
+ public NotificationsPage openNotifications() {
+ return open("/account/notifications", NotificationsPage.class);
+ }
+
public LoginPage openLogin() {
return open("/sessions/login", LoginPage.class);
}
diff --git a/it/it-tests/src/test/java/pageobjects/NotificationsPage.java b/it/it-tests/src/test/java/pageobjects/NotificationsPage.java
new file mode 100644
index 00000000000..a67e554e0e2
--- /dev/null
+++ b/it/it-tests/src/test/java/pageobjects/NotificationsPage.java
@@ -0,0 +1,118 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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;
+
+import static com.codeborne.selenide.Condition.cssClass;
+import static com.codeborne.selenide.Condition.visible;
+import static com.codeborne.selenide.Selenide.$;
+
+public class NotificationsPage {
+
+ private final String EMAIL = "EmailNotificationChannel";
+
+ public NotificationsPage() {
+ }
+
+ public NotificationsPage shouldHaveGlobalNotification(String type) {
+ return shouldHaveGlobalNotification(type, EMAIL);
+ }
+
+ public NotificationsPage shouldHaveGlobalNotification(String type, String channel) {
+ return shouldBeChecked(globalCheckboxSelector(type, channel));
+ }
+
+ public NotificationsPage shouldNotHaveGlobalNotification(String type) {
+ return shouldNotHaveGlobalNotification(type, EMAIL);
+ }
+
+ public NotificationsPage shouldNotHaveGlobalNotification(String type, String channel) {
+ return shouldNotBeChecked(globalCheckboxSelector(type, channel));
+ }
+
+ public NotificationsPage shouldHaveProjectNotification(String project, String type, String channel) {
+ return shouldBeChecked(projectCheckboxSelector(project, type, channel));
+ }
+
+ public NotificationsPage shouldNotHaveProjectNotification(String project, String type, String channel) {
+ return shouldNotBeChecked(projectCheckboxSelector(project, type, channel));
+ }
+
+ public NotificationsPage addGlobalNotification(String type) {
+ return addGlobalNotification(type, EMAIL);
+ }
+
+ public NotificationsPage addGlobalNotification(String type, String channel) {
+ shouldNotHaveGlobalNotification(type, channel);
+ toggleCheckbox(globalCheckboxSelector(type, channel));
+ shouldHaveGlobalNotification(type, channel);
+ return this;
+ }
+
+ public NotificationsPage removeGlobalNotification(String type) {
+ return removeGlobalNotification(type, EMAIL);
+ }
+
+ public NotificationsPage removeGlobalNotification(String type, String channel) {
+ shouldHaveGlobalNotification(type, channel);
+ toggleCheckbox(globalCheckboxSelector(type, channel));
+ shouldNotHaveGlobalNotification(type, channel);
+ return this;
+ }
+
+ public NotificationsPage addProjectNotification(String project, String type, String channel) {
+ shouldNotHaveProjectNotification(project, type, channel);
+ toggleCheckbox(projectCheckboxSelector(project, type, channel));
+ shouldHaveProjectNotification(project, type, channel);
+ return this;
+ }
+
+ public NotificationsPage removeProjectNotification(String project, String type, String channel) {
+ shouldHaveProjectNotification(project, type, channel);
+ toggleCheckbox(projectCheckboxSelector(project, type, channel));
+ shouldNotHaveProjectNotification(project, type, channel);
+ return this;
+ }
+
+ private String globalCheckboxSelector(String type, String channel) {
+ return "#global-notification-" + type + "-" + channel;
+ }
+
+ private String projectCheckboxSelector(String project, String type, String channel) {
+ return "#project-notification-" + project + "-" + type + "-" + channel;
+ }
+
+ private NotificationsPage shouldBeChecked(String selector) {
+ $(selector)
+ .shouldBe(visible)
+ .shouldHave(cssClass("icon-checkbox-checked"));
+ return this;
+ }
+
+ private NotificationsPage shouldNotBeChecked(String selector) {
+ $(selector)
+ .shouldBe(visible)
+ .shouldNotHave(cssClass("icon-checkbox-checked"));
+ return this;
+ }
+
+ private void toggleCheckbox(String selector) {
+ $(selector).click();
+ }
+}