MDL-30811 forum: Update use of redirect to include message and type
[moodle.git] / mod / forum / tests / behat / forum_subscriptions_default.feature
CommitLineData
be773fd6
AN
1@mod @mod_forum
2Feature: A user can control their default discussion subscription settings
3 In order to automatically subscribe to discussions
4 As a user
5 I can choose my default subscription preference
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email | autosubscribe |
10 | student1 | Student | One | student.one@example.com | 1 |
11 | student2 | Student | Two | student.one@example.com | 0 |
12 And the following "courses" exist:
13 | fullname | shortname | category |
14 | Course 1 | C1 | 0 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | student1 | C1 | student |
18 | student2 | C1 | student |
19 And I log in as "admin"
221210e9 20 And I am on site homepage
be773fd6
AN
21 And I follow "Course 1"
22 And I turn editing mode on
23
24 Scenario: Creating a new discussion in an optional forum follows user preferences
25 Given I add a "Forum" to section "1" and I fill the form with:
26 | Forum name | Test forum name |
27 | Forum type | Standard forum for general use |
28 | Description | Test forum description |
29 | Subscription mode | Optional subscription |
30 And I log out
31 And I log in as "student1"
32 And I follow "Course 1"
33 And I follow "Test forum name"
34 When I press "Add a new discussion topic"
35 Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
36 And I log out
37 And I log in as "student2"
38 And I follow "Course 1"
39 And I follow "Test forum name"
40 And I press "Add a new discussion topic"
41 And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist
42
43 Scenario: Replying to an existing discussion in an optional forum follows user preferences
44 Given I add a "Forum" to section "1" and I fill the form with:
45 | Forum name | Test forum name |
46 | Forum type | Standard forum for general use |
47 | Description | Test forum description |
48 | Subscription mode | Optional subscription |
49 And I add a new discussion to "Test forum name" forum with:
50 | Subject | Test post subject |
51 | Message | Test post message |
52 And I log out
53 And I log in as "student1"
54 And I follow "Course 1"
55 And I follow "Test forum name"
56 And I follow "Test post subject"
57 When I follow "Reply"
58 Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
59 And I log out
60 And I log in as "student2"
61 And I follow "Course 1"
62 And I follow "Test forum name"
63 And I follow "Test post subject"
64 And I follow "Reply"
65 And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist
66
67 Scenario: Creating a new discussion in an automatic forum follows forum subscription
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 log out
74 And I log in as "student1"
75 And I follow "Course 1"
76 And I follow "Test forum name"
77 When I press "Add a new discussion topic"
78 Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
79 And I log out
80 And I log in as "student2"
81 And I follow "Course 1"
82 And I follow "Test forum name"
83 And I press "Add a new discussion topic"
84 And "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
85
86 Scenario: Replying to an existing discussion in an automatic forum follows forum subscription
87 Given I add a "Forum" to section "1" and I fill the form with:
88 | Forum name | Test forum name |
89 | Forum type | Standard forum for general use |
90 | Description | Test forum description |
91 | Subscription mode | Optional subscription |
92 And I add a new discussion to "Test forum name" forum with:
93 | Subject | Test post subject |
94 | Message | Test post message |
95 And I log out
96 And I log in as "student1"
97 And I follow "Course 1"
98 And I follow "Test forum name"
99 And I follow "Test post subject"
100 When I follow "Reply"
101 Then "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
102 And I log out
103 And I log in as "student2"
104 And I follow "Course 1"
105 And I follow "Test forum name"
106 And I follow "Test post subject"
107 And I follow "Reply"
108 And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist
109
110 Scenario: Replying to an existing discussion in an automatic forum which has been unsubscribed from follows user preferences
111 Given I add a "Forum" to section "1" and I fill the form with:
112 | Forum name | Test forum name |
113 | Forum type | Standard forum for general use |
114 | Description | Test forum description |
115 | Subscription mode | Auto subscription |
116 And I add a new discussion to "Test forum name" forum with:
117 | Subject | Test post subject |
118 | Message | Test post message |
119 And I log out
120 And I log in as "student1"
121 And I follow "Course 1"
122 And I follow "Test forum name"
123 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject" "table_row"
d954b54f 124 And I should see "Student One will NOT be notified of new posts in 'Test post subject' of 'Test forum name'"
be773fd6
AN
125 And I follow "Test post subject"
126 When I follow "Reply"
127 And "input[name=discussionsubscribe][checked=checked]" "css_element" should exist
128 And I log out
129 And I log in as "student2"
130 And I follow "Course 1"
131 And I follow "Test forum name"
132 And I click on "You are subscribed to this discussion. Click to unsubscribe." "link" in the "Test post subject" "table_row"
d954b54f 133 And I should see "Student Two will NOT be notified of new posts in 'Test post subject' of 'Test forum name'"
be773fd6
AN
134 And I follow "Test post subject"
135 And I follow "Reply"
136 And "input[name=discussionsubscribe]:not([checked=checked])" "css_element" should exist