2 Feature: Viewing the list of cohorts to enrol in a course
3 In order to ensure we only display the cohorts when applicable
5 I should only see the list of cohorts under some circumstances
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 |
14 And the following "course enrolments" exist:
15 | user | course | role |
16 | teacher1 | C1 | editingteacher |
19 Scenario: Check the teacher does not see the cohorts field without the proper capabilities
20 Given I log in as "admin"
21 And I set the following system permissions of "Teacher" role:
22 | capability | permission |
23 | moodle/cohort:manage | Prohibit |
24 | moodle/cohort:view | Prohibit |
25 And I navigate to "Cohorts" node in "Site administration > Users > Accounts"
26 And I follow "Add new cohort"
27 And I set the following fields to these values:
28 | Name | Test cohort name |
31 | Description | Test cohort description |
32 And I press "Save changes"
34 And I log in as "teacher1"
35 And I am on "Course 1" course homepage
36 And I navigate to course participants
37 When I press "Enrol users"
38 Then I should not see "Select cohorts"
39 And I should not see "Enrol selected users and cohorts"
42 Scenario: Check we show the cohorts field if there are some present
43 Given I log in as "admin"
44 And I navigate to "Cohorts" node in "Site administration > Users > Accounts"
45 And I follow "Add new cohort"
46 And I set the following fields to these values:
47 | Name | Test cohort name |
50 | Description | Test cohort description |
51 And I press "Save changes"
53 And I log in as "teacher1"
54 And I am on "Course 1" course homepage
55 And I navigate to course participants
56 When I press "Enrol users"
57 Then I should see "Select cohorts"
58 And I should see "Enrol selected users and cohorts"
61 Scenario: Check we do not show the cohorts field if there are none present
62 Given I log in as "teacher1"
63 And I am on "Course 1" course homepage
64 And I navigate to course participants
65 When I press "Enrol users"
66 Then I should not see "Select cohorts"
67 And I should not see "Enrol selected users and cohorts"