| 1 | efrain | 1 | @enrol @enrol_cohort
 | 
        
           |  |  | 2 | Feature: Unenrol action to disable course enrolment
 | 
        
           |  |  | 3 |   | 
        
           |  |  | 4 |   Background:
 | 
        
           |  |  | 5 |     Given the following "users" exist:
 | 
        
           |  |  | 6 |       | username    | firstname | lastname | email                   |
 | 
        
           |  |  | 7 |       | teacher001  | Teacher   | 001      | teacher001@example.com  |
 | 
        
           |  |  | 8 |       | student001  | Student   | 001      | student001@example.com  |
 | 
        
           |  |  | 9 |       | student002  | Student   | 002      | student002@example.com  |
 | 
        
           |  |  | 10 |       | student003  | Student   | 003      | student003@example.com  |
 | 
        
           |  |  | 11 |       | student004  | Student   | 004      | student004@example.com  |
 | 
        
           |  |  | 12 |     And the following "cohorts" exist:
 | 
        
           |  |  | 13 |       | name                 | idnumber | visible |
 | 
        
           |  |  | 14 |       | System cohort        | CVO      | 1       |
 | 
        
           |  |  | 15 |     And the following "cohort members" exist:
 | 
        
           |  |  | 16 |       | user       | cohort     |
 | 
        
           |  |  | 17 |       | student001 | CVO        |
 | 
        
           |  |  | 18 |       | student002 | CVO        |
 | 
        
           |  |  | 19 |       | student003 | CVO        |
 | 
        
           |  |  | 20 |       | student004 | CVO        |
 | 
        
           |  |  | 21 |     And the following "courses" exist:
 | 
        
           |  |  | 22 |       | fullname   | shortname | format | startdate       |
 | 
        
           |  |  | 23 |       | Course 001 | C001      | weeks  | ##1 month ago## |
 | 
        
           |  |  | 24 |     And the following "course enrolments" exist:
 | 
        
           |  |  | 25 |       | user       | course | role           | timestart       |
 | 
        
           |  |  | 26 |       | teacher001 | C001   | editingteacher | ##1 month ago## |
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 |   @javascript @skip_chrome_zerosize
 | 
        
           |  |  | 29 |   Scenario: Removing the user from the cohort will suspend the enrolment but keep the role
 | 
        
           |  |  | 30 |     When I log in as "teacher001"
 | 
        
           |  |  | 31 |     And I am on the "Course 001" "enrolment methods" page
 | 
        
           |  |  | 32 |     And I select "Cohort sync" from the "Add method" singleselect
 | 
        
           |  |  | 33 |     And I open the autocomplete suggestions list
 | 
        
           |  |  | 34 |     Then "System cohort" "autocomplete_suggestions" should exist
 | 
        
           |  |  | 35 |     And I set the field "Cohort" to "System cohort"
 | 
        
           |  |  | 36 |     And I press "Add method"
 | 
        
           |  |  | 37 |     And I am on the "Course 001" "enrolled users" page
 | 
        
           |  |  | 38 |     And I should see "student001@example.com"
 | 
        
           |  |  | 39 |     And I should see "student002@example.com"
 | 
        
           |  |  | 40 |     And I should see "student003@example.com"
 | 
        
           |  |  | 41 |     And I should see "student004@example.com"
 | 
        
           |  |  | 42 |     And I log out
 | 
        
           |  |  | 43 |     When I log in as "admin"
 | 
        
           |  |  | 44 |     Then I navigate to "Plugins > Enrolments > Cohort sync" in site administration
 | 
        
           |  |  | 45 |     And I select "Disable course enrolment" from the "External unenrol action" singleselect
 | 
        
           |  |  | 46 |     And I press "Save changes"
 | 
        
           |  |  | 47 |     And I navigate to "Users > Accounts > Cohorts" in site administration
 | 
        
           |  |  | 48 |     When I press "Assign" action in the "System cohort" report row
 | 
        
           |  |  | 49 |     And I set the field "removeselect_searchtext" to "Student 001"
 | 
        
           |  |  | 50 |     And I set the field "Current users" to "Student 001 (student001@example.com)"
 | 
        
           |  |  | 51 |     And I wait "1" seconds
 | 
        
           |  |  | 52 |     And I press "Remove"
 | 
        
           |  |  | 53 |     And I am on "Course 001" course homepage
 | 
        
           |  |  | 54 |     And I navigate to course participants
 | 
        
           |  |  | 55 |     And I should see "Suspended" in the "Student 001" "table_row"
 | 
        
           |  |  | 56 |     And I should see "Active" in the "Student 002" "table_row"
 | 
        
           |  |  | 57 |     And I should see "Active" in the "Student 003" "table_row"
 | 
        
           |  |  | 58 |     And I should see "Active" in the "Student 004" "table_row"
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 |   @javascript @skip_chrome_zerosize
 | 
        
           |  |  | 61 |   Scenario: Deleting non-empty cohort will suspend the enrolment but keep the role
 | 
        
           |  |  | 62 |     When I log in as "teacher001"
 | 
        
           |  |  | 63 |     And I am on the "Course 001" "enrolment methods" page
 | 
        
           |  |  | 64 |     And I select "Cohort sync" from the "Add method" singleselect
 | 
        
           |  |  | 65 |     And I open the autocomplete suggestions list
 | 
        
           |  |  | 66 |     Then "System cohort" "autocomplete_suggestions" should exist
 | 
        
           |  |  | 67 |     And I set the field "Cohort" to "System cohort"
 | 
        
           |  |  | 68 |     And I press "Add method"
 | 
        
           |  |  | 69 |     And I am on the "Course 001" "enrolled users" page
 | 
        
           |  |  | 70 |     And I should see "student001@example.com"
 | 
        
           |  |  | 71 |     And I should see "student002@example.com"
 | 
        
           |  |  | 72 |     And I should see "student003@example.com"
 | 
        
           |  |  | 73 |     And I should see "student004@example.com"
 | 
        
           |  |  | 74 |     And I log out
 | 
        
           |  |  | 75 |     When I log in as "admin"
 | 
        
           |  |  | 76 |     Then I navigate to "Plugins > Enrolments > Cohort sync" in site administration
 | 
        
           |  |  | 77 |     And I select "Disable course enrolment" from the "External unenrol action" singleselect
 | 
        
           |  |  | 78 |     And I press "Save changes"
 | 
        
           |  |  | 79 |     And I navigate to "Users > Accounts > Cohorts" in site administration
 | 
        
           |  |  | 80 |     When I press "Delete" action in the "System cohort" report row
 | 
        
           |  |  | 81 |     And I press "Continue"
 | 
        
           |  |  | 82 |     And I am on "Course 001" course homepage
 | 
        
           |  |  | 83 |     And I navigate to course participants
 | 
        
           |  |  | 84 |     And I should see "Suspended" in the "Student 001" "table_row"
 | 
        
           |  |  | 85 |     And I should see "Suspended" in the "Student 002" "table_row"
 | 
        
           |  |  | 86 |     And I should see "Suspended" in the "Student 003" "table_row"
 | 
        
           |  |  | 87 |     And I should see "Suspended" in the "Student 004" "table_row"
 |