mirrored from git://git.moodle.org/moodle.git
/
edit_availability.feature
233 lines (201 loc) · 10.7 KB
/
edit_availability.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
@core @core_availability
Feature: edit_availability
In order to control which students can see activities
As a teacher
I need to set up availability options for activities and sections
# PURPOSE OF THIS TEST FEATURE:
#
# This test covers the user interface around editing availability conditions,
# especially the JavaScript code which is not tested elsewhere (e.g. does the
# 'Add restriction' dialog work). It tests both forms and also the admin
# setting interface.
#
# This test does not check the detailed behaviour of the availability system,
# which is mainly covered in PHPUnit (and, from the user interface
# perspective, in the other Behat tests for each type of condition).
Background:
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "users" exist:
| username |
| teacher1 |
| student1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
Scenario: Confirm the 'enable availability' option is working
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Page" to section "1"
Then "Restrict access" "fieldset" should not exist
Given I follow "C1"
When I edit the section "1"
Then "Restrict access" "fieldset" should not exist
When I log out
And I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
When I log out
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Page" to section "1"
Then "Restrict access" "fieldset" should exist
Given I follow "C1"
When I edit the section "1"
Then "Restrict access" "fieldset" should exist
@javascript
Scenario: Edit availability using settings in activity form
# Set up.
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And I log in as "teacher1"
And I follow "Course 1"
# Add a Page and check it has None in so far.
And I turn editing mode on
And I add a "Page" to section "1"
And I expand all fieldsets
Then I should see "None" in the "Restrict access" "fieldset"
# Add a Date restriction and check it appears.
When I click on "Add restriction..." "button"
Then "Add restriction..." "dialogue" should be visible
When I click on "Date" "button" in the "Add restriction..." "dialogue"
Then "Add restriction..." "dialogue" should not exist
And I should not see "None" in the "Restrict access" "fieldset"
And "Restriction type" "select" should be visible
And I should see "Date" in the "Restrict access" "fieldset"
And ".availability-item .availability-eye img" "css_element" should be visible
And ".availability-item .availability-delete img" "css_element" should be visible
And the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Displayed greyed-out"
# Toggle the eye icon.
When I click on ".availability-item .availability-eye img" "css_element"
Then the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Hidden entirely"
When I click on ".availability-item .availability-eye img" "css_element"
Then the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Displayed greyed-out"
# Click the delete button.
When I click on ".availability-item .availability-delete img" "css_element"
Then I should not see "Date" in the "Restrict access" "fieldset"
# Add a nested restriction set and check it appears.
When I click on "Add restriction..." "button"
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
Then ".availability-children .availability-list" "css_element" should be visible
And I should see "None" in the ".availability-children .availability-list" "css_element"
And I should see "Please set" in the ".availability-children .availability-list" "css_element"
And I should see "Add restriction" in the ".availability-children .availability-list" "css_element"
# Click on the button to add a restriction inside the nested set.
When I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
Then I should not see "None" in the ".availability-children .availability-list" "css_element"
And I should not see "Please set" in the ".availability-children .availability-list" "css_element"
And I should see "Date" in the ".availability-children .availability-list" "css_element"
# OK, let's delete the date inside the nested set...
When I click on ".availability-item .availability-delete img" "css_element" in the ".availability-item" "css_element"
Then I should not see "Date" in the ".availability-children .availability-list" "css_element"
And I should see "None" in the ".availability-children .availability-list" "css_element"
# ...and the nested set itself.
When I click on ".availability-none .availability-delete img" "css_element"
Then ".availability-children .availability-list" "css_element" should not exist
# Add two dates so we can check the connectors.
When I click on "Add restriction..." "button"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I click on "Add restriction..." "button"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
Then I should see "and" in the "Restrict access" "fieldset"
And "Required restrictions" "select" should be visible
# Try changing the connector type.
When I set the field "Required restrictions" to "any"
Then I should not see "and" in the "Restrict access" "fieldset"
And I should see "or" in the "Restrict access" "fieldset"
# Now delete one of the dates and check the connector goes away.
When I click on ".availability-item .availability-delete img" "css_element"
Then I should not see "or" in the "Restrict access" "fieldset"
# Add a nested restriction set with two dates so there will be inner connector.
When I click on "Add restriction..." "button"
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
And I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
And I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
And I click on "Date" "button" in the "Add restriction..." "dialogue"
Then I should see "and" in the ".availability-children .availability-list .availability-connector" "css_element"
# Check changing the outer one does not affect the inner one.
When I set the field "Required restrictions" to "all"
Then I should not see "or" in the "Restrict access" "fieldset"
When I set the field "Required restrictions" to "any"
Then I should see "or" in the "Restrict access" "fieldset"
And I should not see "or" in the ".availability-children .availability-list .availability-connector" "css_element"
@javascript
Scenario: Edit availability using settings in section form
# Set up.
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And I log out
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
# Edit a section
When I edit the section "1"
And I expand all fieldsets
Then I should see "None" in the "Restrict access" "fieldset"
# Add a Date restriction and check it appears.
When I click on "Add restriction..." "button"
When I click on "Date" "button" in the "Add restriction..." "dialogue"
And I should not see "None" in the "Restrict access" "fieldset"
And "Restriction type" "select" should be visible
And I should see "Date" in the "Restrict access" "fieldset"
@javascript
Scenario: 'Add group/grouping access restriction' button unavailable
# Button does not exist when conditional access restrictions are turned off.
Given I log in as "admin"
And I follow "Course 1"
And I turn editing mode on
And I add a "Forum" to section "1"
When I expand all fieldsets
Then "Add group/grouping access restriction" "button" should not exist
@javascript
Scenario: Use the 'Add group/grouping access restriction' button
# Button should initially be disabled.
Given I log in as "admin"
And I set the following administration settings values:
| Enable conditional access | 1 |
And the following "groupings" exist:
| name | course | idnumber |
| GX1 | C1 | GXI1 |
And I am on homepage
And I follow "Course 1"
And I turn editing mode on
And I add a "Forum" to section "1"
And I set the following fields to these values:
| Forum name | MyForum |
| Description | x |
When I expand all fieldsets
Then the "Add group/grouping access restriction" "button" should be disabled
# Turn on separate groups.
And I set the field "Group mode" to "Separate groups"
And the "Add group/grouping access restriction" "button" should be enabled
# Press the button and check it adds a restriction and disables itself.
And I should see "None" in the "Restrict access" "fieldset"
And I press "Add group/grouping access restriction"
And I should see "Group" in the "Restrict access" "fieldset"
And the "Add group/grouping access restriction" "button" should be disabled
# Delete the restriction and check it is enabled again.
And I click on "Delete" "link" in the "Restrict access" "fieldset"
And the "Add group/grouping access restriction" "button" should be enabled
# Try a grouping instead.
And I set the field "Grouping" to "GX1"
And I press "Add group/grouping access restriction"
And I should see "Grouping" in the "Restrict access" "fieldset"
# Check the button still works after saving and editing.
And I press "Save and display"
And I navigate to "Edit settings" node in "Forum administration"
And I expand all fieldsets
And the "Add group/grouping access restriction" "button" should be disabled
And I should see "Grouping" in the "Restrict access" "fieldset"
# And check it's still active if I delete the condition.
And I click on "Delete" "link" in the "Restrict access" "fieldset"
And the "Add group/grouping access restriction" "button" should be enabled