From e1850856c9c0781c6f58f30dd82633b63248fad2 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Mon, 28 Apr 2014 14:18:35 +0800 Subject: [PATCH] MDL-45289 block_course_summary: Add behat tests --- .../behat/block_course_summary_course.feature | 43 +++++++++++++++++++ .../block_course_summary_frontpage.feature | 33 ++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 blocks/course_summary/tests/behat/block_course_summary_course.feature create mode 100644 blocks/course_summary/tests/behat/block_course_summary_frontpage.feature diff --git a/blocks/course_summary/tests/behat/block_course_summary_course.feature b/blocks/course_summary/tests/behat/block_course_summary_course.feature new file mode 100644 index 00000000000..b8758f34f9b --- /dev/null +++ b/blocks/course_summary/tests/behat/block_course_summary_course.feature @@ -0,0 +1,43 @@ +@block @block_course_summary +Feature: Course summary block used in a course + In order to help particpants know the summary of a course + As a teacher + I can add the course summary block to a course page + + Background: + Given the following "courses" exist: + | fullname | shortname | summary | category | + | Course 1 | C101 | Proved the course summary block works! |0 | + And the following "users" exist: + | username | firstname | lastname | email | + | student1 | Sam | Student | student1@asd.com | + | teacher1 | Teacher | One | teacher1@asd.com | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C101 | student | + | teacher1 | C101 | editingteacher | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add the "Course/site summary" block + And I log out + + Scenario: Student can view course summary + When I log in as "student1" + And I follow "Course 1" + Then "block_course_summary" "block" should exist + And I should see "Proved the course summary block works!" in the "block_course_summary" "block" + + Scenario: Teacher can see an edit icon when edit mode is on and follow it to the course edit page + When I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + Then I should see "Proved the course summary block works!" in the "block_course_summary" "block" + And I click on "Edit" "link" in the "block_course_summary" "block" + Then I should see "Edit course settings" in the "h2" "css_element" + + Scenario: Teacher can not see edit icon when edit mode is off + When I log in as "teacher1" + And I follow "Course 1" + Then I should see "Proved the course summary block works!" in the "block_course_summary" "block" + And "Edit" "link" should not exist in the "block_course_summary" "block" diff --git a/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature b/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature new file mode 100644 index 00000000000..05e54e897a7 --- /dev/null +++ b/blocks/course_summary/tests/behat/block_course_summary_frontpage.feature @@ -0,0 +1,33 @@ +@block @block_course_summary +Feature: Course summary block used on the frontpage + In order to help particpants know the summary of a site + As admin + I can use the course summary block on the frontpage + + Background: + Given I log in as "admin" + And I navigate to "Edit settings" node in "Front page settings" + And I set the following fields to these values: + | summary | Proved the summary block works! | + And I press "Save changes" + And I log out + # The course summary block a default front page block, so no need to add it. + + Scenario: Guest can view site summary + When I am on homepage + Then "block_course_summary" "block" should exist + And I should see "Proved the summary block works!" in the "block_course_summary" "block" + + Scenario: Admin can see an edit icon when edit mode is on and follow it to the front page settings + When I log in as "admin" + And I am on homepage + And I follow "Turn editing on" + Then I should see "Proved the summary block works!" in the "block_course_summary" "block" + And I click on "Edit" "link" in the "block_course_summary" "block" + Then I should see "Front page settings" in the "h2" "css_element" + + Scenario: Admin can not see edit icon when edit mode is off + When I log in as "teacher1" + And I am on homepage + Then I should see "Proved the summary block works!" in the "block_course_summary" "block" + And "Edit" "link" should not exist in the "block_course_summary" "block" -- 2.43.0