MDL-56299 behat: Popover doesn't work with phantomjs
[moodle.git] / admin / tool / monitor / tests / behat / subscription.feature
CommitLineData
77098e6d
SL
1@javascript @tool @tool_monitor @tool_monitor_subscriptions
2Feature: tool_monitor_subscriptions
3 In order to monitor events and receive notifications
4 As an user
5 I need to create a new rule, subscribe to it, receive notification and delete subscription
6
7 Background:
8 Given the following "courses" exist:
9 | fullname | shortname |
10 | Course 1 | C1 |
8f6b6982 11 | Course 2 | C2 |
77098e6d
SL
12 And the following "users" exist:
13 | username | firstname | lastname | email |
0fe86bbd
RT
14 | teacher1 | Teacher | 1 | teacher1@example.com |
15 | teacher2 | Teacher | 2 | teacher2@example.com |
77098e6d
SL
16 And the following "course enrolments" exist:
17 | user | course | role |
18 | teacher1 | C1 | editingteacher |
8f6b6982
JO
19 | teacher1 | C2 | teacher |
20 | teacher2 | C1 | teacher |
21 | teacher2 | C2 | editingteacher |
8ad2de40 22 And I log in as "admin"
236a1f8d
AA
23 And I navigate to "Event monitoring rules" node in "Site administration > Reports"
24 And I click on "Enable" "link"
8e94fae9 25 And I am on site homepage
8ad2de40
MN
26 And I follow "Course 1"
27 And I navigate to "Event monitoring rules" node in "Course administration > Reports"
28 And I press "Add a new rule"
29 And I set the following fields to these values:
30 | name | New rule course level |
31 | plugin | Core |
32 | eventname | Course viewed |
33 | id_description | I want a rule to monitor when a course is viewed. |
34 | frequency | 1 |
35 | minutes | 1 |
36 | Notification message | The course was viewed. {modulelink} |
37 And I press "Save changes"
38 And I navigate to "Event monitoring rules" node in "Site administration > Reports"
39 And I press "Add a new rule"
40 And I set the following fields to these values:
41 | name | New rule site level |
42 | plugin | Core |
43 | eventname | Course viewed |
44 | id_description | I want a rule to monitor when a course is viewed. |
45 | frequency | 1 |
46 | minutes | 1 |
47 | Notification message | The course was viewed. {modulelink} |
48 And I press "Save changes"
8f6b6982
JO
49 And I navigate to "Define roles" node in "Site administration > Users > Permissions"
50 And I follow "Non-editing teacher"
51 And I press "Edit"
52 And I click on "tool/monitor:managerules" "checkbox"
53 And I press "Save changes"
8ad2de40 54 And I log out
77098e6d
SL
55
56 Scenario: Subscribe to a rule on course level
57 Given I log in as "teacher1"
4887d152 58 And I follow "Preferences" in the user menu
8e94fae9 59 And I follow "Event monitoring"
8ad2de40 60 And I set the field "Select a course" to "Course 1"
0907f49b 61 When I follow "Subscribe to rule \"New rule course level\""
8ad2de40
MN
62 Then I should see "Subscription successfully created"
63 And "#toolmonitorsubs_r0" "css_element" should exist
77098e6d
SL
64
65 Scenario: Delete a subscription on course level
66 Given I log in as "teacher1"
4887d152 67 And I follow "Preferences" in the user menu
8e94fae9 68 And I follow "Event monitoring"
8ad2de40 69 And I set the field "Select a course" to "Course 1"
0907f49b 70 And I follow "Subscribe to rule \"New rule course level\""
8ad2de40
MN
71 And I should see "Subscription successfully created"
72 When I click on "Delete subscription" "link" in the "New rule course level" "table_row"
8145ab33 73 And I should see "Are you sure you want to delete the subscription to the rule \"New rule course level\"?"
8ad2de40
MN
74 And I press "Continue"
75 Then I should see "Subscription successfully removed"
76 And "#toolmonitorsubs_r0" "css_element" should not exist
77098e6d
SL
77
78 Scenario: Subscribe to a rule on site level
79 Given I log in as "admin"
4887d152 80 And I follow "Preferences" in the user menu
8e94fae9
AG
81 And I follow "Event monitoring"
82 And I set the field "Select a course" to "Acceptance test site"
0907f49b 83 When I follow "Subscribe to rule \"New rule site level\""
8ad2de40
MN
84 Then I should see "Subscription successfully created"
85 And "#toolmonitorsubs_r0" "css_element" should exist
77098e6d
SL
86
87 Scenario: Delete a subscription on site level
88 Given I log in as "admin"
4887d152 89 And I follow "Preferences" in the user menu
8e94fae9
AG
90 And I follow "Event monitoring"
91 And I set the field "Select a course" to "Acceptance test site"
0907f49b 92 And I follow "Subscribe to rule \"New rule site level\""
8ad2de40
MN
93 And I should see "Subscription successfully created"
94 And "#toolmonitorsubs_r0" "css_element" should exist
95 When I click on "Delete subscription" "link" in the "New rule site level" "table_row"
8145ab33 96 And I should see "Are you sure you want to delete the subscription to the rule \"New rule site level\"?"
8ad2de40
MN
97 And I press "Continue"
98 Then I should see "Subscription successfully removed"
99 And "#toolmonitorsubs_r0" "css_element" should not exist
77098e6d 100
d4b28e0b 101 @_bug_phantomjs
77098e6d
SL
102 Scenario: Receiving notification on site level
103 Given I log in as "admin"
4887d152 104 And I follow "Preferences" in the user menu
16f91ae1
MN
105 And I click on "Notification preferences" "link" in the "#page-content" "css_element"
106 And I click on ".preference-state" "css_element" in the "Notifications of rule subscriptions" "table_row"
107 And I wait until the page is ready
4887d152 108 And I follow "Preferences" in the user menu
8e94fae9
AG
109 And I follow "Event monitoring"
110 And I set the field "Select a course" to "Acceptance test site"
0907f49b 111 And I follow "Subscribe to rule \"New rule site level\""
8ad2de40
MN
112 And I should see "Subscription successfully created"
113 And "#toolmonitorsubs_r0" "css_element" should exist
8e94fae9 114 And I am on site homepage
8ad2de40 115 And I trigger cron
8e94fae9 116 And I am on site homepage
16f91ae1
MN
117 When I click on ".popover-region-notifications" "css_element"
118 And I click on "View more" "link" in the ".popover-region-notifications" "css_element"
119 Then I should see "New rule site level"
120 And I should see "The course was viewed"
77098e6d 121
d4b28e0b 122 @_bug_phantomjs
77098e6d
SL
123 Scenario: Receiving notification on course level
124 Given I log in as "teacher1"
4887d152 125 And I follow "Preferences" in the user menu
16f91ae1
MN
126 And I click on "Notification preferences" "link" in the "#page-content" "css_element"
127 And I click on ".preference-state" "css_element" in the "Notifications of rule subscriptions" "table_row"
128 And I wait until the page is ready
4887d152 129 And I follow "Preferences" in the user menu
8e94fae9 130 And I follow "Event monitoring"
8ad2de40 131 And I set the field "Select a course" to "Course 1"
0907f49b 132 And I follow "Subscribe to rule \"New rule course level\""
8ad2de40
MN
133 And I should see "Subscription successfully created"
134 And "#toolmonitorsubs_r0" "css_element" should exist
8e94fae9 135 And I am on site homepage
8ad2de40
MN
136 And I follow "Course 1"
137 And I trigger cron
8e94fae9 138 And I am on site homepage
16f91ae1
MN
139 When I click on ".popover-region-notifications" "css_element"
140 And I click on "View more" "link" in the ".popover-region-notifications" "css_element"
141 Then I should see "New rule course level"
142 And I should see "The course was viewed"
6a6dd57c
JO
143
144 Scenario: Navigating via quick link to rules
145 Given I log in as "admin"
4887d152 146 And I follow "Preferences" in the user menu
8e94fae9
AG
147 When I follow "Event monitoring"
148 And I set the field "Select a course" to "Course 1"
8ad2de40
MN
149 Then I should see "You can manage rules from the Event monitoring rules page."
150 And I follow "Event monitoring rules"
8ad2de40
MN
151 And I should see "You can subscribe to rules from the Event monitoring page."
152 And I log out
153 And I log in as "teacher1"
4887d152 154 And I follow "Preferences" in the user menu
8e94fae9
AG
155 And I follow "Event monitoring"
156 And I set the field "Select a course" to "Course 1"
8ad2de40 157 And I should see "You can manage rules from the Event monitoring rules page."
8f6b6982
JO
158 And I follow "Event monitoring rules"
159 And I should see "You can subscribe to rules from the Event monitoring page."
160 And I click on "//a[text()='Event monitoring']" "xpath_element"
161 And the field "courseid" matches value "Course 1"
a19c4b8d
AG
162 And I follow "Preferences" in the user menu
163 And I follow "Event monitoring"
8f6b6982
JO
164 And I should not see "You can manage rules from the Event monitoring rules page."
165 And I log out
166 And I log in as "teacher2"
4887d152 167 And I follow "Preferences" in the user menu
8e94fae9
AG
168 And I follow "Event monitoring"
169 And I set the field "Select a course" to "Course 1"
8f6b6982
JO
170 And I should not see "You can manage rules the from the Event monitoring rules page."
171
172 Scenario: No manage rules link when user does not have permission
8e94fae9
AG
173 Given I log in as "admin"
174 And I set the following system permissions of "Non-editing teacher" role:
175 | tool/monitor:managerules | Prohibit |
176 And I log out
177 And I log in as "teacher1"
4887d152 178 And I follow "Preferences" in the user menu
8e94fae9
AG
179 And I follow "Event monitoring"
180 When I set the field "Select a course" to "Course 1"
8f6b6982 181 Then I should see "You can manage rules from the Event monitoring rules page."
8e94fae9
AG
182 And I set the field "Select a course" to "Course 2"
183 And I should not see "You can manage rules from the Event monitoring rules page."
8f6b6982
JO
184 And I log out
185 And I log in as "teacher2"
4887d152 186 And I follow "Preferences" in the user menu
8e94fae9
AG
187 And I follow "Event monitoring"
188 And I set the field "Select a course" to "Course 1"
8f6b6982 189 And I should not see "You can manage rules from the Event monitoring rules page."
8e94fae9 190 And I set the field "Select a course" to "Course 2"
8f6b6982 191 And I should see "You can manage rules from the Event monitoring rules page."