1 |
efrain |
1 |
@core @core_message @javascript
|
|
|
2 |
Feature: Manage preferences
|
|
|
3 |
In order to control whether I'm contactable
|
|
|
4 |
As a user
|
|
|
5 |
I need to be able to update my messaging preferences
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
# Note: This course is using separate groups mode.
|
|
|
9 |
Given the following "courses" exist:
|
|
|
10 |
| fullname | shortname | category | groupmode |
|
|
|
11 |
| Course 1 | C1 | 0 | 1 |
|
|
|
12 |
And the following "users" exist:
|
|
|
13 |
| username | firstname | lastname | email |
|
|
|
14 |
| student1 | Student | 1 | student1@example.com |
|
|
|
15 |
| student2 | Student | 2 | student2@example.com |
|
|
|
16 |
| student3 | Student | 3 | student3@example.com |
|
|
|
17 |
| student4 | Student | 4 | student4@example.com |
|
|
|
18 |
| student5 | Student | 5 | student5@example.com |
|
|
|
19 |
And the following "course enrolments" exist:
|
|
|
20 |
| user | course | role |
|
|
|
21 |
| student1 | C1 | student |
|
|
|
22 |
| student2 | C1 | student |
|
|
|
23 |
| student3 | C1 | student |
|
|
|
24 |
| student4 | C1 | student |
|
|
|
25 |
And the following "groups" exist:
|
|
|
26 |
| name | course | idnumber | enablemessaging |
|
|
|
27 |
| Group 1 | C1 | G1 | 1 |
|
|
|
28 |
And the following "group members" exist:
|
|
|
29 |
| user | group |
|
|
|
30 |
| student1 | G1 |
|
|
|
31 |
| student4 | G1 |
|
|
|
32 |
And the following "message contacts" exist:
|
|
|
33 |
| user | contact |
|
|
|
34 |
| student1 | student2 |
|
|
|
35 |
And the following config values are set as admin:
|
|
|
36 |
| messaging | 1 |
|
|
|
37 |
| messagingallusers | 1 |
|
|
|
38 |
| messagingminpoll | 1 |
|
|
|
39 |
|
|
|
40 |
# Recipient has 'My contacts only' set.
|
|
|
41 |
Scenario: Allow sending a message when you are a contact
|
|
|
42 |
Given I log in as "student1"
|
|
|
43 |
And I open messaging
|
|
|
44 |
And I open messaging settings preferences
|
|
|
45 |
When I click on "//label[text()[contains(.,'My contacts only')]]" "xpath_element"
|
|
|
46 |
And I log out
|
|
|
47 |
Then I log in as "student2"
|
|
|
48 |
And I open messaging
|
|
|
49 |
And I send "Hi!" message to "Student 1" user
|
|
|
50 |
And I should see "Hi!" in the "//*[@data-region='message-drawer']//div[@data-region='content-message-container']" "xpath_element"
|
|
|
51 |
|
|
|
52 |
# Recipient has 'My contacts and anyone in my courses' set.
|
|
|
53 |
Scenario: Disallow sending a message if you are neither contacts with the recipient nor do you share a course
|
|
|
54 |
Given I log in as "student1"
|
|
|
55 |
And I open messaging
|
|
|
56 |
And I open messaging settings preferences
|
|
|
57 |
When I click on "//label[text()[contains(.,'My contacts and anyone in my courses')]]" "xpath_element"
|
|
|
58 |
And I log out
|
|
|
59 |
Then I log in as "student5"
|
|
|
60 |
And I open messaging
|
|
|
61 |
And I search for "Student 1" in messaging
|
|
|
62 |
And I should see "No results"
|
|
|
63 |
|
|
|
64 |
# Recipient has 'My contacts and anyone in my courses' set.
|
|
|
65 |
Scenario: Allow sending a message if you share a group in a shared course
|
|
|
66 |
Given I log in as "student1"
|
|
|
67 |
And I open messaging
|
|
|
68 |
And I open messaging settings preferences
|
|
|
69 |
When I click on "//label[text()[contains(.,'My contacts and anyone in my courses')]]" "xpath_element"
|
|
|
70 |
And I log out
|
|
|
71 |
Then I log in as "student4"
|
|
|
72 |
And I open messaging
|
|
|
73 |
And I send "Hi!" message to "Student 1" user
|
|
|
74 |
And I should see "Hi!" in the "//*[@data-region='message-drawer']//div[@data-region='content-message-container']" "xpath_element"
|
|
|
75 |
|
|
|
76 |
# Recipient has 'My contacts and anyone in my courses' set.
|
|
|
77 |
Scenario: Disallow sending a message if you are neither a contact, nor are in the same group in a shared course
|
|
|
78 |
Given I log in as "student1"
|
|
|
79 |
And I open messaging
|
|
|
80 |
And I open messaging settings preferences
|
|
|
81 |
When I click on "//label[text()[contains(.,'My contacts and anyone in my courses')]]" "xpath_element"
|
|
|
82 |
And I log out
|
|
|
83 |
Then I log in as "student3"
|
|
|
84 |
And I open messaging
|
|
|
85 |
And I search for "Student 1" in messaging
|
|
|
86 |
And I should see "No results"
|
|
|
87 |
|
|
|
88 |
# Recipient has 'Anyone on the site' set. Only users whose profiles are visible can be found via the search.
|
|
|
89 |
Scenario: Disallow sending a message if you are neither a contact nor do you share a course with the user.
|
|
|
90 |
Given I log in as "student1"
|
|
|
91 |
And I open messaging
|
|
|
92 |
And I open messaging settings preferences
|
|
|
93 |
When I click on "//label[text()[contains(.,'Anyone on the site')]]" "xpath_element"
|
|
|
94 |
And I log out
|
|
|
95 |
Then I log in as "student5"
|
|
|
96 |
And I open messaging
|
|
|
97 |
And I search for "Student 1" in messaging
|
|
|
98 |
And I should see "No results"
|
|
|
99 |
|
|
|
100 |
Scenario: Sending a message when 'User enter to send' is enabled
|
|
|
101 |
Given I log in as "student1"
|
|
|
102 |
And I open messaging
|
|
|
103 |
And I select "Student 2" user in messaging
|
|
|
104 |
And I set the field with xpath "//textarea[@data-region='send-message-txt']" to "Hi!"
|
|
|
105 |
And I press the enter key
|
|
|
106 |
Then I should see "Hi!" in the "//*[@data-region='message-drawer']//div[@data-region='content-message-container']" "xpath_element"
|
|
|
107 |
|
|
|
108 |
Scenario: Sending a message after 'Use enter to send' is disabled
|
|
|
109 |
Given I log in as "student1"
|
|
|
110 |
And I open messaging
|
|
|
111 |
And I open messaging settings preferences
|
|
|
112 |
When I click on "//label[text()[contains(.,'Use enter to send')]]" "xpath_element"
|
|
|
113 |
And I go back in "view-settings" message drawer
|
|
|
114 |
Then I select "Student 2" user in messaging
|
|
|
115 |
And I set the field with xpath "//textarea[@data-region='send-message-txt']" to "Hi!"
|
|
|
116 |
And I press the enter key
|
|
|
117 |
And I should not see "Hi!" in the "//*[@data-region='message-drawer']//div[@data-region='content-message-container']" "xpath_element"
|
|
|
118 |
And I press "Send message"
|
|
|
119 |
And I should see "Hi!" in the "//*[@data-region='message-drawer']//div[@data-region='content-message-container']" "xpath_element"
|