MDL-52347 behat: fix random failures on fast computer
[moodle.git] / mod / forum / tests / behat / discussion_navigation.feature
CommitLineData
d9c767c7
FM
1@mod @mod_forum
2Feature: A user can navigate to previous and next discussions
3 In order to get go the previous discussion
4 As a user
5 I need to click on the previous discussion link
6
7 Background:
8 Given the following "users" exist:
2e782e51
AN
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 |
d9c767c7 13 And the following "courses" exist:
2e782e51
AN
14 | fullname | shortname | category |
15 | Course 1 | C1 | 0 |
d9c767c7
FM
16 And the following "course enrolments" exist:
17 | user | course | role |
2e782e51 18 | teacher1 | C1 | editingteacher |
d9c767c7
FM
19 | student1 | C1 | student |
20 | student2 | C1 | student |
2e782e51
AN
21 And the following "groups" exist:
22 | name | course | idnumber |
23 | Group 1 | C1 | G1 |
24 | Group 2 | C1 | G2 |
25 And the following "group members" exist:
26 | user | group |
27 | teacher1 | G1 |
28 | teacher1 | G2 |
29 | student1 | G1 |
30 | student2 | G2 |
d9c767c7 31
d9c767c7 32 Scenario: A user can navigate between discussions
2e782e51
AN
33 Given the following "activities" exist:
34 | activity | name | intro | course | idnumber | groupmode |
35 | forum | Test forum name | Test forum name | C1 | forum | 0 |
36 And I log in as "teacher1"
37 And I follow "Course 1"
38 And I follow "Test forum name"
d9c767c7
FM
39 And I add a new discussion to "Test forum name" forum with:
40 | Subject | Discussion 1 |
41 | Message | Test post message |
a7d95e4e 42 And I wait "1" seconds
d9c767c7
FM
43 And I add a new discussion to "Test forum name" forum with:
44 | Subject | Discussion 2 |
45 | Message | Test post message |
a7d95e4e 46 And I wait "1" seconds
d9c767c7
FM
47 And I add a new discussion to "Test forum name" forum with:
48 | Subject | Discussion 3 |
49 | Message | Test post message |
50 When I follow "Discussion 3"
51 Then I should not see "Discussion 1"
52 And I should see "Discussion 2"
53 And I follow "Discussion 2"
54 And I should see "Discussion 1"
55 And I should see "Discussion 3"
56 And I follow "Discussion 1"
57 And I should see "Discussion 2"
58 And I should not see "Discussion 3"
a4269b45 59 And I wait "1" seconds
d9c767c7
FM
60 And I follow "Reply"
61 And I set the following fields to these values:
62 | Message | Answer to discussion |
63 And I press "Post to forum"
2e782e51 64 And I wait to be redirected
d9c767c7
FM
65 And I should not see "Discussion 2"
66 And I should see "Discussion 3"
67 And I follow "Discussion 3"
68 And I should see "Discussion 1"
69 And I should see "Discussion 2"
70 And I follow "Discussion 2"
71 And I should not see "Discussion 1"
72 And I should see "Discussion 3"
73
d9c767c7 74 Scenario: A user can navigate between discussions with visible groups
2e782e51
AN
75 Given the following "activities" exist:
76 | activity | name | intro | course | idnumber | groupmode |
77 | forum | Test forum name | Test forum name | C1 | forum | 2 |
78 And I log in as "teacher1"
79 And I follow "Course 1"
80 And I follow "Test forum name"
d9c767c7
FM
81 And I add a new discussion to "Test forum name" forum with:
82 | Subject | Discussion 1 Group 0 |
83 | Message | Test post message |
5d38a5cd 84 And I wait "1" seconds
d9c767c7
FM
85 And I add a new discussion to "Test forum name" forum with:
86 | Subject | Discussion 2 Group 0 |
87 | Message | Test post message |
5d38a5cd 88 And I wait "1" seconds
d9c767c7
FM
89 And I add a new discussion to "Test forum name" forum with:
90 | Subject | Discussion 1 Group 1 |
91 | Message | Test post message |
92 | Group | Group 1 |
5d38a5cd 93 And I wait "1" seconds
d9c767c7
FM
94 And I add a new discussion to "Test forum name" forum with:
95 | Subject | Discussion 2 Group 1 |
96 | Message | Test post message |
97 | Group | Group 1 |
5d38a5cd 98 And I wait "1" seconds
d9c767c7
FM
99 And I add a new discussion to "Test forum name" forum with:
100 | Subject | Discussion 1 Group 2 |
101 | Message | Test post message |
102 | Group | Group 2 |
5d38a5cd 103 And I wait "1" seconds
d9c767c7
FM
104 And I add a new discussion to "Test forum name" forum with:
105 | Subject | Discussion 2 Group 2 |
106 | Message | Test post message |
107 | Group | Group 2 |
108 And I log out
109 When I log in as "student1"
110 And I follow "Course 1"
111 And I follow "Test forum name"
2e782e51 112 And I select "All participants" from the "Visible groups" singleselect
d9c767c7
FM
113 And I follow "Discussion 1 Group 0"
114 Then I should see "Discussion 2 Group 0"
115 And I should not see "Group 1"
116 And I should not see "Group 2"
117 And I follow "Discussion 2 Group 0"
118 And I should see "Discussion 1 Group 0"
119 And I should see "Discussion 1 Group 1"
120 And I follow "Discussion 1 Group 1"
121 And I should see "Discussion 2 Group 0"
122 And I should see "Discussion 2 Group 1"
123 And I follow "Test forum name"
124 And I follow "Discussion 1 Group 2"
125 And I should see "Discussion 2 Group 1"
126 And I should see "Discussion 2 Group 2"
127 And I follow "Test forum name"
2e782e51 128 And I select "Group 1" from the "Visible groups" singleselect
d9c767c7
FM
129 And I follow "Discussion 1 Group 1"
130 Then I should see "Discussion 2 Group 0"
131 And I should see "Discussion 2 Group 1"
132 And I follow "Discussion 2 Group 1"
133 And I should see "Discussion 1 Group 1"
134 And I should not see "Group 2"
135
d9c767c7 136 Scenario: A user can navigate between discussions with separate groups
2e782e51
AN
137 Given the following "activities" exist:
138 | activity | name | intro | course | idnumber | groupmode |
139 | forum | Test forum name | Test forum name | C1 | forum | 1 |
140 And I log in as "teacher1"
141 And I follow "Course 1"
142 And I follow "Test forum name"
d9c767c7
FM
143 And I add a new discussion to "Test forum name" forum with:
144 | Subject | Discussion 1 Group 0 |
145 | Message | Test post message |
a7d95e4e 146 And I wait "1" seconds
d9c767c7
FM
147 And I add a new discussion to "Test forum name" forum with:
148 | Subject | Discussion 2 Group 0 |
149 | Message | Test post message |
a7d95e4e 150 And I wait "1" seconds
d9c767c7
FM
151 And I add a new discussion to "Test forum name" forum with:
152 | Subject | Discussion 1 Group 1 |
153 | Message | Test post message |
154 | Group | Group 1 |
a7d95e4e 155 And I wait "1" seconds
d9c767c7
FM
156 And I add a new discussion to "Test forum name" forum with:
157 | Subject | Discussion 2 Group 1 |
158 | Message | Test post message |
159 | Group | Group 1 |
a7d95e4e 160 And I wait "1" seconds
d9c767c7
FM
161 And I add a new discussion to "Test forum name" forum with:
162 | Subject | Discussion 1 Group 2 |
163 | Message | Test post message |
164 | Group | Group 2 |
a7d95e4e 165 And I wait "1" seconds
d9c767c7
FM
166 And I add a new discussion to "Test forum name" forum with:
167 | Subject | Discussion 2 Group 2 |
168 | Message | Test post message |
169 | Group | Group 2 |
170 And I log out
171 When I log in as "student1"
172 And I follow "Course 1"
173 And I follow "Test forum name"
174 And I follow "Discussion 1 Group 1"
175 Then I should see "Discussion 2 Group 0"
176 And I should see "Discussion 2 Group 1"
177 And I follow "Discussion 2 Group 1"
178 And I should see "Discussion 1 Group 1"
179 And I should not see "Group 2"