Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@core @core_course
2
Feature: Test category management actions
3
  As a moodle admin
4
  Test we can create a category
5
  Test we can create a sub category
6
  Test we can edit a category
7
  Test we can delete a category
8
  Test deleting categories interface when user permissions are restricted
9
  Test we can move a category
10
  Test we can assign roles within a category
11
  Test we can set permissions on a category
12
  Test we can manage cohorts within a category
13
  Test we can manage filters for a category
14
 
15
  Scenario: Test editing a category through the management interface.
16
    Given the following "categories" exist:
17
      | name | category | idnumber |
18
      | Cat 1 | 0 | CAT1 |
19
    And the following "courses" exist:
20
      | category | fullname | shortname | idnumber |
21
      | CAT1 | Course 1 | Course 1 | C1 |
22
 
23
    And I log in as "admin"
24
    And I go to the courses management page
25
    And I should see the "Course categories and courses" management page
26
    And I click on "edit" action for "Cat 1" in management category listing
27
    # Redirect
28
    And I should see "Edit category settings"
29
    And I should see "Cat 1"
30
    And I press "Cancel"
31
    # Redirect
32
    And I should see the "Course categories and courses" management page
33
    And I click on "edit" action for "Cat 1" in management category listing
34
    # Redirect
35
    And I should see "Edit category settings"
36
    And I should see "Cat 1"
37
    And I set the following fields to these values:
38
      | Category name | Category 1 (edited) |
39
      | Category ID number | CAT1e |
40
    And I press "Save changes"
41
    # Redirect
42
    And I should see the "Course categories and courses" management page
43
    And I should see "Category 1 (edited)" in the "#category-listing" "css_element"
44
    And I should see "Category 1 (edited)" in the "#course-listing h3" "css_element"
45
 
46
  @javascript
47
  Scenario: Test deleting a categories through the management interface.
48
    Given the following "categories" exist:
49
      | name | category | idnumber |
50
      | Cat 1 | 0 | CAT1 |
51
      | Cat 2 | 0 | CAT2 |
52
      | Cat 3 | 0 | CAT3 |
53
 
54
    And the following "courses" exist:
55
      | category | fullname | shortname | idnumber |
56
      | CAT3 | Course 1 | Course 1 | C1 |
57
 
58
    And I log in as "admin"
59
    And I go to the courses management page
60
    And I should see the "Course categories and courses" management page
61
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
62
    And I should see "Cat 2" in the "#category-listing ul" "css_element"
63
    And I should see "Cat 3" in the "#category-listing ul" "css_element"
64
    And I click on "delete" action for "Cat 2" in management category listing
65
    # Redirect
66
    And I should see "Delete category: Cat 2"
67
    And I should see "Contents of Cat 2"
68
    And I should see "This category is empty"
69
    And I press "Cancel"
70
    # Redirect
71
    And I should see the "Course categories and courses" management page
72
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
73
    And I should see "Cat 2" in the "#category-listing ul" "css_element"
74
    And I should see "Cat 3" in the "#category-listing ul" "css_element"
75
    And I click on "delete" action for "Cat 2" in management category listing
76
    # Redirect
77
    And I should see "Delete category: Cat 2"
78
    And I should see "Contents of Cat 2"
79
    And I should see "This category is empty"
80
    And I press "Delete"
81
    # Redirect
82
    And I should see "Delete category: Cat 2"
83
    And I should see "Deleted course category Cat 2"
84
    And I press "Continue"
85
    # Redirect
86
    And I should see the "Course categories and courses" management page
87
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
88
    And I should not see "Cat 2" in the "#category-listing ul" "css_element"
89
    And I should see "Cat 3" in the "#category-listing ul" "css_element"
90
    And I click on "delete" action for "Cat 3" in management category listing
91
    # Redirect
92
    And I should see "Delete category: Cat 3"
93
    And I set the following fields to these values:
94
      | What to do | Move contents to another category |
95
      | Move into  | Cat 1                             |
96
    And I press "Delete"
97
    # Redirect
98
    And I should see "Delete category: Cat 3"
99
    And I should see "Deleted course category Cat 3"
100
    And I press "Continue"
101
    # Redirect
102
    And I should see the "Course categories and courses" management page
103
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
104
    And I should not see "Cat 2" in the "#category-listing ul" "css_element"
105
    And I should not see "Cat 3" in the "#category-listing ul" "css_element"
106
    And I should see "Course 1" in the "#course-listing ul.course-list" "css_element"
107
 
108
  Scenario: Test deleting categories action is not listed when permissions are restricted.
