From bc823ac6bfc4485fbe1a6b894aa71a4c8a85e952 Mon Sep 17 00:00:00 2001 From: Stephen Bourget Date: Mon, 9 May 2016 18:55:33 -0400 Subject: [PATCH] MDL-54115 Behat: tests for the comments block --- .../behat/block_comment_activity.feature | 34 +++++++++++++++++++ .../tests/behat/block_comment_course.feature | 29 ++++++++++++++++ .../behat/block_comment_frontpage.feature | 21 ++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 blocks/comments/tests/behat/block_comment_activity.feature create mode 100644 blocks/comments/tests/behat/block_comment_course.feature create mode 100644 blocks/comments/tests/behat/block_comment_frontpage.feature diff --git a/blocks/comments/tests/behat/block_comment_activity.feature b/blocks/comments/tests/behat/block_comment_activity.feature new file mode 100644 index 00000000000..d2a3180351f --- /dev/null +++ b/blocks/comments/tests/behat/block_comment_activity.feature @@ -0,0 +1,34 @@ +@block @block_comments +Feature: Enable Block comments on an activity page and view comments + In order to enable the comments block on an activity page + As a teacher + I can add the comments block to an activity page + + Scenario: Add the comments block on an activity page and add comments + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | Frist | teacher1@example.com | + | student1 | Student | First | student1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And the following "activities" exist: + | activity | course | idnumber | name | intro | + | page | C1 | page1 | Test page name | Test page description | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I follow "Test page name" + And I add the "Comments" block + And I follow "Show comments" + And I add "I'm a comment from the teacher" comment to comments block + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test page name" + And I follow "Show comments" + Then I should see "I'm a comment from the teacher" diff --git a/blocks/comments/tests/behat/block_comment_course.feature b/blocks/comments/tests/behat/block_comment_course.feature new file mode 100644 index 00000000000..c3acbc43a62 --- /dev/null +++ b/blocks/comments/tests/behat/block_comment_course.feature @@ -0,0 +1,29 @@ +@block @block_comments +Feature: Enable Block comments on a course page and view comments + In order to enable the comments block on a course page + As a teacher + I can add the comments block to the course page + + Scenario: Add the comments block on the course page and add comments + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | Frist | teacher1@example.com | + | student1 | Student | First | student1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add the "Comments" block + And I follow "Show comments" + And I add "I'm a comment from the teacher" comment to comments block + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Show comments" + Then I should see "I'm a comment from the teacher" diff --git a/blocks/comments/tests/behat/block_comment_frontpage.feature b/blocks/comments/tests/behat/block_comment_frontpage.feature new file mode 100644 index 00000000000..5d949ab2816 --- /dev/null +++ b/blocks/comments/tests/behat/block_comment_frontpage.feature @@ -0,0 +1,21 @@ +@block @block_comments +Feature: Enable Block comments on the frontpage and view comments + In order to enable the comments block on the frontpage + As a admin + I can add the comments block to the frontpage + + Scenario: Add the comments block on the frontpage and add comments + Given the following "users" exist: + | username | firstname | lastname | email | idnumber | + | teacher1 | Teacher | 1 | teacher1@example.com | T1 | + And 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 "Comments" block + And I follow "Show comments" + And I add "I'm a comment from admin" comment to comments block + And I log out + When I log in as "teacher1" + And I am on site homepage + And I follow "Show comments" + Then I should see "I'm a comment from admin"