1 |
efrain |
1 |
@mod @mod_data
|
|
|
2 |
Feature: Users can view and manage data presets
|
|
|
3 |
In order to use presets
|
|
|
4 |
As a user
|
|
|
5 |
I need to view, manage and use presets
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
11 |
And the following "courses" exist:
|
|
|
12 |
| fullname | shortname | category |
|
|
|
13 |
| Course 1 | C1 | 0 |
|
|
|
14 |
And the following "course enrolments" exist:
|
|
|
15 |
| user | course | role |
|
|
|
16 |
| teacher1 | C1 | editingteacher |
|
|
|
17 |
And the following "activities" exist:
|
|
|
18 |
| activity | name | intro | course | idnumber |
|
|
|
19 |
| data | Mountain landscapes | n | C1 | data1 |
|
|
|
20 |
And the following "mod_data > presets" exist:
|
|
|
21 |
| database | name | description | user |
|
|
|
22 |
| data1 | Saved preset 1 | The preset1 has description | admin |
|
|
|
23 |
| data1 | Saved preset 2 | | admin |
|
|
|
24 |
| data1 | Saved preset by teacher1 | This preset has also a description | teacher1 |
|
|
|
25 |
|
|
|
26 |
@javascript
|
|
|
27 |
Scenario: Admins can delete saved presets
|
|
|
28 |
Given I am on the "Mountain landscapes" "data activity" page logged in as admin
|
|
|
29 |
When I follow "Presets"
|
|
|
30 |
Then I should see "Choose a preset to use as a starting point."
|
|
|
31 |
And I should see "Image gallery"
|
|
|
32 |
And I should see "Saved preset 1"
|
|
|
33 |
And I should see "Saved preset 2"
|
|
|
34 |
And I should see "Saved preset by teacher1"
|
|
|
35 |
# Plugin presets can't be removed.
|
|
|
36 |
And I should not see "Actions" in the "Image gallery" "table_row"
|
|
|
37 |
# The admin should be able to delete saved presets.
|
|
|
38 |
But I open the action menu in "Saved preset 1" "table_row"
|
|
|
39 |
And I should see "Delete"
|
|
|
40 |
And I press the escape key
|
|
|
41 |
And I open the action menu in "Saved preset 2" "table_row"
|
|
|
42 |
And I should see "Delete"
|
|
|
43 |
And I press the escape key
|
|
|
44 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
45 |
And I should see "Delete"
|
|
|
46 |
|
|
|
47 |
@javascript
|
|
|
48 |
Scenario: Teachers can see and use presets
|
|
|
49 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
50 |
When I follow "Presets"
|
|
|
51 |
Then I should see "Choose a preset to use as a starting point."
|
|
|
52 |
And I should see "Image gallery"
|
|
|
53 |
And I should see "Use this preset to collect images." in the "Image gallery" "table_row"
|
|
|
54 |
And I should see "Saved preset 1"
|
|
|
55 |
And I should see "The preset1 has description" in the "Saved preset 1" "table_row"
|
|
|
56 |
And I should see "Saved preset 2"
|
|
|
57 |
And I should see "Saved preset by teacher1"
|
|
|
58 |
And I should see "This preset has also a description" in the "Saved preset by teacher1" "table_row"
|
|
|
59 |
# Plugin presets can't be removed.
|
|
|
60 |
And I should not see "Actions" in the "Image gallery" "table_row"
|
|
|
61 |
# Teachers should be able to delete their saved presets.
|
|
|
62 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
63 |
And I should see "Delete"
|
|
|
64 |
# Teachers can't delete the presets they haven't created.
|
|
|
65 |
And I should not see "Actions" in the "Saved preset 1" "table_row"
|
|
|
66 |
# The "Use this preset" button should be enabled only when a preset is selected.
|
|
|
67 |
And the "Use this preset" "button" should be disabled
|
|
|
68 |
And I click on "fullname" "radio" in the "Image gallery" "table_row"
|
|
|
69 |
And the "Use this preset" "button" should be enabled
|
|
|
70 |
|
|
|
71 |
@javascript
|
|
|
72 |
Scenario: Only users with the viewalluserpresets capability can see presets created by other users
|
|
|
73 |
Given the following "permission override" exists:
|
|
|
74 |
| role | editingteacher |
|
|
|
75 |
| capability | mod/data:viewalluserpresets |
|
|
|
76 |
| permission | Prohibit |
|
|
|
77 |
| contextlevel | System |
|
|
|
78 |
| reference | |
|
|
|
79 |
When I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
80 |
And I follow "Presets"
|
|
|
81 |
Then I should see "Image gallery"
|
|
|
82 |
And I should not see "Saved preset 1"
|
|
|
83 |
And I should not see "Saved preset 2"
|
|
|
84 |
But I should see "Saved preset by teacher1"
|
|
|
85 |
|
|
|
86 |
@javascript
|
|
|
87 |
Scenario: Teachers can save presets
|
|
|
88 |
Given the following "mod_data > fields" exist:
|
|
|
89 |
| database | type | name | description |
|
|
|
90 |
| data1 | text | Test field name | Test field description |
|
|
|
91 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
92 |
And I follow "Templates"
|
|
|
93 |
When I click on "Actions" "button"
|
|
|
94 |
And I choose "Publish preset on this site" in the open action menu
|
|
|
95 |
Then I should see "Name" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
96 |
And I should see "Description" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
97 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should not be visible
|
|
|
98 |
# Teacher should be able to save preset.
|
|
|
99 |
And I set the field "Name" to "New saved preset"
|
|
|
100 |
And I set the field "Description" to "My funny description goes here."
|
|
|
101 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
102 |
And I should see "Preset saved."
|
|
|
103 |
And I follow "Presets"
|
|
|
104 |
And I should see "New saved preset"
|
|
|
105 |
And I should see "My funny description goes here." in the "New saved preset" "table_row"
|
|
|
106 |
# Teacher can't overwrite an existing preset that they haven't created.
|
|
|
107 |
And I follow "Templates"
|
|
|
108 |
And I click on "Actions" "button"
|
|
|
109 |
And I choose "Publish preset on this site" in the open action menu
|
|
|
110 |
And I set the field "Name" to "Saved preset 1"
|
|
|
111 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
112 |
And I should see "A preset with this name already exists. Choose a different name."
|
|
|
113 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should not be visible
|
|
|
114 |
# Teacher can overwrite existing presets created by them, but they are not overwritten if the checkbox is not marked.
|
|
|
115 |
And I set the field "Name" to "New saved preset"
|
|
|
116 |
And I set the field "Description" to "This is a new description that shouldn't be saved."
|
|
|
117 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
118 |
And I should see "A preset with this name already exists."
|
|
|
119 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
|
|
|
120 |
# Confirm the checkbox is still displayed and nothing happens if it's not checked and no change is done in the name.
|
|
|
121 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
122 |
And I should see "A preset with this name already exists."
|
|
|
123 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
|
|
|
124 |
And I click on "Cancel" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
125 |
And I follow "Presets"
|
|
|
126 |
And I should see "New saved preset"
|
|
|
127 |
And I should see "My funny description goes here." in the "New saved preset" "table_row"
|
|
|
128 |
And I should not see "This is a new description that shouldn't be saved."
|
|
|
129 |
# But teacher can overwrite existing presets created by them.
|
|
|
130 |
But I follow "Templates"
|
|
|
131 |
And I click on "Actions" "button"
|
|
|
132 |
And I choose "Publish preset on this site" in the open action menu
|
|
|
133 |
And I set the field "Name" to "New saved preset"
|
|
|
134 |
And I set the field "Description" to "This is a new description that will be overwritten."
|
|
|
135 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
136 |
And I should see "A preset with this name already exists."
|
|
|
137 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
|
|
|
138 |
And I click on "Replace existing preset with this name and overwrite its contents" "checkbox" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
139 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
140 |
And I should see "Preset saved."
|
|
|
141 |
And I follow "Presets"
|
|
|
142 |
And I should see "New saved preset"
|
|
|
143 |
And I should see "This is a new description that will be overwritten." in the "New saved preset" "table_row"
|
|
|
144 |
And I should not see "My funny description goes here." in the "New saved preset" "table_row"
|
|
|
145 |
|
|
|
146 |
@javascript
|
|
|
147 |
Scenario: Teachers can edit presets
|
|
|
148 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
149 |
When I follow "Presets"
|
|
|
150 |
# Plugin presets can't be edited.
|
|
|
151 |
Then I should not see "Actions" in the "Image gallery" "table_row"
|
|
|
152 |
# Teachers can't edit the presets they haven't created.
|
|
|
153 |
And I should not see "Actions" in the "Saved preset 1" "table_row"
|
|
|
154 |
# Teachers should be able to edit their saved presets.
|
|
|
155 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
156 |
And I choose "Edit" in the open action menu
|
|
|
157 |
And I set the field "Name" to "RENAMED preset by teacher1"
|
|
|
158 |
And I set the field "Description" to "My funny description goes here."
|
|
|
159 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
160 |
And I should see "Preset saved."
|
|
|
161 |
And I should see "RENAMED preset by teacher1"
|
|
|
162 |
And I should see "My funny description goes here." in the "RENAMED preset by teacher1" "table_row"
|
|
|
163 |
And I should not see "Saved preset by teacher1"
|
|
|
164 |
And I should not see "This preset has also a description"
|
|
|
165 |
|
|
|
166 |
@javascript
|
|
|
167 |
Scenario: Nothing happens when teachers edit a preset and do not change anything
|
|
|
168 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
169 |
When I follow "Presets"
|
|
|
170 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
171 |
And I choose "Edit" in the open action menu
|
|
|
172 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
173 |
Then I should not see "Preset saved."
|
|
|
174 |
And I should see "Saved preset by teacher1"
|
|
|
175 |
|
|
|
176 |
@javascript
|
|
|
177 |
Scenario: Teachers can edit presets and overwrite them if they are the authors
|
|
|
178 |
Given the following "mod_data > preset" exists:
|
|
|
179 |
| database | data1 |
|
|
|
180 |
| name | Another preset created by teacher1 |
|
|
|
181 |
| description | This description will be overwritten |
|
|
|
182 |
| user | teacher1 |
|
|
|
183 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
184 |
When I follow "Presets"
|
|
|
185 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
186 |
And I choose "Edit" in the open action menu
|
|
|
187 |
And I set the field "Name" to "Another preset created by teacher1"
|
|
|
188 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
189 |
Then I should see "A preset with this name already exists."
|
|
|
190 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
|
|
|
191 |
# If the checkbox is not selected, the preset shoudn't be saved.
|
|
|
192 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
193 |
And I should see "A preset with this name already exists."
|
|
|
194 |
# But when I select the overwrite checkbox, the preset should be overwritten.
|
|
|
195 |
But I click on "Replace existing preset with this name and overwrite its contents" "checkbox" in the "Edit preset" "dialogue"
|
|
|
196 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
197 |
And I should see "Preset saved."
|
|
|
198 |
And I should see "Another preset created by teacher1"
|
|
|
199 |
And I should see "This preset has also a description" in the "Another preset created by teacher1" "table_row"
|
|
|
200 |
And I should not see "Saved preset by teacher1"
|
|
|
201 |
And I should not see "This description will be overwritten"
|
|
|
202 |
|
|
|
203 |
@javascript
|
|
|
204 |
Scenario: Teachers cannot overwrite presets if they are not the authors
|
|
|
205 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
206 |
When I follow "Presets"
|
|
|
207 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
208 |
And I choose "Edit" in the open action menu
|
|
|
209 |
And I set the field "Name" to "Saved preset 1"
|
|
|
210 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
211 |
Then I should see " A preset with this name already exists. Choose a different name."
|
|
|
212 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should not be visible
|
|
|
213 |
# If the teacher clicks again the Save button, the preset shoudn't be saved.
|
|
|
214 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
215 |
And I should see " A preset with this name already exists. Choose a different name."
|
|
|
216 |
# But if they set a different name (which doesn't exist), the preset should be saved.
|
|
|
217 |
And I set the field "Name" to "New saved preset"
|
|
|
218 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
219 |
And I should see "Preset saved."
|
|
|
220 |
And I should see "New saved preset"
|
|
|
221 |
And I should see "This preset has also a description" in the "New saved preset" "table_row"
|
|
|
222 |
And I should not see "Saved preset by teacher1"
|
|
|
223 |
|
|
|
224 |
@javascript
|
|
|
225 |
Scenario: Admins can overwrite presets even if they are not the authors
|
|
|
226 |
Given I am on the "Mountain landscapes" "data activity" page logged in as admin
|
|
|
227 |
When I follow "Presets"
|
|
|
228 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
229 |
And I choose "Edit" in the open action menu
|
|
|
230 |
And I set the field "Name" to "Saved preset 1"
|
|
|
231 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
232 |
Then I should see " A preset with this name already exists."
|
|
|
233 |
And "Replace existing preset with this name and overwrite its contents" "checkbox" should be visible
|
|
|
234 |
# But when admin selects the overwrite checkbox, the preset should be overwritten.
|
|
|
235 |
But I click on "Replace existing preset with this name and overwrite its contents" "checkbox" in the "Edit preset" "dialogue"
|
|
|
236 |
And I click on "Save" "button" in the "Edit preset" "dialogue"
|
|
|
237 |
And I should see "Preset saved."
|
|
|
238 |
And I should see "Saved preset 1"
|
|
|
239 |
And I should see "This preset has also a description" in the "Saved preset 1" "table_row"
|
|
|
240 |
And I should not see "Saved preset by teacher1"
|
|
|
241 |
And I should not see "The preset1 has description"
|
|
|
242 |
|
|
|
243 |
@javascript
|
|
|
244 |
Scenario: Teachers can delete their own presets
|
|
|
245 |
Given the following "mod_data > fields" exist:
|
|
|
246 |
| database | type | name | description |
|
|
|
247 |
| data1 | text | Test field name | Test field description |
|
|
|
248 |
And the following "mod_data > presets" exist:
|
|
|
249 |
| database | name | description | user |
|
|
|
250 |
| data1 | Saved preset by teacher1 | My funny description goes here. | teacher1 |
|
|
|
251 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
252 |
When I follow "Presets"
|
|
|
253 |
And I should see "Image gallery"
|
|
|
254 |
And I should see "Saved preset 1"
|
|
|
255 |
And I should see "Saved preset by teacher1"
|
|
|
256 |
# Plugin presets can't be removed.
|
|
|
257 |
And I should not see "Actions" in the "Image gallery" "table_row"
|
|
|
258 |
# The teacher should not be able to delete presets saved by others.
|
|
|
259 |
And I should not see "Actions" in the "Saved preset 1" "table_row"
|
|
|
260 |
# The teacher should be able to delete their own preset.
|
|
|
261 |
And I open the action menu in "Saved preset by teacher" "table_row"
|
|
|
262 |
And I follow "Delete"
|
|
|
263 |
And I click on "Delete" "button" in the "Delete preset Saved preset by teacher1?" "dialogue"
|
|
|
264 |
And I should see "Preset deleted"
|
|
|
265 |
And I should not see "Saved preset by teacher1"
|
|
|
266 |
|
|
|
267 |
@javascript
|
|
|
268 |
Scenario: Teachers can preview a saved preset from the notification
|
|
|
269 |
Given the following "mod_data > fields" exist:
|
|
|
270 |
| database | type | name | description |
|
|
|
271 |
| data1 | text | Test field name | Test field description |
|
|
|
272 |
And the following "mod_data > templates" exist:
|
|
|
273 |
| database | name |
|
|
|
274 |
| data1 | singletemplate |
|
|
|
275 |
| data1 | listtemplate |
|
|
|
276 |
| data1 | addtemplate |
|
|
|
277 |
| data1 | asearchtemplate |
|
|
|
278 |
| data1 | rsstemplate |
|
|
|
279 |
And I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
280 |
And I follow "Templates"
|
|
|
281 |
And I click on "Actions" "button"
|
|
|
282 |
And I choose "Publish preset on this site" in the open action menu
|
|
|
283 |
And I set the field "Name" to "New saved preset"
|
|
|
284 |
And I set the field "Description" to "My funny description goes here."
|
|
|
285 |
And I click on "Save" "button" in the "Save all fields and templates and publish as preset on this site" "dialogue"
|
|
|
286 |
And I should see "Preset saved"
|
|
|
287 |
When I click on "Preview preset" "link"
|
|
|
288 |
Then I should see "Preview"
|
|
|
289 |
And I should see "New saved preset"
|
|
|
290 |
And I should see "Test field name"
|
|
|
291 |
And I should see "This is a short text"
|
|
|
292 |
Then "Use this preset" "button" should exist
|
|
|
293 |
|
|
|
294 |
@javascript
|
|
|
295 |
Scenario: Teachers can export any saved preset
|
|
|
296 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
297 |
When I follow "Presets"
|
|
|
298 |
# Plugin presets can't be exported.
|
|
|
299 |
And I should not see "Actions" in the "Image gallery" "table_row"
|
|
|
300 |
# The teacher should be able to export any saved preset.
|
|
|
301 |
And I open the action menu in "Saved preset by teacher1" "table_row"
|
|
|
302 |
Then I should see "Export"
|
|
|
303 |
And following "Export" "link" in the "Saved preset by teacher1" "table_row" should download between "1" and "5000" bytes
|
|
|
304 |
And I open the action menu in "Saved preset 1" "table_row"
|
|
|
305 |
And I should see "Export"
|
|
|
306 |
And following "Export" "link" in the "Saved preset 1" "table_row" should download between "1" and "5000" bytes
|
|
|
307 |
|
|
|
308 |
@javascript @_file_upload
|
|
|
309 |
Scenario Outline: Admins and Teachers can load a preset from a file
|
|
|
310 |
Given I am on the "Mountain landscapes" "data activity" page logged in as <user>
|
|
|
311 |
When I follow "Presets"
|
|
|
312 |
Then I click on "Actions" "button"
|
|
|
313 |
And I choose "Import preset" in the open action menu
|
|
|
314 |
And I upload "mod/data/tests/fixtures/image_gallery_preset.zip" file to "Preset file" filemanager
|
|
|
315 |
Then I click on "Import preset and apply" "button" in the ".modal-dialog" "css_element"
|
|
|
316 |
Then I should see "Preset applied"
|
|
|
317 |
# I am on the field page.
|
|
|
318 |
And I should see "Manage fields"
|
|
|
319 |
Then I should see "Preset applied"
|
|
|
320 |
|
|
|
321 |
Examples:
|
|
|
322 |
| user |
|
|
|
323 |
| admin |
|
|
|
324 |
| teacher1 |
|
|
|
325 |
|
|
|
326 |
@javascript
|
|
|
327 |
Scenario Outline: Teachers can use "Use this preset" actions menu next to each preset.
|
|
|
328 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
329 |
And I follow "Presets"
|
|
|
330 |
And I open the action menu in "<Preset Name>" "table_row"
|
|
|
331 |
When I click on "Use this preset" "link" in the "<Preset Name>" "table_row"
|
|
|
332 |
Then I should see "Preset applied"
|
|
|
333 |
|
|
|
334 |
Examples:
|
|
|
335 |
| Preset Name |
|
|
|
336 |
| Image gallery |
|
|
|
337 |
| Saved preset 1 (Admin User) |
|
|
|
338 |
| Saved preset by teacher1 (Teacher 1) |
|
|
|
339 |
|
|
|
340 |
@javascript
|
|
|
341 |
Scenario Outline: Teachers can use "Preview" actions menu next to each preset.
|
|
|
342 |
Given I am on the "Mountain landscapes" "data activity" page logged in as teacher1
|
|
|
343 |
And I follow "Presets"
|
|
|
344 |
And I open the action menu in "<Preset Name>" "table_row"
|
|
|
345 |
When I click on "Preview" "link" in the "<Preset Name>" "table_row"
|
|
|
346 |
Then I should see "Preview of <Preset preview name>"
|
|
|
347 |
|
|
|
348 |
Examples:
|
|
|
349 |
| Preset Name | Preset preview name |
|
|
|
350 |
| Image gallery | Image gallery |
|
|
|
351 |
| Saved preset 1 (Admin User) | Saved preset 1 |
|
|
|
352 |
| Saved preset by teacher1 (Teacher 1) | Saved preset by teacher1 |
|