MDL-57042 messaging: When selecting a user, go to send message

This is the whole point of this UI - make it the default action after
searching and selecting a user. You can still get to their profile by
clicking their name in the header of the messaging pane.
This commit is contained in:
Damyon Wiese 2016-11-21 12:10:36 +08:00
parent cd4a6b8b0b
commit 9741087ffd
2 changed files with 28 additions and 7 deletions

View File

@ -15,7 +15,7 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
<div class="contact {{#selected}}selected{{/selected}} {{#lastmessage}}{{^isread}}unread{{/isread}}{{/lastmessage}}"
data-action="{{#ismessaging}}view-contact-msg{{/ismessaging}}{{^ismessaging}}view-contact-profile{{/ismessaging}}"
data-action="view-contact-msg"
data-userid="{{userid}}" data-messageid="{{#messageid}}{{.}}{{isread}}{{/messageid}}" data-region="contact" tabindex="0">
<div class="picture">
<img src="{{profileimageurl}}" alt="" />

View File

@ -44,6 +44,30 @@ class behat_message extends behat_base {
* @param string $userfullname
*/
public function i_view_contact_in_messages($userfullname) {
// Visit home page and follow messages.
$this->i_select_user_in_messaging($userfullname);
$this->execute('behat_general::i_click_on_in_the',
array(
"//button[@data-action='view-contact-profile']
[contains(normalize-space(.), '" . $this->escape($userfullname) . "')]",
'xpath_element',
".messages-header",
"css_element",
)
);
$this->execute('behat_general::wait_until_the_page_is_ready');
}
/**
* Select a user in the messaging UI.
*
* @Given /^I select "(?P<user_full_name_string>(?:[^"]|\\")*)" user in messaging$/
* @param string $userfullname
*/
public function i_select_user_in_messaging($userfullname) {
// Visit home page and follow messages.
$this->execute("behat_general::i_am_on_homepage");
@ -63,7 +87,7 @@ class behat_message extends behat_base {
// can occur in two separate divs on the page.
$this->execute('behat_general::i_click_on_in_the',
array(
"//div[@data-action='view-contact-profile']
"//div[@data-action='view-contact-msg']
[./div[contains(normalize-space(.), '" . $this->escape($userfullname) . "')]]",
'xpath_element',
"[data-region='messaging-area'] [data-region='search-results-area']",
@ -74,6 +98,7 @@ class behat_message extends behat_base {
$this->execute('behat_general::wait_until_the_page_is_ready');
}
/**
* Sends a message to the specified user from the logged user. The user full name should contain the first and last names.
*
@ -82,11 +107,7 @@ class behat_message extends behat_base {
* @param string $userfullname
*/
public function i_send_message_to_user($messagecontent, $userfullname) {
$this->i_view_contact_in_messages($userfullname);
$this->execute("behat_general::i_click_on", array("[data-action='profile-send-message']", 'css_element'));
$this->execute('behat_general::wait_until_the_page_is_ready');
$this->i_select_user_in_messaging($userfullname);
$this->execute('behat_forms::i_set_the_field_with_xpath_to',
array("//textarea[@data-region='send-message-txt']", $this->escape($messagecontent))