MDL-60590 core_user: added Behat test for cohort list presence
[moodle.git] / user / tests / behat / enrol_cohort_list.feature
blob467c56b1191dca7153e5e8fb5a41a95079fc1e3b
1 @core @core_user
2 Feature: Viewing the list of cohorts to enrol in a course
3   In order to ensure we only display the cohorts when applicable
4   As a teacher
5   I should only see the list of cohorts under some circumstances
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 |
13       | Course 1 | C1        |
14     And the following "course enrolments" exist:
15       | user      | course | role           |
16       | teacher1  | C1     | editingteacher |
18   @javascript
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        |
29       | Context     | System                  |
30       | Cohort ID   | 1337                    |
31       | Description | Test cohort description |
32     And I press "Save changes"
33     And I log out
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"
41   @javascript
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        |
48       | Context     | System                  |
49       | Cohort ID   | 1337                    |
50       | Description | Test cohort description |
51     And I press "Save changes"
52     And I log out
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"
60   @javascript
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"