From d0583411459afd6e042838b90fb7830811bdde95 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Fri, 13 May 2016 22:05:33 -0400 Subject: [PATCH] MDL-54131 Behat: tests for the course list block --- .../behat/block_course_list_category.feature | 78 +++++++++++++++ .../behat/block_course_list_course.feature | 94 +++++++++++++++++++ .../behat/block_course_list_dashboard.feature | 61 ++++++++++++ .../behat/block_course_list_frontpage.feature | 86 +++++++++++++++++ 4 files changed, 319 insertions(+) create mode 100644 blocks/course_list/tests/behat/block_course_list_category.feature create mode 100644 blocks/course_list/tests/behat/block_course_list_course.feature create mode 100644 blocks/course_list/tests/behat/block_course_list_dashboard.feature create mode 100644 blocks/course_list/tests/behat/block_course_list_frontpage.feature diff --git a/blocks/course_list/tests/behat/block_course_list_category.feature b/blocks/course_list/tests/behat/block_course_list_category.feature new file mode 100644 index 00000000000..4f3fa502ed4 --- /dev/null +++ b/blocks/course_list/tests/behat/block_course_list_category.feature @@ -0,0 +1,78 @@ +@block @block_course_list +Feature: Enable the course_list block on a category page and view it's contents + In order to enable the course list block on a category page + As an admin + I can add the course list block to a category page + + Background: + Given the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | + | Category 2 | 0 | CAT2 | + | Category 3 | CAT2 | CAT3 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + | Course 2 | C2 | CAT1 | + | Course 3 | C3 | CAT2 | + | Course 4 | C4 | CAT3 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | First | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher1 | C2 | editingteacher | + | teacher1 | C3 | editingteacher | + + Scenario: Add the course list block on category page and navigate to the course listing + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I follow "Course 1" + And I follow "Miscellaneous" + And I add the "Courses" block + And I log out + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Miscellaneous" + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "All courses" + And I should see "Miscellaneous" + + Scenario: Add the course list block on category page and navigate to another course + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I follow "Course 1" + And I follow "Miscellaneous" + And I add the "Courses" block + And I log out + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Miscellaneous" + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "Course 3" + And I should see "Course 3" + + Scenario: Add the course list block on category page and view as an admin + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I follow "Course 1" + And I follow "Miscellaneous" + When I add the "Courses" block + Then I should see "Miscellaneous" in the "Course categories" "block" + And I should see "Category 1" in the "Course categories" "block" + And I should see "Category 2" in the "Course categories" "block" + And I should not see "Category 3" in the "Course categories" "block" + And I should not see "Course 1" in the "Course categories" "block" + And I should not see "Course 2" in the "Course categories" "block" + And I follow "All courses" + And I should see "Miscellaneous" diff --git a/blocks/course_list/tests/behat/block_course_list_course.feature b/blocks/course_list/tests/behat/block_course_list_course.feature new file mode 100644 index 00000000000..aded7f512c8 --- /dev/null +++ b/blocks/course_list/tests/behat/block_course_list_course.feature @@ -0,0 +1,94 @@ +@block @block_course_list +Feature: Enable the course_list block on a course page and view it's contents + In order to enable the course list block on an course page + As a teacher + I can add the course list block to a course page + + Background: + Given the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | + | Category 2 | 0 | CAT2 | + | Category 3 | CAT2 | CAT3 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + | Course 2 | C2 | CAT1 | + | Course 3 | C3 | CAT2 | + | Course 4 | C4 | CAT3 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | First | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher1 | C2 | editingteacher | + | teacher1 | C3 | editingteacher | + + Scenario: Add the course list block on course page and navigate to the course listing + Given I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Courses" block + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "All courses" + And I should see "Miscellaneous" + + Scenario: Add the course list block on course page and navigate to another course + Given I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Courses" block + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "Course 3" + And I should see "Course 3" + + Scenario: Add the course list block on course page and view as an admin + Given I log in as "admin" + And I am on site homepage + And I follow "Course 1" + And I turn editing mode on + When I add the "Courses" block + Then I should see "Miscellaneous" in the "Course categories" "block" + And I should see "Category 1" in the "Course categories" "block" + And I should see "Category 2" in the "Course categories" "block" + And I should not see "Category 3" in the "Course categories" "block" + And I should not see "Course 1" in the "Course categories" "block" + And I should not see "Course 2" in the "Course categories" "block" + And I follow "All courses" + And I should see "Miscellaneous" + + Scenario: View the course list block on course page with hide all courses link enabled + Given the following config values are set as admin: + | block_course_list_hideallcourseslink | 1 | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + When I add the "Courses" block + Then I should not see "Miscellaneous" in the "My courses" "block" + + Scenario: View the course list block on course page with admin sees own course enabled + Given the following config values are set as admin: + | block_course_list_adminview | own | + And the following "course enrolments" exist: + | user | course | role | + | admin | C1 | editingteacher | + And I log in as "admin" + And I am on site homepage + And I follow "Course 1" + And I turn editing mode on + When I add the "Courses" block + Then I should not see "Miscellaneous" in the "My courses" "block" + And I should not see "Category 1" in the "My courses" "block" + And I should not see "Category 2" in the "My courses" "block" + And I should not see "Category 3" in the "My courses" "block" + And I should see "Course 1" in the "My courses" "block" + And I should not see "Course 2" in the "My courses" "block" + And I follow "All courses" + And I should see "Miscellaneous" diff --git a/blocks/course_list/tests/behat/block_course_list_dashboard.feature b/blocks/course_list/tests/behat/block_course_list_dashboard.feature new file mode 100644 index 00000000000..33f50594cf5 --- /dev/null +++ b/blocks/course_list/tests/behat/block_course_list_dashboard.feature @@ -0,0 +1,61 @@ +@block @block_course_list +Feature: Enable the course_list block on the dashboard and view it's contents + In order to enable the course list block on the dashboard + As a user + I can add the course list block to the dashboard + + Background: + Given the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | + | Category 2 | 0 | CAT2 | + | Category 3 | CAT2 | CAT3 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + | Course 2 | C2 | CAT1 | + | Course 3 | C3 | CAT2 | + | Course 4 | C4 | CAT3 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | First | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher1 | C2 | editingteacher | + | teacher1 | C3 | editingteacher | + + Scenario: Add the course list block on the dashboard and navigate to the course listing + Given I log in as "teacher1" + And I press "Customise this page" + When I add the "Courses" block + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "All courses" + And I should see "Miscellaneous" + + Scenario: Add the course list block on the dashboard and navigate to another course + Given I log in as "teacher1" + And I press "Customise this page" + When I add the "Courses" block + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "Course 3" + And I should see "Course 3" + + Scenario: Add the course list block on the dashboard and view as an admin + Given I log in as "admin" + And I press "Customise this page" + When I add the "Courses" block + Then I should see "Miscellaneous" in the "Course categories" "block" + And I should see "Category 1" in the "Course categories" "block" + And I should see "Category 2" in the "Course categories" "block" + And I should not see "Category 3" in the "Course categories" "block" + And I should not see "Course 1" in the "Course categories" "block" + And I should not see "Course 2" in the "Course categories" "block" + And I follow "All courses" + And I should see "Miscellaneous" diff --git a/blocks/course_list/tests/behat/block_course_list_frontpage.feature b/blocks/course_list/tests/behat/block_course_list_frontpage.feature new file mode 100644 index 00000000000..e13a38019bd --- /dev/null +++ b/blocks/course_list/tests/behat/block_course_list_frontpage.feature @@ -0,0 +1,86 @@ +@block @block_course_list +Feature: Enable the course_list block on the frontpage and view it's contents + In order to enable the course list block on the frontpage + As an admin + I can add the course list block to the frontpage + + Background: + Given the following "categories" exist: + | name | category | idnumber | + | Category 1 | 0 | CAT1 | + | Category 2 | 0 | CAT2 | + | Category 3 | CAT2 | CAT3 | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + | Course 2 | C2 | CAT1 | + | Course 3 | C3 | CAT2 | + | Course 4 | C4 | CAT3 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | First | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | teacher1 | C2 | editingteacher | + | teacher1 | C3 | editingteacher | + + Scenario: Add the course list block on the frontpage and navigate to the course listing + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I add the "Courses" block + And I log out + When I log in as "teacher1" + And I am on site homepage + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "All courses" + And I should see "Miscellaneous" + + Scenario: Add the course list block on the frontpage page and navigate to another course + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I add the "Courses" block + And I log out + When I log in as "teacher1" + And I am on site homepage + Then I should see "Course 1" in the "My courses" "block" + And I should see "Course 2" in the "My courses" "block" + And I should see "Course 3" in the "My courses" "block" + And I should not see "Course 4" in the "My courses" "block" + And I follow "Course 3" + And I should see "Course 3" + + Scenario: Add the course list block on the frontpage page and view as an admin + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + When I add the "Courses" block + Then I should see "Miscellaneous" in the "Course categories" "block" + And I should see "Category 1" in the "Course categories" "block" + And I should see "Category 2" in the "Course categories" "block" + And I should not see "Category 3" in the "Course categories" "block" + And I should not see "Course 1" in the "Course categories" "block" + And I should not see "Course 2" in the "Course categories" "block" + And I follow "All courses" + And I should see "Miscellaneous" + + Scenario: Add the course list block on the frontpage page and view as a guest + Given I log in as "admin" + And I am on site homepage + And I navigate to "Turn editing on" node in "Front page settings" + And I add the "Courses" block + And I log out + When I log in as "guest" + Then I should see "Miscellaneous" in the "Course categories" "block" + And I should see "Category 1" in the "Course categories" "block" + And I should see "Category 2" in the "Course categories" "block" + And I should not see "Category 3" in the "Course categories" "block" + And I should not see "Course 1" in the "Course categories" "block" + And I should not see "Course 2" in the "Course categories" "block" + And I follow "All courses" + And I should see "Miscellaneous"