From 06aa592315f3bda2585b882575b56c9004c693cd Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 18 Jul 2017 11:59:46 +0800 Subject: [PATCH] MDL-59369 enrol: Behat tests for plugin enrol actions --- enrol/meta/tests/behat/enrol_meta.feature | 27 +++++++++---- enrol/self/tests/behat/self_enrolment.feature | 38 +++++++++++++++++++ 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/enrol/meta/tests/behat/enrol_meta.feature b/enrol/meta/tests/behat/enrol_meta.feature index f8ba17310445c..447822973a3c3 100644 --- a/enrol/meta/tests/behat/enrol_meta.feature +++ b/enrol/meta/tests/behat/enrol_meta.feature @@ -16,18 +16,21 @@ Feature: Enrolments are synchronised with meta courses | Course 1 | C1C1 | | Course 2 | C2C2 | | Course 3 | C3C3 | + | Course 4 | C4C4 | And the following "groups" exist: | name | course | idnumber | | Groupcourse 1 | C3C3 | G1 | | Groupcourse 2 | C3C3 | G2 | And the following "course enrolments" exist: - | user | course | role | - | student1 | C1C1 | student | - | student2 | C1C1 | student | - | student3 | C1C1 | student | - | student4 | C1C1 | student | - | student1 | C2C2 | student | - | student2 | C2C2 | student | + | user | course | role | status | + | student1 | C1C1 | student | 0 | + | student2 | C1C1 | student | 0 | + | student3 | C1C1 | student | 0 | + | student4 | C1C1 | student | 0 | + | student1 | C2C2 | student | 0 | + | student2 | C2C2 | student | 0 | + | student1 | C4C4 | student | 0 | + | student2 | C4C4 | student | 1 | And I log in as "admin" And I navigate to "Manage enrol plugins" node in "Site administration > Plugins > Enrolments" And I click on "Enable" "link" in the "Course meta link" "table_row" @@ -105,3 +108,13 @@ Feature: Enrolments are synchronised with meta courses And I should see "Groupcourse 1" in the "Student 4" "table_row" And I should see "Course 2" in the "Student 1" "table_row" And I should not see "Course 2" in the "Student 3" "table_row" + + Scenario: Unenrol a user from the course participants page that was enrolled via course meta link. + Given I am on "Course 3" course homepage + And I add "Course meta link" enrolment method with: + | Link course | C4C4 | + And I navigate to course participants + # Suspended users can be unenrolled. + When I click on "//a[@data-action='unenrol']" "xpath_element" in the "student2" "table_row" + And I click on "Yes" "button" + Then I should not see "Student 2" in the "participants" "table" diff --git a/enrol/self/tests/behat/self_enrolment.feature b/enrol/self/tests/behat/self_enrolment.feature index b38fb108ae440..332e3af7fdf82 100644 --- a/enrol/self/tests/behat/self_enrolment.feature +++ b/enrol/self/tests/behat/self_enrolment.feature @@ -87,3 +87,41 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe Then I should see "Topic 1" And I should not see "Enrolment options" And I should not see "Enrol me in this course" + + @javascript + Scenario: Edit a self-enrolled user's enrolment from the course participants page + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I add "Self enrolment" enrolment method with: + | Custom instance name | Test student enrolment | + And I log out + And I log in as "student1" + And I am on "Course 1" course homepage + And I press "Enrol me" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to course participants + When I click on "//a[@data-action='editenrolment']" "xpath_element" in the "student1" "table_row" + And I should see "Edit Student 1's enrolment" + And I set the field "Status" to "Suspended" + And I click on "Save changes" "button" + Then I should see "Suspended" in the "student1" "table_row" + + @javascript + Scenario: Unenrol a self-enrolled student from the course participants page + Given I log in as "teacher1" + And I am on "Course 1" course homepage + When I add "Self enrolment" enrolment method with: + | Custom instance name | Test student enrolment | + And I log out + And I log in as "student1" + And I am on "Course 1" course homepage + And I press "Enrol me" + And I log out + And I log in as "teacher1" + And I am on "Course 1" course homepage + And I navigate to course participants + When I click on "//a[@data-action='unenrol']" "xpath_element" in the "student1" "table_row" + And I click on "Yes" "button" + Then I should not see "Student 1" in the "participants" "table"