MDL-30811 forum: Update use of redirect to include message and type
[moodle.git] / mod / forum / tests / behat / discussion_subscriptions.feature
CommitLineData
ebfb73db
AN
1@mod @mod_forum
2Feature: A user can control their own subscription preferences for a discussion
3 In order to receive notifications for things I am interested in
4 As a user
5 I need to choose my discussion subscriptions
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | student1 | Student | One | student.one@example.com |
11 And the following "courses" exist:
12 | fullname | shortname | category |
13 | Course 1 | C1 | 0 |
14 And the following "course enrolments" exist:
15 | user | course | role |
16 | student1 | C1 | student |
17 And I log in as "admin"
221210e9 18 And I am on site homepage
ebfb73db
AN
19 And I follow "Course 1"
20 And I turn editing mode on
21
22 Scenario: An optional forum can have discussions subscribed to
23 Given I add a "Forum" to section "1" and I fill the form with:
24 | Forum name | Test forum name |
25 | Forum type | Standard forum for general use |
26 | Description | Test forum description |
27 | Subscription mode | Optional subscription |
28 And I add a new discussion to "Test forum name" forum with:
29 | Subject | Test post subject one |
30 | Message | Test post message one |
31 And I add a new discussion to "Test forum name" forum with:
32 | Subject | Test post subject two |
33 | Message | Test post message two |
34 And I log out
35 When I log in as "student1"
36 And I follow "Course 1"
37 And I follow "Test forum name"
38 Then I should see "Subscribe to this forum"
8271c89a
AN
39 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
40 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
41 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
d954b54f 42 And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db
AN
43 And I should see "Subscribe to this forum"
44 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 45 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db 46 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
d954b54f 47 And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db 48 And I should see "Subscribe to this forum"
8271c89a
AN
49 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
50 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
51 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
d954b54f 52 And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db
AN
53 And I should see "Subscribe to this forum"
54 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 55 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db 56 And I follow "Subscribe to this forum"
d954b54f 57 And I should see "Student One will be notified of new posts in 'Test forum name'"
ebfb73db
AN
58 And I should see "Unsubscribe from this forum"
59 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
60 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
61 And I follow "Unsubscribe from this forum"
d954b54f 62 And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
ebfb73db 63 And I should see "Subscribe to this forum"
8271c89a
AN
64 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
65 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
66
67 Scenario: An automatic subscription forum can have discussions unsubscribed from
68 Given I add a "Forum" to section "1" and I fill the form with:
69 | Forum name | Test forum name |
70 | Forum type | Standard forum for general use |
71 | Description | Test forum description |
72 | Subscription mode | Auto subscription |
73 And I add a new discussion to "Test forum name" forum with:
74 | Subject | Test post subject one |
75 | Message | Test post message one |
76 And I add a new discussion to "Test forum name" forum with:
77 | Subject | Test post subject two |
78 | Message | Test post message two |
79 And I log out
80 When I log in as "student1"
81 And I follow "Course 1"
82 And I follow "Test forum name"
83 Then I should see "Unsubscribe from this forum"
84 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
85 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
86 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
d954b54f 87 And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db 88 And I should see "Unsubscribe from this forum"
8271c89a 89 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
ebfb73db 90 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
8271c89a 91 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
d954b54f 92 And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db
AN
93 And I should see "Unsubscribe from this forum"
94 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
95 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
96 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
d954b54f 97 And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db 98 And I should see "Unsubscribe from this forum"
8271c89a 99 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
ebfb73db
AN
100 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
101 And I follow "Unsubscribe from this forum"
d954b54f 102 And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
ebfb73db 103 And I should see "Subscribe to this forum"
8271c89a
AN
104 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
105 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db 106 And I follow "Subscribe to this forum"
d954b54f 107 And I should see "Student One will be notified of new posts in 'Test forum name'"
ebfb73db
AN
108 And I should see "Unsubscribe from this forum"
109 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
110 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
111
112 Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
113 Given I add a "Forum" to section "1" and I fill the form with:
114 | Forum name | Test forum name |
115 | Forum type | Standard forum for general use |
116 | Description | Test forum description |
117 | Subscription mode | Optional subscription |
118 And I add a new discussion to "Test forum name" forum with:
119 | Subject | Test post subject one |
120 | Message | Test post message one |
121 And I add a new discussion to "Test forum name" forum with:
122 | Subject | Test post subject two |
123 | Message | Test post message two |
124 And I log out
125 And I log in as "student1"
126 And I follow "Course 1"
127 And I follow "Test forum name"
128 And I should see "Subscribe to this forum"
8271c89a
AN
129 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
130 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
131 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
d954b54f 132 And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db
AN
133 And I should see "Subscribe to this forum"
134 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 135 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
136 And I log out
137 And I log in as "admin"
221210e9 138 And I am on site homepage
ebfb73db
AN
139 And I follow "Course 1"
140 And I follow "Test forum name"
141 And I click on "Edit settings" "link" in the "Administration" "block"
142 And I set the following fields to these values:
143 | Subscription mode | Auto subscription |
144 And I press "Save and return to course"
145 And I log out
146 And I log in as "student1"
147 And I follow "Course 1"
148 And I follow "Test forum name"
149 And I should see "Unsubscribe from this forum"
150 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
151 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
152 When I follow "Unsubscribe from this forum"
d954b54f
AN
153 Then I should see "Student One will NOT be notified of new posts in 'Test forum name'"
154 And I should see "Subscribe to this forum"
ebfb73db 155 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 156 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
157
158 Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
159 Given I add a "Forum" to section "1" and I fill the form with:
160 | Forum name | Test forum name |
161 | Forum type | Standard forum for general use |
162 | Description | Test forum description |
163 | Subscription mode | Optional subscription |
164 And I add a new discussion to "Test forum name" forum with:
165 | Subject | Test post subject one |
166 | Message | Test post message one |
167 And I add a new discussion to "Test forum name" forum with:
168 | Subject | Test post subject two |
169 | Message | Test post message two |
170 And I log out
171 And I log in as "student1"
172 And I follow "Course 1"
173 And I follow "Test forum name"
174 And I should see "Subscribe to this forum"
8271c89a
AN
175 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
176 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
177 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
d954b54f 178 And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
ebfb73db
AN
179 And I should see "Subscribe to this forum"
180 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 181 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
182 And I log out
183 And I log in as "admin"
221210e9 184 And I am on site homepage
ebfb73db
AN
185 And I follow "Course 1"
186 And I follow "Test forum name"
187 And I click on "Edit settings" "link" in the "Administration" "block"
188 And I set the following fields to these values:
189 | Subscription mode | Auto subscription |
190 And I press "Save and return to course"
191 And I log out
192 And I log in as "student1"
193 And I follow "Course 1"
194 And I follow "Test forum name"
195 And I should see "Unsubscribe from this forum"
196 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
197 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
198 When I follow "Unsubscribe from this forum"
d954b54f 199 And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
ebfb73db
AN
200 Then I should see "Subscribe to this forum"
201 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 202 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
203
204 Scenario: An optional forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
205 Given I add a "Forum" to section "1" and I fill the form with:
206 | Forum name | Test forum name |
207 | Forum type | Standard forum for general use |
208 | Description | Test forum description |
209 | Subscription mode | Optional subscription |
210 And I add a new discussion to "Test forum name" forum with:
211 | Subject | Test post subject one |
212 | Message | Test post message one |
213 And I add a new discussion to "Test forum name" forum with:
214 | Subject | Test post subject two |
215 | Message | Test post message two |
216 And I log out
217 When I log in as "student1"
218 And I follow "Course 1"
219 And I follow "Test forum name"
220 And I should see "Subscribe to this forum"
221 And I reply "Test post subject one" post from "Test forum name" forum with:
222 | Subject | Reply 1 to discussion 1 |
223 | Message | Discussion contents 1, second message |
be773fd6 224 | Discussion subscription | 1 |
ebfb73db
AN
225 And I reply "Test post subject two" post from "Test forum name" forum with:
226 | Subject | Reply 1 to discussion 1 |
227 | Message | Discussion contents 1, second message |
be773fd6 228 | Discussion subscription | 0 |
ebfb73db
AN
229 And I follow "Test forum name"
230 Then "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 231 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
232 And I follow "Test post subject one"
233 And I follow "Reply"
ea2b511d 234 And the field "Discussion subscription" matches value "Send me notifications of new posts in this discussion"
ebfb73db
AN
235 And I follow "Test forum name"
236 And I follow "Test post subject two"
237 And I follow "Reply"
f7dd19f0 238 And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
ebfb73db
AN
239
240 Scenario: An automatic forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
241 Given I add a "Forum" to section "1" and I fill the form with:
242 | Forum name | Test forum name |
243 | Forum type | Standard forum for general use |
244 | Description | Test forum description |
245 | Subscription mode | Auto subscription |
246 And I add a new discussion to "Test forum name" forum with:
247 | Subject | Test post subject one |
248 | Message | Test post message one |
249 And I add a new discussion to "Test forum name" forum with:
250 | Subject | Test post subject two |
251 | Message | Test post message two |
252 And I log out
253 When I log in as "student1"
254 And I follow "Course 1"
255 And I follow "Test forum name"
256 And I should see "Unsubscribe from this forum"
257 And I reply "Test post subject one" post from "Test forum name" forum with:
258 | Subject | Reply 1 to discussion 1 |
259 | Message | Discussion contents 1, second message |
be773fd6 260 | Discussion subscription | 1 |
ebfb73db
AN
261 And I reply "Test post subject two" post from "Test forum name" forum with:
262 | Subject | Reply 1 to discussion 1 |
263 | Message | Discussion contents 1, second message |
be773fd6 264 | Discussion subscription | 0 |
ebfb73db
AN
265 And I follow "Test forum name"
266 Then "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 267 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
268 And I follow "Test post subject one"
269 And I follow "Reply"
ea2b511d 270 And the field "Discussion subscription" matches value "Send me notifications of new posts in this discussion"
ebfb73db
AN
271 And I follow "Test forum name"
272 And I follow "Test post subject two"
273 And I follow "Reply"
f7dd19f0 274 And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
12cf8140
DC
275
276 Scenario: A guest should not be able to subscribe to a discussion
221210e9 277 Given I am on site homepage
12cf8140
DC
278 And I add a "Forum" to section "1" and I fill the form with:
279 | Forum name | Test forum name |
280 | Forum type | Standard forum for general use |
281 | Description | Test forum description |
282 And I add a new discussion to "Test forum name" forum with:
283 | Subject | Test post subject one |
284 | Message | Test post message one |
285 And I log out
286 When I log in as "guest"
287 And I follow "Test forum name"
8271c89a 288 Then "You are not subscribed to this discussion. Click to subscribe." "link" should not exist in the "Test post subject one" "table_row"
12cf8140
DC
289 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist in the "Test post subject one" "table_row"
290 And I follow "Test post subject one"
8271c89a 291 And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist
12cf8140
DC
292 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist
293
294 Scenario: A user who is not logged in should not be able to subscribe to a discussion
221210e9 295 Given I am on site homepage
12cf8140
DC
296 And I add a "Forum" to section "1" and I fill the form with:
297 | Forum name | Test forum name |
298 | Forum type | Standard forum for general use |
299 | Description | Test forum description |
300 And I add a new discussion to "Test forum name" forum with:
301 | Subject | Test post subject one |
302 | Message | Test post message one |
303 And I log out
304 When I follow "Test forum name"
8271c89a 305 Then "You are not subscribed to this discussion. Click to subscribe." "link" should not exist in the "Test post subject one" "table_row"
12cf8140
DC
306 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist in the "Test post subject one" "table_row"
307 And I follow "Test post subject one"
8271c89a 308 And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist
12cf8140 309 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist
62208137
AN
310
311 Scenario: A user can toggle their subscription preferences when viewing a discussion
312 Given I add a "Forum" to section "1" and I fill the form with:
313 | Forum name | Test forum name |
314 | Forum type | Standard forum for general use |
315 | Description | Test forum description |
316 | Subscription mode | Optional subscription |
317 And I add a new discussion to "Test forum name" forum with:
318 | Subject | Test post subject one |
319 | Message | Test post message one |
320 And I log out
321 And I log in as "student1"
322 And I follow "Course 1"
323 And I follow "Test forum name"
324 When I follow "Test post subject one"
325 Then I should see "Subscribe to this forum"
326 And I should see "Subscribe to this discussion"
327 And I follow "Subscribe to this forum"
d954b54f 328 And I should see "Student One will be notified of new posts in 'Test forum name'"
62208137
AN
329 And I follow "Test post subject one"
330 And I should see "Unsubscribe from this forum"
331 And I should see "Unsubscribe from this discussion"
332 And I follow "Unsubscribe from this discussion"
d954b54f 333 And I should see "Student One will NOT be notified of new posts in 'Test post subject one' of 'Test forum name'"
62208137
AN
334 And I follow "Test post subject one"
335 And I should see "Unsubscribe from this forum"
336 And I should see "Subscribe to this discussion"
337 And I follow "Unsubscribe from this forum"
d954b54f 338 And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
62208137
AN
339 And I follow "Test post subject one"
340 And I should see "Subscribe to this forum"
341 And I should see "Subscribe to this discussion"
342 And I follow "Subscribe to this discussion"
d954b54f 343 And I should see "Student One will be notified of new posts in 'Test post subject one' of 'Test forum name'"
62208137
AN
344 And I should see "Subscribe to this forum"
345 And I should see "Unsubscribe from this discussion"
346 And I follow "Subscribe to this forum"
d954b54f 347 And I should see "Student One will be notified of new posts in 'Test forum name'"
62208137
AN
348 And I follow "Test post subject one"
349 And I should see "Unsubscribe from this forum"
350 And I should see "Unsubscribe from this discussion"
351 And I follow "Unsubscribe from this forum"
d954b54f 352 And I should see "Student One will NOT be notified of new posts in 'Test forum name'"
62208137
AN
353 And I follow "Test post subject one"
354 And I should see "Subscribe to this forum"
355 And I should see "Subscribe to this discussion"