109
    Given the following "users" exist:
110
      | username  | firstname | lastname |
111
      | manager   | Manager   | Manager  |
112
    And the following "categories" exist:
113
      | name | category | idnumber |
114
      | Cat 1 | 0 | CAT1 |
115
      | Cat 2 | 0 | CAT2 |
116
    And the following "courses" exist:
117
      | category | fullname | shortname |
118
      | CAT1 | Course 1 | C1 |
119
    And the following "system role assigns" exist:
120
      | user | role | contextlevel |
121
      | manager | manager | System |
122
    And the following "permission overrides" exist:
123
      | capability | permission | role | contextlevel | reference |
124
      | moodle/course:delete | Prevent | manager | Course | C1 |
125
      | moodle/course:create | Prevent | manager | System |    |
126
 
127
    When I log in as "manager"
128
    And I go to the courses management page
129
    Then I should see the "Course categories and courses" management page
130
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
131
    And I should see "Cat 2" in the "#category-listing ul" "css_element"
132
    And I open the action menu for "Cat 1" in management category listing
133
    And "Cat 1" category actions menu should not have "Delete" item
134
 
135
  Scenario: Test deleting categories interface when course create permission is restricted in system.
136
    Given the following "users" exist:
137
      | username  | firstname | lastname |
138
      | manager   | Manager   | Manager  |
139
    And the following "categories" exist:
140
      | name | category | idnumber |
141
      | Cat 1 | 0 | CAT1 |
142
      | Cat 2 | 0 | CAT2 |
143
    And the following "courses" exist:
144
      | category | fullname | shortname |
145
      | CAT1 | Course 1 | C1 |
146
    And the following "system role assigns" exist:
147
      | user | role | contextlevel |
148
      | manager | manager | System |
149
    And the following "permission overrides" exist:
150
      | capability | permission | role | contextlevel | reference |
151
      | moodle/course:delete | Allow | manager | Course | C1 |
152
      | moodle/course:create | Prevent | manager | System |    |
153
 
154
    When I log in as "manager"
155
    And I go to the courses management page
156
    And I open the action menu for "Cat 1" in management category listing
157
    Then "Cat 1" category actions menu should have "Delete" item
158
    And I click on "delete" action for "Cat 1" in management category listing
159
    # Redirect
160
    And I should see "Delete category: Cat 1"
161
    And I should see "Contents of Cat 1"
162
    And I should see "Delete all - cannot be undone"
163
    And "What to do" "select" should not exist
164
    And "Move into" "select" should not exist
165
    And I press "Cancel"
166
 
167
  Scenario: Test deleting categories interface when course delete permission is restricted for category.
168
    Given the following "users" exist:
169
      | username  | firstname | lastname |
170
      | manager   | Manager   | Manager  |
171
    And the following "categories" exist:
172
      | name | category | idnumber |
173
      | Cat 1 | 0 | CAT1 |
174
      | Cat 2 | 0 | CAT2 |
175
    And the following "courses" exist:
176
      | category | fullname | shortname |
177
      | CAT1 | Course 1 | C1 |
178
    And the following "system role assigns" exist:
179
      | user | role | contextlevel |
180
      | manager | manager | System |
181
    And the following "permission overrides" exist:
182
      | capability | permission | role | contextlevel | reference |
183
      | moodle/course:delete | Prevent | manager | Course | C1 |
184
      | moodle/course:create | Allow | manager | System |    |
185
 
186
    When I log in as "manager"
187
    And I go to the courses management page
188
    And I open the action menu for "Cat 1" in management category listing
189
    Then "Cat 1" category actions menu should have "Delete" item
190
    And I click on "delete" action for "Cat 1" in management category listing
191
    # Redirect
192
    And I should see "Delete category: Cat 1"
193
    And I should see "Contents of Cat 1"
194
    And I should see "Move contents to another category"
195
    And "What to do" "select" should not exist
196
    And "Move into" "select" should exist
197
    And the "Move into" select box should contain "Cat 2"
198
    And the "Move into" select box should contain "Category 1"
199
    And I press "Cancel"
200
 
201
  @javascript
202
  Scenario: Test deleting categories interface when course create permissions are restricted for some categories.
203
    Given the following "users" exist:
204
      | username  | firstname | lastname |
205
      | manager   | Manager   | Manager  |
206
    And the following "categories" exist:
207
      | name | category | idnumber |
208
      | Cat 1 | 0 | CAT1 |
209
      | Cat 2 | 0 | CAT2 |
210
    And the following "courses" exist:
211
      | category | fullname | shortname |
