source: moodle/trunk/fuentes/availability/tests/behat/edit_availability.feature @ 1331

Last change on this file since 1331 was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

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