MDL-65069 mod_forum: Stripped out inpage form and advanced redirect
[moodle.git] / mod / forum / tests / behat / visible_group_discussions.feature
CommitLineData
bff7570e
AN
1@mod @mod_forum
2Feature: Posting to all groups in a visible group discussion is restricted to users with access to all groups
3 In order to post to all groups in a forum with visible groups
4 As a teacher
5 I need to have the accessallgroups capability
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | teacher1 | Teacher | 1 | teacher1@example.com |
11 | student1 | Student | 1 | student1@example.com |
12 | student2 | Student | 2 | student2@example.com |
13 And the following "courses" exist:
14 | fullname | shortname | category |
15 | Course 1 | C1 | 0 |
16 And the following "course enrolments" exist:
17 | user | course | role |
18 | teacher1 | C1 | editingteacher |
19 | student1 | C1 | student |
20 | student2 | C1 | student |
21 And the following "groups" exist:
22 | name | course | idnumber |
23 | Group A | C1 | G1 |
24 | Group B | C1 | G2 |
25 | Group C | C1 | G3 |
26 And the following "group members" exist:
27 | user | group |
28 | teacher1 | G1 |
29 | teacher1 | G2 |
30 | student1 | G1 |
31 | student2 | G1 |
32 | student2 | G2 |
33 And the following "activities" exist:
34 | activity | name | intro | course | idnumber | groupmode |
35 | forum | Standard forum name | Standard forum description | C1 | groups | 2 |
36
37 Scenario: Teacher with accessallgroups can view all groups
38 Given I log in as "teacher1"
fdeeaff9 39 And I am on "Course 1" course homepage
bff7570e
AN
40 When I follow "Standard forum name"
41 Then the "Visible groups" select box should contain "All participants"
42 Then the "Visible groups" select box should contain "Group A"
43 Then the "Visible groups" select box should contain "Group B"
44 Then the "Visible groups" select box should contain "Group C"
45
46 Scenario: Teacher with accessallgroups can select any group when posting
47 Given I log in as "teacher1"
fdeeaff9 48 And I am on "Course 1" course homepage
bff7570e 49 And I follow "Standard forum name"
858179b0 50 When I click on "Add a new discussion topic" "link"
97babbf7 51 And I click on "Advanced" "button"
bff7570e
AN
52 Then the "Group" select box should contain "All participants"
53 And the "Group" select box should contain "Group A"
54 And the "Group" select box should contain "Group B"
55 And the "Group" select box should contain "Group C"
56 And I should see "Post a copy to all groups"
57
58 Scenario: Teacher with accessallgroups can post in groups they are a member of
59 Given I log in as "teacher1"
fdeeaff9 60 And I am on "Course 1" course homepage
bff7570e
AN
61 And I follow "Standard forum name"
62 And I select "Group A" from the "Visible groups" singleselect
858179b0 63 When I click on "Add a new discussion topic" "link"
97babbf7 64 And I click on "Advanced" "button"
bff7570e
AN
65 Then I should see "Post a copy to all groups"
66 And I set the following fields to these values:
67 | Subject | Teacher 1 -> Group B |
68 | Message | Teacher 1 -> Group B |
69 # Change the group in the post form.
70 | Group | Group B |
71 And I press "Post to forum"
72 And I wait to be redirected
73 # We should be redirected to the group that we selected when posting.
74 And the field "Visible groups" matches value "Group B"
75 And I should see "Group B" in the "Teacher 1 -> Group B" "table_row"
76 And I should not see "Group A" in the "Teacher 1 -> Group B" "table_row"
77 And I should not see "Group C" in the "Teacher 1 -> Group B" "table_row"
78 # It should also be displayed under All participants
79 And I select "All participants" from the "Visible groups" singleselect
80 And I should see "Group B" in the "Teacher 1 -> Group B" "table_row"
81 And I should not see "Group A" in the "Teacher 1 -> Group B" "table_row"
82 And I should not see "Group C" in the "Teacher 1 -> Group B" "table_row"
83 # It should not be displayed in Groups A, or C.
84 And I select "Group A" from the "Visible groups" singleselect
85 And I should not see "Teacher 1 -> Group B"
86 And I select "Group C" from the "Visible groups" singleselect
87 And I should not see "Teacher 1 -> Group B"
88
89 Scenario: Teacher with accessallgroups can post in groups they are not a member of
90 Given I log in as "teacher1"
fdeeaff9 91 And I am on "Course 1" course homepage
bff7570e
AN
92 And I follow "Standard forum name"
93 And I select "Group A" from the "Visible groups" singleselect
858179b0 94 When I click on "Add a new discussion topic" "link"
97babbf7 95 And I click on "Advanced" "button"
bff7570e
AN
96 Then I should see "Post a copy to all groups"
97 And I set the following fields to these values:
98 | Subject | Teacher 1 -> Group C |
99 | Message | Teacher 1 -> Group C |
100 | Group | Group C |
101 And I press "Post to forum"
102 And I wait to be redirected
103 # We should be redirected to the group that we selected when posting.
104 And the field "Visible groups" matches value "Group C"
105 # We redirect to the group posted in automatically.
106 And I should see "Group C" in the "Teacher 1 -> Group C" "table_row"
107 And I should not see "Group A" in the "Teacher 1 -> Group C" "table_row"
108 And I should not see "Group B" in the "Teacher 1 -> Group C" "table_row"
109 # It should also be displayed under All participants
110 And I select "All participants" from the "Visible groups" singleselect
111 And I should see "Group C" in the "Teacher 1 -> Group C" "table_row"
112 And I should not see "Group A" in the "Teacher 1 -> Group C" "table_row"
113 And I should not see "Group B" in the "Teacher 1 -> Group C" "table_row"
114 # It should not be displayed in Groups A, or B.
115 And I select "Group A" from the "Visible groups" singleselect
116 And I should not see "Teacher 1 -> Group C"
117 And I select "Group B" from the "Visible groups" singleselect
118 And I should not see "Teacher 1 -> Group C"
119
120 Scenario: Teacher with accessallgroups can post to all groups
121 Given I log in as "teacher1"
fdeeaff9 122 And I am on "Course 1" course homepage
bff7570e 123 And I follow "Standard forum name"
858179b0 124 When I click on "Add a new discussion topic" "link"
97babbf7 125 And I click on "Advanced" "button"
bff7570e
AN
126 And I set the following fields to these values:
127 | Subject | Teacher 1 -> Post to all |
128 | Message | Teacher 1 -> Post to all |
129 | Post a copy to all groups | 1 |
130 And I press "Post to forum"
131 And I wait to be redirected
132 # Posting to all groups means that we should be redirected to the page we started from.
133 And the field "Visible groups" matches value "All participants"
134 And I select "Group A" from the "Visible groups" singleselect
135 Then I should see "Group A" in the "Teacher 1 -> Post to all" "table_row"
136 And I should not see "Group B" in the "Teacher 1 -> Post to all" "table_row"
137 And I should not see "Group C" in the "Teacher 1 -> Post to all" "table_row"
138 And I select "Group B" from the "Visible groups" singleselect
139 And I should see "Group B" in the "Teacher 1 -> Post to all" "table_row"
140 And I should not see "Group A" in the "Teacher 1 -> Post to all" "table_row"
141 And I should not see "Group C" in the "Teacher 1 -> Post to all" "table_row"
142 And I select "Group C" from the "Visible groups" singleselect
143 And I should see "Group C" in the "Teacher 1 -> Post to all" "table_row"
144 And I should not see "Group A" in the "Teacher 1 -> Post to all" "table_row"
145 And I should not see "Group B" in the "Teacher 1 -> Post to all" "table_row"
146 # No point testing the "All participants".
147
148 Scenario: Students can view all groups
149 Given I log in as "student1"
fdeeaff9 150 And I am on "Course 1" course homepage
bff7570e
AN
151 When I follow "Standard forum name"
152 Then the "Visible groups" select box should contain "All participants"
153 Then the "Visible groups" select box should contain "Group A"
154 Then the "Visible groups" select box should contain "Group B"
155 Then the "Visible groups" select box should contain "Group C"
156
157 Scenario: Students in one group can only post in their group
158 Given I log in as "student1"
fdeeaff9 159 And I am on "Course 1" course homepage
bff7570e
AN
160 When I follow "Standard forum name"
161 Then I should see "Group A"
858179b0 162 And I click on "Add a new discussion topic" "link"
97babbf7 163 And I click on "Advanced" "button"
bff7570e
AN
164 And I should see "Group A"
165 And I should not see "Group B"
166 And I should not see "Group C"
167 And I should not see "Post a copy to all groups"
168 And I set the following fields to these values:
169 | Subject | Student -> B |
170 | Message | Student -> B |
171 And I press "Post to forum"
172 And I wait to be redirected
173 And I should see "Group A" in the "Student -> B" "table_row"
174 And I should not see "Group B" in the "Student -> B" "table_row"
175
176 Scenario: Students in multiple group can post in all of their group individually
177 Given I log in as "student2"
fdeeaff9 178 And I am on "Course 1" course homepage
bff7570e
AN
179 When I follow "Standard forum name"
180 And I select "Group A" from the "Visible groups" singleselect
858179b0 181 And I click on "Add a new discussion topic" "link"
97babbf7 182 And I click on "Advanced" "button"
bff7570e
AN
183 And the "Group" select box should not contain "All participants"
184 And the "Group" select box should contain "Group A"
185 And the "Group" select box should contain "Group B"
186 And the "Group" select box should not contain "Group C"
187 And I should not see "Post a copy to all groups"
188 And I set the following fields to these values:
189 | Subject | Student -> B |
190 | Message | Student -> B |
191 | Group | Group B |
192 And I press "Post to forum"
193 And I wait to be redirected
194 # We should be redirected to the group that we selected when posting.
195 And the field "Visible groups" matches value "Group B"
196 And I should see "Group B" in the "Student -> B" "table_row"
197 And I should not see "Group A" in the "Student -> B" "table_row"
198 And I select "Group A" from the "Visible groups" singleselect
199 And I should not see "Student -> B"
200 # Now try posting in Group A (starting at Group B)
201 And I select "Group B" from the "Visible groups" singleselect
858179b0 202 And I click on "Add a new discussion topic" "link"
97babbf7 203 And I click on "Advanced" "button"
bff7570e
AN
204 And the "Group" select box should not contain "All participants"
205 And the "Group" select box should contain "Group A"
206 And the "Group" select box should contain "Group B"
207 And the "Group" select box should not contain "Group C"
208 And I should not see "Post a copy to all groups"
209 And I set the following fields to these values:
210 | Subject | Student -> A |
211 | Message | Student -> A |
212 | Group | Group A |
213 And I press "Post to forum"
214 And I wait to be redirected
215 # We should be redirected to the group that we selected when posting.
216 And the field "Visible groups" matches value "Group A"
217 And I should see "Group A" in the "Student -> A" "table_row"
218 And I should not see "Group B" in the "Student -> A" "table_row"
219 And I select "Group B" from the "Visible groups" singleselect
220 And I should not see "Student -> A"