MDL-59759 enrol: Update behat tests for unenrol confirm dialogue
[moodle.git] / enrol / meta / tests / behat / enrol_meta.feature
CommitLineData
6f326bd2 1@enrol @enrol_meta @javascript
9e37d365
MG
2Feature: Enrolments are synchronised with meta courses
3 In order to simplify enrolments in parent courses
4 As a teacher
5 I need to be able to set up meta enrolments
6
7 Background:
8 Given the following "users" exist:
9 | username | firstname | lastname | email |
10 | student1 | Student | 1 | student1@asd.com |
11 | student2 | Student | 2 | student2@asd.com |
12 | student3 | Student | 3 | student3@asd.com |
13 | student4 | Student | 4 | student4@asd.com |
14 And the following "courses" exist:
15 | fullname | shortname |
6f326bd2
DW
16 | Course 1 | C1C1 |
17 | Course 2 | C2C2 |
18 | Course 3 | C3C3 |
06aa5923 19 | Course 4 | C4C4 |
9e37d365
MG
20 And the following "groups" exist:
21 | name | course | idnumber |
6f326bd2
DW
22 | Groupcourse 1 | C3C3 | G1 |
23 | Groupcourse 2 | C3C3 | G2 |
9e37d365 24 And the following "course enrolments" exist:
06aa5923
JP
25 | user | course | role | status |
26 | student1 | C1C1 | student | 0 |
27 | student2 | C1C1 | student | 0 |
28 | student3 | C1C1 | student | 0 |
29 | student4 | C1C1 | student | 0 |
30 | student1 | C2C2 | student | 0 |
31 | student2 | C2C2 | student | 0 |
32 | student1 | C4C4 | student | 0 |
33 | student2 | C4C4 | student | 1 |
9e37d365
MG
34 And I log in as "admin"
35 And I navigate to "Manage enrol plugins" node in "Site administration > Plugins > Enrolments"
36 And I click on "Enable" "link" in the "Course meta link" "table_row"
e5287f9b 37 And I am on course index
9e37d365 38
9e37d365 39 Scenario: Add meta enrolment instance without groups
fdeeaff9 40 When I am on "Course 3" course homepage
9e37d365 41 And I add "Course meta link" enrolment method with:
6f326bd2 42 | Link course | C1C1 |
9e37d365 43 And I navigate to "Enrolled users" node in "Course administration > Users"
5dd94c81
DW
44 Then I should see "No groups" in the "Student 1" "table_row"
45 And I should see "No groups" in the "Student 4" "table_row"
9e37d365 46
9e37d365 47 Scenario: Add meta enrolment instance with groups
fdeeaff9 48 When I am on "Course 3" course homepage
6f326bd2
DW
49 And I add "Course meta link" enrolment method with:
50 | Link course | C1C1 |
9e37d365 51 | Add to group | Groupcourse 1 |
fdeeaff9 52 And I am on "Course 3" course homepage
6f326bd2
DW
53 And I add "Course meta link" enrolment method with:
54 | Link course | C2C2 |
9e37d365 55 | Add to group | Groupcourse 2 |
9e37d365
MG
56 And I navigate to "Enrolled users" node in "Course administration > Users"
57 Then I should see "Groupcourse 1" in the "Student 1" "table_row"
58 And I should see "Groupcourse 1" in the "Student 2" "table_row"
59 And I should see "Groupcourse 1" in the "Student 3" "table_row"
60 And I should see "Groupcourse 1" in the "Student 4" "table_row"
61 And I should see "Groupcourse 2" in the "Student 1" "table_row"
62 And I should see "Groupcourse 2" in the "Student 2" "table_row"
63 And I should not see "Groupcourse 2" in the "Student 3" "table_row"
64 And I should not see "Groupcourse 2" in the "Student 4" "table_row"
65
e284e179 66 Scenario: Add meta enrolment instance with auto-created groups
fdeeaff9 67 When I am on "Course 3" course homepage
6f326bd2
DW
68 And I add "Course meta link" enrolment method with:
69 | Link course | C1C1 |
e284e179 70 | Add to group | Create new group |
e284e179
MG
71 And I navigate to "Enrolled users" node in "Course administration > Users"
72 Then I should see "Course 1 course" in the "Student 1" "table_row"
73 And I should see "Course 1 course" in the "Student 2" "table_row"
74 And I should see "Course 1 course" in the "Student 3" "table_row"
75 And I should see "Course 1 course" in the "Student 4" "table_row"
76 And I navigate to "Groups" node in "Course administration > Users"
77 And the "Groups" select box should contain "Course 1 course (4)"
78
9e37d365 79 Scenario: Backup and restore of meta enrolment instance
fdeeaff9 80 When I am on "Course 3" course homepage
6f326bd2
DW
81 And I add "Course meta link" enrolment method with:
82 | Link course | C1C1 |
9e37d365 83 | Add to group | Groupcourse 1 |
fdeeaff9 84 And I am on "Course 3" course homepage
6f326bd2
DW
85 And I add "Course meta link" enrolment method with:
86 | Link course | C2C2 |
9e37d365
MG
87 When I backup "Course 3" course using this options:
88 | Confirmation | Filename | test_backup.mbz |
89 And I click on "Restore" "link" in the "test_backup.mbz" "table_row"
90 And I press "Continue"
91 And I set the field "targetid" to "1"
92 And I click on "Continue" "button" in the ".bcs-new-course" "css_element"
93 And I press "Next"
3d4739ab 94 And I set the field "Course name" to "Course 5"
9e37d365
MG
95 And I press "Next"
96 And I press "Perform restore"
97 And I trigger cron
3d4739ab 98 And I am on "Course 5 copy 1" course homepage
9e37d365
MG
99 And I navigate to "Enrolment methods" node in "Course administration > Users"
100 Then I should see "Course meta link (Course 1)"
101 And I should see "Course meta link (Course 2)"
102 And I navigate to "Enrolled users" node in "Course administration > Users"
103 And I should see "Groupcourse 1" in the "Student 1" "table_row"
104 And I should see "Groupcourse 1" in the "Student 2" "table_row"
105 And I should see "Groupcourse 1" in the "Student 3" "table_row"
106 And I should see "Groupcourse 1" in the "Student 4" "table_row"
5dd94c81
DW
107 And I click on "[data-enrolinstancename='Course meta link (Course 2)'] a[data-action=showdetails]" "css_element" in the "Student 1" "table_row"
108 And I should see "Course meta link (Course 2)" in the "Enrolment method" "table_row"
06aa5923
JP
109
110 Scenario: Unenrol a user from the course participants page that was enrolled via course meta link.
111 Given I am on "Course 3" course homepage
112 And I add "Course meta link" enrolment method with:
113 | Link course | C4C4 |
114 And I navigate to course participants
115 # Suspended users can be unenrolled.
116 When I click on "//a[@data-action='unenrol']" "xpath_element" in the "student2" "table_row"
030ede54 117 And I click on "Unenrol" "button" in the "[data-region='modal']" "css_element"
06aa5923 118 Then I should not see "Student 2" in the "participants" "table"