1 @core @core_message @javascript
2 Feature: Capability test for 'moodle/site:messageanyuser'
3 In order to test that the 'moodle/site:messageanyuser' works as expected
4 As a user with or without the capability 'moodle/site:messageanyuser'
5 I should either be able to message anyone regardless of their messaging preferences, or not
8 Given the following "courses" exist:
9 | fullname | shortname |
11 And the following "users" exist:
12 | username | firstname | lastname | email |
13 | teacher1 | Teacher | 1 | teacher1@example.com |
14 | student1 | Student | 1 | student1@example.com |
15 | student2 | Student | 2 | student1@example.com |
16 And the following "course enrolments" exist:
17 | user | course | role |
18 | teacher1 | C1 | teacher |
19 | student1 | C1 | student |
20 | student2 | C1 | student |
21 And the following config values are set as admin:
23 | messagingallusers | 1 |
24 And I log in as "student1"
26 And I open messaging settings preferences
27 And I click on "//label[text()[contains(.,'My contacts only')]]" "xpath_element"
30 Scenario: Allow a message to be sent as the user has the correct capabilities
31 Given I log in as "teacher1"
33 When I send "Hi!" message to "Student 1" user
34 Then I should see "Hi!" in the "//div[@data-region='message-drawer']//div[@data-region='content-message-container']" "xpath_element"
36 Scenario: Do not allow a message to be sent as the user does not have the correct capabilities
37 Given I log in as "student2"
38 And I am on "Course 1" course homepage
39 And I follow "Participants"
40 And I follow "Student 1"
41 When I click on "Message" "link" in the ".header-button-group" "css_element"
42 Then I should see "Student 1 is not in your contacts"