MDL-48035 Fix more Behat tests regressions after merging en_fix strings
[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"
18 And I follow "Course 1"
19 And I turn editing mode on
20
21 Scenario: An optional forum can have discussions subscribed to
22 Given I add a "Forum" to section "1" and I fill the form with:
23 | Forum name | Test forum name |
24 | Forum type | Standard forum for general use |
25 | Description | Test forum description |
26 | Subscription mode | Optional subscription |
27 And I add a new discussion to "Test forum name" forum with:
28 | Subject | Test post subject one |
29 | Message | Test post message one |
30 And I add a new discussion to "Test forum name" forum with:
31 | Subject | Test post subject two |
32 | Message | Test post message two |
33 And I log out
34 When I log in as "student1"
35 And I follow "Course 1"
36 And I follow "Test forum name"
37 Then I should see "Subscribe to this forum"
8271c89a
AN
38 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
39 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
40 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
ebfb73db
AN
41 And I follow "Continue"
42 And I should see "Subscribe to this forum"
43 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 44 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
45 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
46 And I follow "Continue"
47 And I should see "Subscribe to this forum"
8271c89a
AN
48 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
49 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
50 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
ebfb73db
AN
51 And I follow "Continue"
52 And I should see "Subscribe to this forum"
53 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 54 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
55 And I follow "Subscribe to this forum"
56 And I follow "Continue"
57 And I should see "Unsubscribe from this forum"
58 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
59 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
60 And I follow "Unsubscribe from this forum"
61 And I follow "Continue"
62 And I should see "Subscribe to this forum"
8271c89a
AN
63 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
64 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
65
66 Scenario: An automatic subscription forum can have discussions unsubscribed from
67 Given I add a "Forum" to section "1" and I fill the form with:
68 | Forum name | Test forum name |
69 | Forum type | Standard forum for general use |
70 | Description | Test forum description |
71 | Subscription mode | Auto subscription |
72 And I add a new discussion to "Test forum name" forum with:
73 | Subject | Test post subject one |
74 | Message | Test post message one |
75 And I add a new discussion to "Test forum name" forum with:
76 | Subject | Test post subject two |
77 | Message | Test post message two |
78 And I log out
79 When I log in as "student1"
80 And I follow "Course 1"
81 And I follow "Test forum name"
82 Then I should see "Unsubscribe from this forum"
83 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
84 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
85 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
86 And I follow "Continue"
87 And I should see "Unsubscribe from this forum"
8271c89a 88 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
ebfb73db 89 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
8271c89a 90 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
ebfb73db
AN
91 And I follow "Continue"
92 And I should see "Unsubscribe from this forum"
93 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
94 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
95 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject one" "table_row"
96 And I follow "Continue"
97 And I should see "Unsubscribe from this forum"
8271c89a 98 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
ebfb73db
AN
99 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
100 And I follow "Unsubscribe from this forum"
101 And I follow "Continue"
102 And I should see "Subscribe to this forum"
8271c89a
AN
103 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
104 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
105 And I follow "Subscribe to this forum"
106 And I follow "Continue"
107 And I should see "Unsubscribe from this forum"
108 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
109 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
110
111 Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
112 Given I add a "Forum" to section "1" and I fill the form with:
113 | Forum name | Test forum name |
114 | Forum type | Standard forum for general use |
115 | Description | Test forum description |
116 | Subscription mode | Optional subscription |
117 And I add a new discussion to "Test forum name" forum with:
118 | Subject | Test post subject one |
119 | Message | Test post message one |
120 And I add a new discussion to "Test forum name" forum with:
121 | Subject | Test post subject two |
122 | Message | Test post message two |
123 And I log out
124 And I log in as "student1"
125 And I follow "Course 1"
126 And I follow "Test forum name"
127 And I should see "Subscribe to this forum"
8271c89a
AN
128 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
129 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
130 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
ebfb73db
AN
131 And I follow "Continue"
132 And I should see "Subscribe to this forum"
133 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 134 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
135 And I log out
136 And I log in as "admin"
137 And I follow "Course 1"
138 And I follow "Test forum name"
139 And I click on "Edit settings" "link" in the "Administration" "block"
140 And I set the following fields to these values:
141 | Subscription mode | Auto subscription |
142 And I press "Save and return to course"
143 And I log out
144 And I log in as "student1"
145 And I follow "Course 1"
146 And I follow "Test forum name"
147 And I should see "Unsubscribe from this forum"
148 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
149 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
150 When I follow "Unsubscribe from this forum"
151 And I follow "Continue"
152 Then I should see "Subscribe to this forum"
153 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 154 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
155
156 Scenario: A user does not lose their preferences when a forum is switch from optional to automatic
157 Given I add a "Forum" to section "1" and I fill the form with:
158 | Forum name | Test forum name |
159 | Forum type | Standard forum for general use |
160 | Description | Test forum description |
161 | Subscription mode | Optional subscription |
162 And I add a new discussion to "Test forum name" forum with:
163 | Subject | Test post subject one |
164 | Message | Test post message one |
165 And I add a new discussion to "Test forum name" forum with:
166 | Subject | Test post subject two |
167 | Message | Test post message two |
168 And I log out
169 And I log in as "student1"
170 And I follow "Course 1"
171 And I follow "Test forum name"
172 And I should see "Subscribe to this forum"
8271c89a
AN
173 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject one" "table_row"
174 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
175 And I click on "You are not subscribed to this discussion. Click to subscribe." "link" in the "Test post subject one" "table_row"
ebfb73db
AN
176 And I follow "Continue"
177 And I should see "Subscribe to this forum"
178 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 179 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
180 And I log out
181 And I log in as "admin"
182 And I follow "Course 1"
183 And I follow "Test forum name"
184 And I click on "Edit settings" "link" in the "Administration" "block"
185 And I set the following fields to these values:
186 | Subscription mode | Auto subscription |
187 And I press "Save and return to course"
188 And I log out
189 And I log in as "student1"
190 And I follow "Course 1"
191 And I follow "Test forum name"
192 And I should see "Unsubscribe from this forum"
193 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
194 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject two" "table_row"
195 When I follow "Unsubscribe from this forum"
196 And I follow "Continue"
197 Then I should see "Subscribe to this forum"
198 And "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 199 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
200
201 Scenario: An optional forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
202 Given I add a "Forum" to section "1" and I fill the form with:
203 | Forum name | Test forum name |
204 | Forum type | Standard forum for general use |
205 | Description | Test forum description |
206 | Subscription mode | Optional subscription |
207 And I add a new discussion to "Test forum name" forum with:
208 | Subject | Test post subject one |
209 | Message | Test post message one |
210 And I add a new discussion to "Test forum name" forum with:
211 | Subject | Test post subject two |
212 | Message | Test post message two |
213 And I log out
214 When I log in as "student1"
215 And I follow "Course 1"
216 And I follow "Test forum name"
217 And I should see "Subscribe to this forum"
218 And I reply "Test post subject one" post from "Test forum name" forum with:
219 | Subject | Reply 1 to discussion 1 |
220 | Message | Discussion contents 1, second message |
6887e2e5 221 | Discussion subscription | I don't want to be notified of new posts in this discussion |
ebfb73db
AN
222 And I reply "Test post subject two" post from "Test forum name" forum with:
223 | Subject | Reply 1 to discussion 1 |
224 | Message | Discussion contents 1, second message |
f7dd19f0 225 | Discussion subscription | I don't want to be notified of new posts in this discussion |
ebfb73db
AN
226 And I follow "Test forum name"
227 Then "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 228 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
229 And I follow "Test post subject one"
230 And I follow "Reply"
6887e2e5 231 And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
ebfb73db
AN
232 And I follow "Test forum name"
233 And I follow "Test post subject two"
234 And I follow "Reply"
f7dd19f0 235 And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
ebfb73db
AN
236
237 Scenario: An automatic forum prompts a user to subscribe to a discussion when posting unless they have already chosen not to subscribe
238 Given I add a "Forum" to section "1" and I fill the form with:
239 | Forum name | Test forum name |
240 | Forum type | Standard forum for general use |
241 | Description | Test forum description |
242 | Subscription mode | Auto subscription |
243 And I add a new discussion to "Test forum name" forum with:
244 | Subject | Test post subject one |
245 | Message | Test post message one |
246 And I add a new discussion to "Test forum name" forum with:
247 | Subject | Test post subject two |
248 | Message | Test post message two |
249 And I log out
250 When I log in as "student1"
251 And I follow "Course 1"
252 And I follow "Test forum name"
253 And I should see "Unsubscribe from this forum"
254 And I reply "Test post subject one" post from "Test forum name" forum with:
255 | Subject | Reply 1 to discussion 1 |
256 | Message | Discussion contents 1, second message |
6887e2e5 257 | Discussion subscription | I don't want to be notified of new posts in this discussion |
ebfb73db
AN
258 And I reply "Test post subject two" post from "Test forum name" forum with:
259 | Subject | Reply 1 to discussion 1 |
260 | Message | Discussion contents 1, second message |
f7dd19f0 261 | Discussion subscription | I don't want to be notified of new posts in this discussion |
ebfb73db
AN
262 And I follow "Test forum name"
263 Then "You are subscribed to this discussion. Click to unsubscribe." "link" should exist in the "Test post subject one" "table_row"
8271c89a 264 And "You are not subscribed to this discussion. Click to subscribe." "link" should exist in the "Test post subject two" "table_row"
ebfb73db
AN
265 And I follow "Test post subject one"
266 And I follow "Reply"
6887e2e5 267 And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
ebfb73db
AN
268 And I follow "Test forum name"
269 And I follow "Test post subject two"
270 And I follow "Reply"
f7dd19f0 271 And the field "Discussion subscription" matches value "I don't want to be notified of new posts in this discussion"
12cf8140
DC
272
273 Scenario: A guest should not be able to subscribe to a discussion
50dfb7cf 274 Given I click on "Home" "link" in the "Navigation" "block"
12cf8140
DC
275 And I add a "Forum" to section "1" and I fill the form with:
276 | Forum name | Test forum name |
277 | Forum type | Standard forum for general use |
278 | Description | Test forum description |
279 And I add a new discussion to "Test forum name" forum with:
280 | Subject | Test post subject one |
281 | Message | Test post message one |
282 And I log out
283 When I log in as "guest"
284 And I follow "Test forum name"
8271c89a 285 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
286 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist in the "Test post subject one" "table_row"
287 And I follow "Test post subject one"
8271c89a 288 And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist
12cf8140
DC
289 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist
290
291 Scenario: A user who is not logged in should not be able to subscribe to a discussion
50dfb7cf 292 Given I click on "Home" "link" in the "Navigation" "block"
12cf8140
DC
293 And I add a "Forum" to section "1" and I fill the form with:
294 | Forum name | Test forum name |
295 | Forum type | Standard forum for general use |
296 | Description | Test forum description |
297 And I add a new discussion to "Test forum name" forum with:
298 | Subject | Test post subject one |
299 | Message | Test post message one |
300 And I log out
301 When I follow "Test forum name"
8271c89a 302 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
303 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist in the "Test post subject one" "table_row"
304 And I follow "Test post subject one"
8271c89a 305 And "You are not subscribed to this discussion. Click to subscribe." "link" should not exist
12cf8140 306 And "You are subscribed to this discussion. Click to unsubscribe." "link" should not exist