on-demand release 4.2dev+
[moodle.git] / message / tests / behat / message_send_messages.feature
blob3c681c689de4b053bf9d9c30c51b46ee4725c01a
1 @core @core_message @javascript
2 Feature: Message send messages
3   In order to communicate with fellow users
4   As a user
5   I need to be able to send a message
7   Background:
8     Given the following "courses" exist:
9       | fullname | shortname | category | groupmode |
10       | Course 1 | C1        | 0        | 1         |
11     And the following "users" exist:
12       | username | firstname | lastname | email                |
13       | student1 | Student   | 1        | student1@example.com |
14       | student2 | Student   | 2        | student2@example.com |
15     And the following "course enrolments" exist:
16       | user     | course | role |
17       | student1 | C1     | student |
18       | student2 | C1     | student |
19     And the following "groups" exist:
20       | name    | course | idnumber | enablemessaging |
21       | Group 1 | C1     | G1       | 1               |
22     And the following "group members" exist:
23       | user     | group |
24       | student1 | G1 |
25       | student2 | G1 |
26     And the following config values are set as admin:
27       | messaging        | 1 |
28       | messagingminpoll | 1 |
30   Scenario: Send a message to a group conversation
31     Given I log in as "student1"
32     And I open messaging
33     And I open the "Group" conversations list
34     And "Group 1" "core_message > Message" should exist
35     And I select "Group 1" conversation in messaging
36     When I send "Hi!" message in the message area
37     Then I should see "Hi!" in the "Group 1" "core_message > Message conversation"
38     And I should see "##today##%d %B##" in the "Group 1" "core_message > Message conversation"
39     And I log out
40     And I log in as "student2"
41     And I open messaging
42     And "Group 1" "core_message > Message" should exist
43     And I select "Group 1" conversation in messaging
44     And I should see "Hi!" in the "Group 1" "core_message > Message conversation"
46   Scenario: Send a message to a starred conversation
47     Given I log in as "student1"
48     When I open messaging
49     And I open the "Group" conversations list
50     Then "Group 1" "core_message > Message" should exist
51     And I select "Group 1" conversation in the "group-messages" conversations list
52     And I open contact menu
53     And I click on "Star conversation" "link" in the "conversation-actions-menu" "region"
54     And I go back in "view-conversation" message drawer
55     And I open the "Starred" conversations list
56     And I should see "Group 1"
57     And I select "Group 1" conversation in the "favourites" conversations list
58     And I send "Hi!" message in the message area
59     And I should see "Hi!" in the "Group 1" "core_message > Message conversation"
60     And I should see "##today##%d %B##" in the "Group 1" "core_message > Message conversation"
61     And I go back in "view-conversation" message drawer
62     And I open the "Group" conversations list
63     And I should not see "Group 1" in the "Group" "core_message > Message tab"
65   Scenario: Send a message to a private conversation via contact tab
66     Given the following "message contacts" exist:
67       | user     | contact |
68       | student1 | student2 |
69     And I log in as "student1"
70     And I open messaging
71     And I click on "Contacts" "link"
72     And I click on "Student 2" "link" in the "//*[@data-section='contacts']" "xpath_element"
73     When I send "Hi!" message in the message area
74     Then I should see "Hi!" in the "Student 2" "core_message > Message conversation"
75     And I should see "##today##%d %B##" in the "Student 2" "core_message > Message conversation"
77   Scenario: Try to send a message to a private conversation is not contact but you are allowed to send a message
78     Given I log in as "student1"
79     And I open messaging
80     When I send "Hi!" message to "Student 2" user
81     Then I should see "Hi!" in the "Student 2" "core_message > Message conversation"
82     And I should see "##today##%d %B##" in the "Student 2" "core_message > Message conversation"
83     And I log out
84     And I log in as "student2"
85     And I open messaging
86     And I select "Student 1" conversation in messaging
87     And I should see "Hi!" in the "Student 1" "core_message > Message conversation"