From 52a630f7c8fd371a068a1b0f107b1105b7956308 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Fri, 13 May 2016 21:42:38 -0400 Subject: [PATCH] MDL-54133 Behat: tests for the course overview block --- .../tests/behat/block_course_overview.feature | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 blocks/course_overview/tests/behat/block_course_overview.feature diff --git a/blocks/course_overview/tests/behat/block_course_overview.feature b/blocks/course_overview/tests/behat/block_course_overview.feature new file mode 100644 index 00000000000..e6bb84c14a3 --- /dev/null +++ b/blocks/course_overview/tests/behat/block_course_overview.feature @@ -0,0 +1,141 @@ +@block @block_course_overview +Feature: View the course overview block on the dashboard and test it's functionality + In order to view the course overview block on the dashboard + As an admin + I can configure the course overview block + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | student1 | Student | 1 | student1@example.com | S1 | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + And the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | + | Category 2 | CAT1 | CAT2 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + | Course 2 | C2 | CAT1 | + | Course 3 | C3 | CAT2 | + + Scenario: View the block by a user without any enrolments + Given I log in as "student1" + Then I should see "No course information to show" in the "Course overview" "block" + + Scenario: View the block by a user with several enrolments + Given the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + When I log in as "student1" + Then I should see "Course 1" in the "Course overview" "block" + And I should see "Course 2" in the "Course overview" "block" + + Scenario: View the block by a user with several enrolments and limit the number of courses. + Given the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + When I log in as "student1" + And I press "Customise this page" + And I select "1" from the "Number of courses to display:" singleselect + Then I should see "Course 1" in the "Course overview" "block" + And I should see "You have 2 hidden courses" + And I should not see "Course 2" in the "Course overview" "block" + And I should not see "Course 3" in the "Course overview" "block" + And I follow "Show all courses" + And I should see "Course 1" in the "Course overview" "block" + And I should see "Course 2" in the "Course overview" "block" + And I should see "Course 3" in the "Course overview" "block" + + Scenario: View the block by a user with several enrolments and an admin set default max courses. + Given the following config values are set as admin: + | defaultmaxcourses | 2 | block_course_overview | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + When I log in as "student1" + Then I should see "Course 1" in the "Course overview" "block" + And I should see "Course 2" in the "Course overview" "block" + And I should see "You have 1 hidden course" + And I press "Customise this page" + And I select "Always show all" from the "Number of courses to display:" singleselect + And I should see "Course 3" in the "Course overview" "block" + And I should not see "You have 1 hidden course" + + Scenario: View the block by a user with several enrolments and an admin enforced maximum displayed courses. + Given the following config values are set as admin: + | defaultmaxcourses | 2 | block_course_overview | + | forcedefaultmaxcourses | 1 | block_course_overview | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + When I log in as "student1" + Then I should see "Course 1" in the "Course overview" "block" + And I should see "Course 2" in the "Course overview" "block" + And I should see "You have 1 hidden course" + And I press "Customise this page" + And I should not see "Always show all" + + Scenario: View the block by a user with the welcome area enabled and messaging disabled. + Given the following config values are set as admin: + | showwelcomearea | 1 | block_course_overview | + | messaging | 0 | | + When I log in as "student1" + Then I should see "Welcome Student" in the "Course overview" "block" + And I should not see "messages" in the "Course overview" "block" + + Scenario: View the block by a user with both the welcome area and messaging enabled. + Given the following config values are set as admin: + | showwelcomearea | 1 | block_course_overview | + When I log in as "student1" + Then I should see "Welcome Student" in the "Course overview" "block" + And I should see "You have no unread messages" in the "Course overview" "block" + And I follow "messages" + And I should see "Contact list empty" + + Scenario: View the block by a user with the welcome area and the user having messages. + Given the following config values are set as admin: + | showwelcomearea | 1 | block_course_overview | + And I log in as "student1" + And I should see "Welcome Student" in the "Course overview" "block" + And I should see "You have no unread messages" in the "Course overview" "block" + And I follow "messages" + And I send "This is message 1" message to "Teacher 1" user + And I send "This is message 2" message to "Teacher 1" user + When I log out + And I log in as "teacher1" + Then I should see "Welcome Teacher" in the "Course overview" "block" + And I should see "You have 2 unread messages" in the "Course overview" "block" + + Scenario: View the block by a user with the parent categories displayed. + Given the following config values are set as admin: + | showcategories | Parent category only | block_course_overview | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + When I log in as "student1" + Then I should see "Miscellaneous" in the "Course overview" "block" + And I should see "Category 1" in the "Course overview" "block" + And I should see "Category 2" in the "Course overview" "block" + And I should not see "Category 1 / Category 1" in the "Course overview" "block" + + Scenario: View the block by a user with the full categories displayed. + Given the following config values are set as admin: + | showcategories | 2 | block_course_overview | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | student1 | C2 | student | + | student1 | C3 | student | + When I log in as "student1" + Then I should see "Miscellaneous" in the "Course overview" "block" + And I should see "Category 1 / Category 2" in the "Course overview" "block"