1 |
efrain |
1 |
@javascript @tool @tool_monitor @tool_monitor_subscriptions
|
|
|
2 |
Feature: 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 |
|
|
|
11 |
| Course 2 | C2 |
|
|
|
12 |
And the following "users" exist:
|
|
|
13 |
| username | firstname | lastname | email |
|
|
|
14 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
15 |
| teacher2 | Teacher | 2 | teacher2@example.com |
|
|
|
16 |
And the following "course enrolments" exist:
|
|
|
17 |
| user | course | role |
|
|
|
18 |
| teacher1 | C1 | editingteacher |
|
|
|
19 |
| teacher1 | C2 | teacher |
|
|
|
20 |
| teacher2 | C1 | teacher |
|
|
|
21 |
| teacher2 | C2 | editingteacher |
|
|
|
22 |
And I log in as "admin"
|
|
|
23 |
And I navigate to "Reports > Event monitoring rules" in site administration
|
|
|
24 |
And I click on "Enable" "link"
|
|
|
25 |
And I am on "Course 1" course homepage
|
|
|
26 |
And I navigate to "Reports" in current page administration
|
|
|
27 |
And I click on "Event monitoring rules" "link"
|
|
|
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 | Subsystem (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 "Reports > Event monitoring rules" in site administration
|
|
|
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 | Subsystem (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"
|
|
|
49 |
And I navigate to "Users > Permissions > Define roles" in site administration
|
|
|
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"
|
|
|
54 |
And I log out
|
|
|
55 |
|
|
|
56 |
Scenario: Subscribe to a rule on course level
|
|
|
57 |
Given I log in as "teacher1"
|
|
|
58 |
And I follow "Preferences" in the user menu
|
|
|
59 |
And I follow "Event monitoring"
|
|
|
60 |
And I set the field "Select a course" to "Course 1"
|
|
|
61 |
When I follow "Subscribe to rule \"New rule course level\""
|
|
|
62 |
Then I should see "Subscription successfully created"
|
|
|
63 |
And "#toolmonitorsubs_r0" "css_element" should exist
|
|
|
64 |
|
|
|
65 |
Scenario: Delete a subscription on course level
|
|
|
66 |
Given I log in as "teacher1"
|
|
|
67 |
And I follow "Preferences" in the user menu
|
|
|
68 |
And I follow "Event monitoring"
|
|
|
69 |
And I set the field "Select a course" to "Course 1"
|
|
|
70 |
And I follow "Subscribe to rule \"New rule course level\""
|
|
|
71 |
And I should see "Subscription successfully created"
|
|
|
72 |
When I click on "Delete subscription" "link" in the "New rule course level" "table_row"
|
|
|
73 |
And I should see "Are you sure you want to delete the subscription to the rule \"New rule course level\"?"
|
|
|
74 |
And I press "Continue"
|
|
|
75 |
Then I should see "Subscription successfully removed"
|
|
|
76 |
And "#toolmonitorsubs_r0" "css_element" should not exist
|
|
|
77 |
|
|
|
78 |
Scenario: Subscribe to a rule on site level
|
|
|
79 |
Given I log in as "admin"
|
|
|
80 |
And I follow "Preferences" in the user menu
|
|
|
81 |
And I follow "Event monitoring"
|
|
|
82 |
And I set the field "Select a course" to "Acceptance test site"
|
|
|
83 |
When I follow "Subscribe to rule \"New rule site level\""
|
|
|
84 |
Then I should see "Subscription successfully created"
|
|
|
85 |
And "#toolmonitorsubs_r0" "css_element" should exist
|
|
|
86 |
|
|
|
87 |
Scenario: Delete a subscription on site level
|
|
|
88 |
Given I log in as "admin"
|
|
|
89 |
And I follow "Preferences" in the user menu
|
|
|
90 |
And I follow "Event monitoring"
|
|
|
91 |
And I set the field "Select a course" to "Acceptance test site"
|
|
|
92 |
And I follow "Subscribe to rule \"New rule site level\""
|
|
|
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"
|
|
|
96 |
And I should see "Are you sure you want to delete the subscription to the rule \"New rule site level\"?"
|
|
|
97 |
And I press "Continue"
|
|
|
98 |
Then I should see "Subscription successfully removed"
|
|
|
99 |
And "#toolmonitorsubs_r0" "css_element" should not exist
|
|
|
100 |
|
|
|
101 |
@_bug_phantomjs
|
|
|
102 |
Scenario: Receiving notification on site level
|
|
|
103 |
Given I log in as "admin"
|
|
|
104 |
And I follow "Preferences" in the user menu
|
|
|
105 |
And I follow "Event monitoring"
|
|
|
106 |
And I set the field "Select a course" to "Acceptance test site"
|
|
|
107 |
And I follow "Subscribe to rule \"New rule site level\""
|
|
|
108 |
And I should see "Subscription successfully created"
|
|
|
109 |
And "#toolmonitorsubs_r0" "css_element" should exist
|
|
|
110 |
And I am on site homepage
|
|
|
111 |
And I trigger cron
|
|
|
112 |
And I am on site homepage
|
|
|
113 |
When I click on ".popover-region-notifications" "css_element"
|
|
|
114 |
And I click on "View full notification" "link" in the ".popover-region-notifications" "css_element"
|
|
|
115 |
Then I should see "New rule site level"
|
|
|
116 |
And I should see "The course was viewed"
|
|
|
117 |
|
|
|
118 |
@_bug_phantomjs
|
|
|
119 |
Scenario: Receiving notification on course level
|
|
|
120 |
Given I log in as "teacher1"
|
|
|
121 |
And I follow "Preferences" in the user menu
|
|
|
122 |
And I follow "Event monitoring"
|
|
|
123 |
And I set the field "Select a course" to "Course 1"
|
|
|
124 |
And I follow "Subscribe to rule \"New rule course level\""
|
|
|
125 |
And I should see "Subscription successfully created"
|
|
|
126 |
And "#toolmonitorsubs_r0" "css_element" should exist
|
|
|
127 |
And I am on "Course 1" course homepage
|
|
|
128 |
And I trigger cron
|
|
|
129 |
And I am on site homepage
|
|
|
130 |
When I click on ".popover-region-notifications" "css_element"
|
|
|
131 |
And I click on "View full notification" "link" in the ".popover-region-notifications" "css_element"
|
|
|
132 |
Then I should see "New rule course level"
|
|
|
133 |
And I should see "The course was viewed"
|
|
|
134 |
|
|
|
135 |
Scenario: Navigating via quick link to rules
|
|
|
136 |
Given I log in as "admin"
|
|
|
137 |
And I follow "Preferences" in the user menu
|
|
|
138 |
When I follow "Event monitoring"
|
|
|
139 |
And I set the field "Select a course" to "Course 1"
|
|
|
140 |
Then I should see "You can manage rules from the Event monitoring rules page."
|
|
|
141 |
And I click on "Event monitoring rules" "link" in the "region-main" "region"
|
|
|
142 |
And I should see "You can subscribe to rules from the Event monitoring page."
|
|
|
143 |
And I log out
|
|
|
144 |
And I log in as "teacher1"
|
|
|
145 |
And I follow "Preferences" in the user menu
|
|
|
146 |
And I follow "Event monitoring"
|
|
|
147 |
And I set the field "Select a course" to "Course 1"
|
|
|
148 |
And I should see "You can manage rules from the Event monitoring rules page."
|
|
|
149 |
And I click on "Event monitoring rules" "link" in the "region-main" "region"
|
|
|
150 |
And I should see "You can subscribe to rules from the Event monitoring page."
|
|
|
151 |
And I click on "//a[text()='Event monitoring']" "xpath_element"
|
|
|
152 |
And the field "courseid" matches value "Course 1"
|
|
|
153 |
And I follow "Preferences" in the user menu
|
|
|
154 |
And I follow "Event monitoring"
|
|
|
155 |
And I should not see "You can manage rules from the Event monitoring rules page."
|
|
|
156 |
And I log out
|
|
|
157 |
And I log in as "teacher2"
|
|
|
158 |
And I follow "Preferences" in the user menu
|
|
|
159 |
And I follow "Event monitoring"
|
|
|
160 |
And I set the field "Select a course" to "Course 1"
|
|
|
161 |
And I should not see "You can manage rules the from the Event monitoring rules page."
|
|
|
162 |
|
|
|
163 |
Scenario: No manage rules link when user does not have permission
|
|
|
164 |
Given the following "role capability" exists:
|
|
|
165 |
| role | teacher |
|
|
|
166 |
| tool/monitor:managerules | prohibit |
|
|
|
167 |
And I log in as "teacher1"
|
|
|
168 |
And I follow "Preferences" in the user menu
|
|
|
169 |
And I follow "Event monitoring"
|
|
|
170 |
When I set the field "Select a course" to "Course 1"
|
|
|
171 |
Then I should see "You can manage rules from the Event monitoring rules page."
|
|
|
172 |
And I set the field "Select a course" to "Course 2"
|
|
|
173 |
And I should not see "You can manage rules from the Event monitoring rules page."
|
|
|
174 |
And I log out
|
|
|
175 |
And I log in as "teacher2"
|
|
|
176 |
And I follow "Preferences" in the user menu
|
|
|
177 |
And I follow "Event monitoring"
|
|
|
178 |
And I set the field "Select a course" to "Course 1"
|
|
|
179 |
And I should not see "You can manage rules from the Event monitoring rules page."
|
|
|
180 |
And I set the field "Select a course" to "Course 2"
|
|
|
181 |
And I should see "You can manage rules from the Event monitoring rules page."
|