MDL-67042 customfield: Add behat tests to check hidden fields
[moodle.git] / blocks / myoverview / tests / behat / block_myoverview_customfield.feature
CommitLineData
8d166d77
DS
1@block @block_myoverview @javascript
2Feature: The my overview block allows users to group courses by custom fields
3
4 Background:
5 Given the following "users" exist:
6 | username | firstname | lastname | email | idnumber |
7 | student1 | Student | X | student1@example.com | S1 |
8 And the following "custom field categories" exist:
9 | name | component | area | itemid |
10 | Course fields | core_course | course | 0 |
11 And the following "custom fields" exist:
12 | name | category | type | shortname | configdata |
13 | Checkbox field | Course fields | checkbox | checkboxfield | |
14 | Date field | Course fields | date | datefield | {"mindate":0, "maxdate":0} |
15 | Select field | Course fields | select | selectfield | {"options":"Option 1\nOption 2\nOption 3\nOption 4"} |
e49543e8
SA
16 | Text field | Course fields | text | textfield | {"visibility":"2"} |
17 | Text field 2 | Course fields | text | textfield2 | {"visibility":"2"} |
18 | Hidden field | Course fields | text | hiddenfield | {"visibility":"0"} |
8d166d77 19 And the following "courses" exist:
e49543e8
SA
20 | fullname | shortname | category | customfield_checkboxfield | customfield_datefield | customfield_selectfield | customfield_textfield | customfield_textfield2 |
21 | Course 1 | C1 | 0 | 1 | 981028800 | 1 | fish | penguin |
22 | Course 2 | C2 | 0 | 0 | 334324800 | | | |
23 | Course 3 | C3 | 0 | 0 | 981028800 | 2 | dog | |
24 | Course 4 | C4 | 0 | 1 | | 3 | cat | |
25 | Course 5 | C5 | 0 | | 334411200 | 2 | fish | penguin |
8d166d77
DS
26 And the following "course enrolments" exist:
27 | user | course | role |
28 | student1 | C1 | student |
29 | student1 | C2 | student |
30 | student1 | C3 | student |
31 | student1 | C4 | student |
32 | student1 | C5 | student |
33
34 Scenario: Group courses by checkbox: Yes
35 Given the following config values are set as admin:
36 | displaygroupingcustomfield | 1 | block_myoverview |
37 | customfiltergrouping | checkboxfield | block_myoverview |
38 And I log in as "student1"
39 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
40 When I click on "Checkbox field: Yes" "link" in the "Course overview" "block"
41 Then I should see "Course 1" in the "Course overview" "block"
42 And I should not see "Course 2" in the "Course overview" "block"
43 And I should not see "Course 3" in the "Course overview" "block"
44 And I should see "Course 4" in the "Course overview" "block"
45 And I should not see "Course 5" in the "Course overview" "block"
46
47 Scenario: Group courses by checkbox: No
48 Given the following config values are set as admin:
49 | displaygroupingcustomfield | 1 | block_myoverview |
50 | customfiltergrouping | checkboxfield | block_myoverview |
51 And I log in as "student1"
52 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
53 When I click on "Checkbox field: No" "link" in the "Course overview" "block"
54 Then I should not see "Course 1" in the "Course overview" "block"
55 And I should see "Course 2" in the "Course overview" "block"
56 And I should see "Course 3" in the "Course overview" "block"
57 And I should not see "Course 4" in the "Course overview" "block"
58 And I should see "Course 5" in the "Course overview" "block"
59
60 Scenario: Group courses by date: 1 February 2001
61 Given the following config values are set as admin:
62 | displaygroupingcustomfield | 1 | block_myoverview |
63 | customfiltergrouping | datefield | block_myoverview |
64 And I log in as "student1"
65 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
66 When I click on "1 February 2001" "link" in the "Course overview" "block"
67 Then I should see "Course 1" in the "Course overview" "block"
68 And I should not see "Course 2" in the "Course overview" "block"
69 And I should see "Course 3" in the "Course overview" "block"
70 And I should not see "Course 4" in the "Course overview" "block"
71 And I should not see "Course 5" in the "Course overview" "block"
72
73 Scenario: Group courses by date: 6 August 1980
74 Given the following config values are set as admin:
75 | displaygroupingcustomfield | 1 | block_myoverview |
76 | customfiltergrouping | datefield | block_myoverview |
77 And I log in as "student1"
78 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
79 When I click on "6 August 1980" "link" in the "Course overview" "block"
80 Then I should not see "Course 1" in the "Course overview" "block"
81 And I should not see "Course 2" in the "Course overview" "block"
82 And I should not see "Course 3" in the "Course overview" "block"
83 And I should not see "Course 4" in the "Course overview" "block"
84 And I should see "Course 5" in the "Course overview" "block"
85
86 Scenario: Group courses by date: No Date field
87 Given the following config values are set as admin:
88 | displaygroupingcustomfield | 1 | block_myoverview |
89 | customfiltergrouping | datefield | block_myoverview |
90 And I log in as "student1"
91 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
92 When I click on "No Date field" "link" in the "Course overview" "block"
93 Then I should not see "Course 1" in the "Course overview" "block"
94 And I should not see "Course 2" in the "Course overview" "block"
95 And I should not see "Course 3" in the "Course overview" "block"
96 And I should see "Course 4" in the "Course overview" "block"
97 And I should not see "Course 5" in the "Course overview" "block"
98
99 Scenario: Group courses by select: Option 1
100 Given the following config values are set as admin:
101 | displaygroupingcustomfield | 1 | block_myoverview |
102 | customfiltergrouping | selectfield | block_myoverview |
103 And I log in as "student1"
104 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
105 And I should not see "Option 4" in the "Course overview" "block"
106 When I click on "Option 1" "link" in the "Course overview" "block"
107 Then I should see "Course 1" in the "Course overview" "block"
108 And I should not see "Course 2" in the "Course overview" "block"
109 And I should not see "Course 3" in the "Course overview" "block"
110 And I should not see "Course 4" in the "Course overview" "block"
111 And I should not see "Course 5" in the "Course overview" "block"
112
113 Scenario: Group courses by select: Option 2
114 Given the following config values are set as admin:
115 | displaygroupingcustomfield | 1 | block_myoverview |
116 | customfiltergrouping | selectfield | block_myoverview |
117 And I log in as "student1"
118 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
119 When I click on "Option 2" "link" in the "Course overview" "block"
120 Then I should not see "Course 1" in the "Course overview" "block"
121 And I should not see "Course 2" in the "Course overview" "block"
122 And I should see "Course 3" in the "Course overview" "block"
123 And I should not see "Course 4" in the "Course overview" "block"
124 And I should see "Course 5" in the "Course overview" "block"
125
126 Scenario: Group courses by select: No Select field
127 Given the following config values are set as admin:
128 | displaygroupingcustomfield | 1 | block_myoverview |
129 | customfiltergrouping | selectfield | block_myoverview |
130 And I log in as "student1"
131 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
132 When I click on "No Select field" "link" in the "Course overview" "block"
133 Then I should not see "Course 1" in the "Course overview" "block"
134 And I should see "Course 2" in the "Course overview" "block"
135 And I should not see "Course 3" in the "Course overview" "block"
136 And I should not see "Course 4" in the "Course overview" "block"
137 And I should not see "Course 5" in the "Course overview" "block"
138
139 Scenario: Group courses by text: fish
140 Given the following config values are set as admin:
141 | displaygroupingcustomfield | 1 | block_myoverview |
142 | customfiltergrouping | textfield | block_myoverview |
143 And I log in as "student1"
144 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
145 When I click on "fish" "link" in the "Course overview" "block"
146 Then I should see "Course 1" in the "Course overview" "block"
147 And I should not see "Course 2" in the "Course overview" "block"
148 And I should not see "Course 3" in the "Course overview" "block"
149 And I should not see "Course 4" in the "Course overview" "block"
150 And I should see "Course 5" in the "Course overview" "block"
151
152 Scenario: Group courses by text: dog
153 Given the following config values are set as admin:
154 | displaygroupingcustomfield | 1 | block_myoverview |
155 | customfiltergrouping | textfield | block_myoverview |
156 And I log in as "student1"
157 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
158 When I click on "dog" "link" in the "Course overview" "block"
159 Then I should not see "Course 1" in the "Course overview" "block"
160 And I should not see "Course 2" in the "Course overview" "block"
161 And I should see "Course 3" in the "Course overview" "block"
162 And I should not see "Course 4" in the "Course overview" "block"
163 And I should not see "Course 5" in the "Course overview" "block"
164
165 Scenario: Group courses by text: No Text field
166 Given the following config values are set as admin:
167 | displaygroupingcustomfield | 1 | block_myoverview |
168 | customfiltergrouping | textfield | block_myoverview |
169 And I log in as "student1"
170 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
171 When I click on "No Text field" "link" in the "Course overview" "block"
172 Then I should not see "Course 1" in the "Course overview" "block"
173 And I should see "Course 2" in the "Course overview" "block"
174 And I should not see "Course 3" in the "Course overview" "block"
175 And I should not see "Course 4" in the "Course overview" "block"
176 And I should not see "Course 5" in the "Course overview" "block"
e49543e8
SA
177
178 Scenario: Hidden fields not displayed when configuring the custom field filters
179 Given I log in as "admin"
180 When I navigate to "Plugins > Blocks > Course overview" in site administration
181 And I set the field "Custom field" to "1"
182 Then the "Field to use" select box should not contain "Hidden field"
183
184 Scenario: Hidden fields not displayed in the filter
185 Given the following config values are set as admin:
186 | displaygroupingcustomfield | 1 | block_myoverview |
187 | customfiltergrouping | textfield2 | block_myoverview |
188 And I log in as "admin"
189 And I navigate to "Courses > Course custom fields" in site administration
190 And I click on "Edit" "link" in the "Text field 2" "table_row"
191 And I set the field "Visible to" to "Nobody"
192 And I press "Save changes"
193 And I log out
194 When I log in as "student1"
195 And I click on "All (except removed from view)" "button" in the "Course overview" "block"
196 Then I should not see "penguin" in the "Course overview" "block"
197 Then I should not see "No text field" in the "Course overview" "block"