212
      | CAT1 | Course 1 | C1 |
213
    And the following "system role assigns" exist:
214
      | user | role | contextlevel |
215
      | manager | manager | System |
216
    And the following "permission overrides" exist:
217
      | capability | permission | role | contextlevel | reference |
218
      | moodle/course:delete | Allow | manager | Course | C1 |
219
      | moodle/course:create | Allow | manager | System |    |
220
      | moodle/course:create | Prevent | manager | Category | CAT2  |
221
 
222
    When I log in as "manager"
223
    And I go to the courses management page
224
    And I open the action menu for "Cat 1" in management category listing
225
    Then "Cat 1" category actions menu should have "Delete" item
226
    And I click on "delete" action for "Cat 1" in management category listing
227
    # Redirect
228
    And I should see "Delete category: Cat 1"
229
    And I should see "Contents of Cat 1"
230
    And "What to do" "select" should exist
231
    And I expand the "Move into" autocomplete
232
    And "Cat 2" "autocomplete_suggestions" should not exist
233
    And "Category 1" "autocomplete_selection" should be visible
234
    And I set the field "What to do" to "Delete all - cannot be undone"
235
    And "Move into" "select" should not be visible
236
    And I press "Cancel"
237
 
238
  @javascript
239
  Scenario: Test I can assign roles for a category through the management interface.
240
    Given the following "categories" exist:
241
      | name | category | idnumber |
242
      | Cat 1 | 0 | CAT1 |
243
    And the following "courses" exist:
244
      | category | fullname | shortname | idnumber |
245
      | CAT1 | Course 1 | Course 1 | C1 |
246
    And I log in as "admin"
247
    And I go to the courses management page
248
    And I should see the "Course categories and courses" management page
249
    And I click on "permissions" action for "Cat 1" in management category listing
250
    And I set the field "Participants tertiary navigation" to "Assign roles"
251
    # Redirect
252
    And I should see "Assign roles in Category: Cat 1"
253
    And I should see "Please choose a role to assign"
254
 
255
  Scenario: Test I can set access permissions for a category through the management interface.
256
    Given the following "categories" exist:
257
      | name | category | idnumber |
258
      | Cat 1 | 0 | CAT1 |
259
    And the following "courses" exist:
260
      | category | fullname | shortname | idnumber |
261
      | CAT1 | Course 1 | Course 1 | C1 |
262
 
263
    And I log in as "admin"
264
    And I go to the courses management page
265
    And I should see the "Course categories and courses" management page
266
    And I click on "permissions" action for "Cat 1" in management category listing
267
    # Redirect
268
    And I should see "Permissions in Category: Cat 1"
269
    And I click on "Back to Category: Cat 1" "link"
270
    # Redirect
271
    And I should see "Cat 1" in the "h1" "css_element"
272
 
273
  Scenario: Test clicking to manage cohorts for a category through the management interface.
274
    Given the following "categories" exist:
275
      | name | category | idnumber |
276
      | Cat 1 | 0 | CAT1 |
277
    And the following "courses" exist:
278
      | category | fullname | shortname | idnumber |
279
      | CAT1 | Course 1 | Course 1 | C1 |
280
 
281
    And I log in as "admin"
282
    And I go to the courses management page
283
    And I should see the "Course categories and courses" management page
284
    And I click on "cohorts" action for "Cat 1" in management category listing
285
    # Redirect
286
    And I should see "Cohorts"
287
 
288
  Scenario: Test configuring filters for a category
289
    Given the following "categories" exist:
290
      | name | category | idnumber |
291
      | Cat 1 | 0 | CAT1 |
292
    And the following "courses" exist:
293
      | category | fullname | shortname | idnumber |
294
      | CAT1 | Course 1 | Course 1 | C1 |
295
 
296
    And I log in as "admin"
297
    And I go to the courses management page
298
    And I should see the "Course categories and courses" management page
299
    And I click on "filters" action for "Cat 1" in management category listing
300
    # Redirect
301
    And I should see "Filter settings in Category: Cat 1"
302
    And I click on "Back to Category: Cat 1" "link"
303
    # Redirect
304
    And I should see the "Course categories and courses" management page
305
    And I should see "Cat 1" in the "#course-listing h3" "css_element"
306
 
307
  @javascript
308
  Scenario: Test that I can create a category and view it in the management interface
309
    Given the following "categories" exist:
310
      | name | category | idnumber |
311
      | Cat 1 | 0 | CAT1 |
312
    And I log in as "admin"
313
    And I go to the courses management page
