Skip to content

Commit

Permalink
MDL-54577 Behat: Add tests for messages block
Browse files Browse the repository at this point in the history
  • Loading branch information
sbourget authored and cameorn1730 committed May 26, 2016
1 parent 6a74e76 commit 71b1761
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 0 deletions.
58 changes: 58 additions & 0 deletions blocks/messages/tests/behat/block_messages_course.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@block @block_messages
Feature: The messages block allows users to list new messages an a course
In order to enable the messages block in a course
As a teacher
I can add the messages block to a course and view my messages

Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |

Scenario: View the block by a user with messaging disabled.
Given the following config values are set as admin:
| messaging | 0 |
And I log in as "teacher1"
And I follow "Course 1"
When I turn editing mode on
And I add the "Messages" block
Then I should see "Messaging is disabled on this site" in the "Messages" "block"

Scenario: View the block by a user who does not have any messages.
Given I log in as "teacher1"
And I follow "Course 1"
When I turn editing mode on
And I add the "Messages" block
Then I should see "No messages waiting" in the "Messages" "block"

Scenario: View the block by a user who has messages.
Given I log in as "student1"
And I follow "Messages" in the user menu
And I send "This is message 1" message to "Teacher 1" user
And I send "This is message 2" message to "Teacher 1" user
And I log out
And I log in as "teacher1"
And I follow "Course 1"
When I turn editing mode on
And I add the "Messages" block
Then I should see "Student 1" in the "Messages" "block"

Scenario: Use the block to send a message to a user.
Given I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add the "Messages" block
And I follow "Messages"
And I send "This is message 1" message to "Student 1" user
And I log out
When I log in as "student1"
And I follow "Course 1"
Then I should see "Teacher 1" in the "Messages" "block"
48 changes: 48 additions & 0 deletions blocks/messages/tests/behat/block_messages_dashboard.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@block @block_messages
Feature: The messages block allows users to list new messages on the dashboard
In order to enable the messages block on the dashboard
As a user
I can add the messages block to a my dashboard and view my messages

Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |

Scenario: View the block by a user with messaging disabled.
Given the following config values are set as admin:
| messaging | 0 |
And I log in as "teacher1"
And I press "Customise this page"
When I add the "Messages" block
Then I should see "Messaging is disabled on this site" in the "Messages" "block"

Scenario: View the block by a user who does not have any messages.
Given I log in as "teacher1"
And I press "Customise this page"
When I add the "Messages" block
Then I should see "No messages waiting" in the "Messages" "block"

Scenario: View the block by a user who has messages.
Given I log in as "student1"
And I follow "Messages" in the user menu
And I send "This is message 1" message to "Teacher 1" user
And I send "This is message 2" message to "Teacher 1" user
And I log out
When I log in as "teacher1"
And I press "Customise this page"
And I add the "Messages" block
Then I should see "Student 1" in the "Messages" "block"

Scenario: Use the block to send a message to a user.
Given I log in as "teacher1"
And I press "Customise this page"
And I add the "Messages" block
And I follow "Messages"
And I send "This is message 1" message to "Student 1" user
And I log out
When I log in as "student1"
And I press "Customise this page"
And I add the "Messages" block
Then I should see "Teacher 1" in the "Messages" "block"
56 changes: 56 additions & 0 deletions blocks/messages/tests/behat/block_messages_frontpage.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@block @block_messages
Feature: The messages block allows users to list new messages on the frontpage
In order to enable the messages block on the frontpage
As an admin
I can add the messages block to a the frontpage and view my messages

Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
| student1 | Student | 1 | student1@example.com | S1 |
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 "Messages" block
And I log out

Scenario: View the block by a user with messaging disabled.
Given the following config values are set as admin:
| messaging | 0 |
And I log in as "admin"
And I am on site homepage
When I navigate to "Turn editing on" node in "Front page settings"
And I should see "Messaging is disabled on this site" in the "Messages" "block"
Then I navigate to "Turn editing off" node in "Front page settings"
And I should not see "Messaging is disabled on this site"

Scenario: View the block by a user who does not have any messages.
Given I log in as "teacher1"
When I am on site homepage
Then I should see "No messages waiting" in the "Messages" "block"

Scenario: Try to view the block as a guest user.
Given I log in as "guest"
When I am on site homepage
Then I should not see "Messages"

Scenario: View the block by a user who has messages.
Given I log in as "student1"
And I follow "Messages" in the user menu
And I send "This is message 1" message to "Teacher 1" user
And I send "This is message 2" message to "Teacher 1" user
And I log out
When I log in as "teacher1"
And I am on site homepage
Then I should see "Student 1" in the "Messages" "block"

Scenario: Use the block to send a message to a user.
Given I log in as "teacher1"
And I am on site homepage
And I follow "Messages"
And I send "This is message 1" message to "Student 1" user
And I log out
When I log in as "student1"
And I am on site homepage
Then I should see "Teacher 1" in the "Messages" "block"

0 comments on commit 71b1761

Please sign in to comment.