MDL-45289 block_course_summary: Add behat tests
authorDan Poltawski <dan@moodle.com>
Mon, 28 Apr 2014 06:18:35 +0000 (14:18 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 29 Apr 2014 01:52:54 +0000 (09:52 +0800)
blocks/course_summary/tests/behat/block_course_summary_course.feature [new file with mode: 0644]
blocks/course_summary/tests/behat/block_course_summary_frontpage.feature [new file with mode: 0644]

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 (file)
index 0000000..b8758f3
--- /dev/null
@@ -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 (file)
index 0000000..05e54e8
--- /dev/null
@@ -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"