314
    And I should see the "Course categories and courses" management page
315
    And I click on "Create new category" "link" in the ".category-listing-actions" "css_element"
316
    # Redirect.
317
    And I should see "Add new category"
318
    And I set the following fields to these values:
319
      | Parent category | Top |
320
      | Category name | Test category 2 |
321
      | Category ID number | TC2 |
322
    And I press "Create category"
323
    # Redirect
324
    And I should see the "Course categories and courses" management page
325
    And I should see "Test category 2" in the "#course-listing h3" "css_element"
326
    And I should see category listing "Cat 1" before "Test category 2"
327
    And I should see "No courses in this category"
328
    And I click on "createnewsubcategory" action for "Test category 2" in management category listing
329
    # Redirect
330
    And I should see "Add new category"
331
    And I set the following fields to these values:
332
      | Parent category | Top |
333
      | Category name | Test category 3 |
334
      | Category ID number | TC3 |
335
    And I press "Create category"
336
    # Redirect
337
    And I should see the "Course categories and courses" management page
338
    And I should see "Test category 3" in the "#course-listing h3" "css_element"
339
    And I should see category listing "Cat 1" before "Test category 2"
340
    And I should see "No courses in this category"
341
 
342
  @javascript
343
  Scenario: Test moving a categories through the management interface.
344
    Given the following "categories" exist:
345
      | name | category | idnumber |
346
      | Cat 1 | 0 | CAT1 |
347
      | Cat 2 | 0 | CAT2 |
348
      | Cat 3 | 0 | CAT3 |
349
 
350
    And I log in as "admin"
351
    And I go to the courses management page
352
    And I should see the "Course categories and courses" management page
353
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
354
    And I should see "Cat 2" in the "#category-listing ul" "css_element"
355
    And I should see "Cat 3" in the "#category-listing ul" "css_element"
356
    And I select category "Cat 2" in the management interface
357
    And I select category "Cat 3" in the management interface
358
    And I set the field "menumovecategoriesto" to "Cat 1"
359
    When I press "bulkmovecategories"
360
    # Redirect
361
    And I click on category "Cat 1" in the management interface
362
    # Redirect
363
    Then I should see category "CAT3" as subcategory of "CAT1" in the management interface
364
    And I move category "Cat 3" to top level in the management interface
365
    # Redirect
366
    And I should not see category "CAT3" as subcategory of "CAT1" in the management interface
367
    Then I should see category "CAT2" as subcategory of "CAT1" in the management interface
368
 
369
  @javascript
370
  Scenario: Test bulk action is shown only when some category/course is selected
371
    Given the following "categories" exist:
372
      | name | category | idnumber |
373
      | Cat 1 | 0 | CAT1 |
374
      | Cat 2 | 0 | CAT2 |
375
      | Cat 3 | 0 | CAT3 |
376
    And the following "courses" exist:
377
      | category | fullname | shortname | idnumber |
378
      | CAT3 | Course 1 | Course 1 | C1 |
379
      | CAT3 | Course 2 | Course 2 | C2 |
380
 
381
    And I log in as "admin"
382
    And I go to the courses management page
383
    And I should see the "Course categories and courses" management page
384
    And I should see "Cat 1" in the "#category-listing ul" "css_element"
385
    And I should see "Cat 2" in the "#category-listing ul" "css_element"
386
    And I should see "Cat 3" in the "#category-listing ul" "css_element"
387
    And the "movecategoriesto" "select" should be disabled
388
    And the "resortcategoriesby" "select" should be disabled
389
    And the "resortcoursesby" "select" should be disabled
390
    When I set the field "selectsortby" to "allcategories"
391
    Then the "resortcategoriesby" "select" should be enabled
392
    And the "resortcoursesby" "select" should be enabled
393
    And the "movecategoriesto" "select" should be disabled
394
    And I select category "Cat 2" in the management interface
395
    And the "movecategoriesto" "select" should be enabled
396
    And the "resortcategoriesby" "select" should be enabled
397
    And the "resortcoursesby" "select" should be enabled
398
    And I set the field "selectsortby" to "selectedcategories"
399
    And the "movecategoriesto" "select" should be enabled
400
    And the "resortcategoriesby" "select" should be enabled
401
    And the "resortcoursesby" "select" should be enabled
402
    And I unselect category "Cat 2" in the management interface
403
    And the "movecategoriesto" "select" should be disabled
404
    And the "resortcategoriesby" "select" should be disabled
405
    And the "resortcoursesby" "select" should be disabled
406
    And I select category "Cat 3" in the management interface
