source: moodle/trunk/fuentes/admin/tool/monitor/tests/behat/subscription.feature @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 8.7 KB
Line 
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        |
11      | Course 2 | C2        |
12    And the following "users" exist:
13      | username | firstname | lastname | email |
14      | teacher1 | Teacher | 1 | teacher1@asd.com |
15      | teacher2 | Teacher | 2 | teacher2@asd.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 "Event monitoring rules" node in "Site administration > Reports"
24    And I click on "Enable" "link"
25    And I am on homepage
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"
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"
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 "Course 1"
59    And I navigate to "Event monitoring" node in "My profile settings"
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 "Course 1"
68    And I navigate to "Event monitoring" node in "My profile settings"
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 navigate to "Event monitoring" node in "My profile settings"
81    And I set the field "Select a course" to "Site"
82    When I follow "Subscribe to rule \"New rule site level\""
83    Then I should see "Subscription successfully created"
84    And "#toolmonitorsubs_r0" "css_element" should exist
85
86  Scenario: Delete a subscription on site level
87    Given I log in as "admin"
88    And I navigate to "Event monitoring" node in "My profile settings"
89    And I set the field "Select a course" to "Site"
90    And I follow "Subscribe to rule \"New rule site level\""
91    And I should see "Subscription successfully created"
92    And "#toolmonitorsubs_r0" "css_element" should exist
93    When I click on "Delete subscription" "link" in the "New rule site level" "table_row"
94    And I should see "Are you sure you want to delete the subscription to the rule \"New rule site level\"?"
95    And I press "Continue"
96    Then I should see "Subscription successfully removed"
97    And "#toolmonitorsubs_r0" "css_element" should not exist
98
99  Scenario: Receiving notification on site level
100    Given I log in as "admin"
101    And I navigate to "Messaging" node in "My profile settings"
102    And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element"
103    And I press "Update profile"
104    And I am on homepage
105    And I follow "Course 1"
106    And I navigate to "Event monitoring" node in "My profile settings"
107    And I set the field "Select a course" to "Site"
108    And I follow "Subscribe to rule \"New rule site level\""
109    And I should see "Subscription successfully created"
110    And "#toolmonitorsubs_r0" "css_element" should exist
111    And I am on homepage
112    And I trigger cron
113    And I am on homepage
114    When I navigate to "Messages" node in "My profile"
115    And I follow "Do not reply to this email (1)"
116    Then I should see "The course was viewed."
117
118  Scenario: Receiving notification on course level
119    Given I log in as "teacher1"
120    And I navigate to "Messaging" node in "My profile settings"
121    And I click on "input[name^=tool_monitor_notification_loggedin]" "css_element"
122    And I press "Update profile"
123    And I am on homepage
124    And I follow "Course 1"
125    And I navigate to "Event monitoring" node in "My profile settings"
126    And I set the field "Select a course" to "Course 1"
127    And I follow "Subscribe to rule \"New rule course level\""
128    And I should see "Subscription successfully created"
129    And "#toolmonitorsubs_r0" "css_element" should exist
130    And I am on homepage
131    And I follow "Course 1"
132    And I trigger cron
133    And I am on homepage
134    When I navigate to "Messages" node in "My profile"
135    And I follow "Do not reply to this email (1)"
136    Then I should see "The course was viewed."
137
138  Scenario: Navigating via quick link to rules
139    Given I log in as "admin"
140    When I navigate to "Event monitoring" node in "My profile settings"
141    Then I should see "You can manage rules from the Event monitoring rules page."
142    And I follow "Event monitoring rules"
143    And I should see "You can subscribe to rules from the Event monitoring page."
144    And I log out
145    And I log in as "teacher1"
146    And I follow "Course 1"
147    And I navigate to "Event monitoring" node in "My profile settings"
148    And I should see "You can manage rules from the Event monitoring rules page."
149    And I follow "Event monitoring rules"
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 set the field "courseid" to "Site"
154    And I should not see "You can manage rules from the Event monitoring rules page."
155    And I log out
156    And I log in as "teacher2"
157    And I follow "Course 1"
158    And I navigate to "Event monitoring" node in "My profile settings"
159    And I should not see "You can manage rules the from the Event monitoring rules page."
160
161  Scenario: No manage rules link when user does not have permission
162    Given I log in as "teacher1"
163    When I follow "Course 1"
164    And I navigate to "Event monitoring" node in "My profile settings"
165    Then I should see "You can manage rules from the Event monitoring rules page."
166    And I log out
167    And I log in as "teacher2"
168    And I follow "Course 1"
169    And I navigate to "Event monitoring" node in "My profile settings"
170    And I should not see "You can manage rules from the Event monitoring rules page."
171    And I follow "Home"
172    And I follow "Course 2"
173    And I navigate to "Event monitoring" node in "My profile settings"
174    And I should see "You can manage rules from the Event monitoring rules page."
175    And I log out
176    And I log in as "teacher1"
177    And I follow "Course 2"
178    And I navigate to "Event monitoring" node in "My profile settings"
179    And I should not see "You can manage rules from the Event monitoring rules page."
Note: See TracBrowser for help on using the repository browser.