407
    And the "movecategoriesto" "select" should be enabled
408
    And the "resortcategoriesby" "select" should be enabled
409
    And the "resortcoursesby" "select" should be enabled
410
    And I select category "Cat 2" in the management interface
411
    And the "movecategoriesto" "select" should be enabled
412
    And the "resortcategoriesby" "select" should be enabled
413
    And the "resortcoursesby" "select" should be enabled
414
    And I unselect category "Cat 2" in the management interface
415
    And I unselect category "Cat 3" in the management interface
416
    And the "movecategoriesto" "select" should be disabled
417
    And the "resortcategoriesby" "select" should be disabled
418
    And the "resortcoursesby" "select" should be disabled
419
    And I click on category "Cat 1" in the management interface
420
    # Redirect.
421
    And I should see the "Course categories and courses" management page
422
    And the "movecategoriesto" "select" should be disabled
423
    And the "resortcategoriesby" "select" should be disabled
424
    And the "resortcoursesby" "select" should be disabled
425
    And the "movecoursesto" "select" should be disabled
426
    And I click on category "Cat 3" in the management interface
427
    #Redirect
428
    And I should see the "Course categories and courses" management page
429
    And I should see "Course 1" in the "#course-listing ul.course-list" "css_element"
430
    And I should see "Course 2" in the "#course-listing ul.course-list" "css_element"
431
    And the "movecategoriesto" "select" should be disabled
432
    And the "resortcategoriesby" "select" should be disabled
433
    And the "resortcoursesby" "select" should be disabled
434
    And the "movecoursesto" "select" should be disabled
435
    And I select course "Course 1" in the management interface
436
    And the "movecoursesto" "select" should be enabled
437
    And the "movecategoriesto" "select" should be disabled
438
    And the "resortcategoriesby" "select" should be disabled
439
    And the "resortcoursesby" "select" should be disabled
440
    And I select course "Course 2" in the management interface
441
    And the "movecoursesto" "select" should be enabled
442
    And the "movecategoriesto" "select" should be disabled
443
    And the "resortcategoriesby" "select" should be disabled
444
    And the "resortcoursesby" "select" should be disabled
445
    And I select category "Cat 3" in the management interface
446
    And the "movecoursesto" "select" should be enabled
447
    And the "movecategoriesto" "select" should be enabled
448
    And the "resortcategoriesby" "select" should be enabled
449
    And the "resortcoursesby" "select" should be enabled
450
    And I unselect course "Course 2" in the management interface
451
    And the "movecoursesto" "select" should be enabled
452
    And the "movecategoriesto" "select" should be enabled
453
    And the "resortcategoriesby" "select" should be enabled
454
    And the "resortcoursesby" "select" should be enabled
455
    And I unselect course "Course 1" in the management interface
456
    And the "movecoursesto" "select" should be disabled
457
    And the "movecategoriesto" "select" should be enabled
458
    And the "resortcategoriesby" "select" should be enabled
459
    And the "resortcoursesby" "select" should be enabled
460
    And I unselect category "Cat 3" in the management interface
461
    And the "movecoursesto" "select" should be disabled
462
    And the "movecategoriesto" "select" should be disabled
463
    And the "resortcategoriesby" "select" should be disabled
464
    And the "resortcoursesby" "select" should be disabled
465
 
466
  Scenario: Test that is not possible to create a course category with a duplicate idnumber
467
    Given the following "categories" exist:
468
      | name | category | idnumber |
469
      | Cat 1 | 0 | CAT1 |
470
    And I log in as "admin"
471
    And I navigate to "Courses > Add a category" in site administration
472
    And I set the following fields to these values:
473
      | Category name | Test duplicate |
474
      | Category ID number | CAT1 |
475
    When I press "Create category"
476
    Then I should see "ID number is already used for another category"
477
 
478
  Scenario: Test that is possible to remove an idnumber from a course category
479
    Given the following "categories" exist:
480
      | name | category | idnumber |
481
      | Cat 1 | 0 | CAT1 |
482
      | Cat 2 | 0 ||
483
    And I log in as "admin"
484
    And I go to the courses management page
485
    And I should see "CAT1" in the "#category-listing" "css_element"
486
    When I click on "edit" action for "Cat 1" in management category listing
487
    And I set the following fields to these values:
488
      | Category name | Category 1 (edited) |
489
      | Category ID number ||
490
    And I press "Save changes"
491
    # Redirect
492
    Then I should see "Category 1 (edited)" in the "#category-listing" "css_element"
493
    And I should not see "CAT1" in the "#course-listing" "css_element"