Skip to content

Commit

Permalink
MDL-64669 core_message: New steps and selectors for messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaia Anabitarte committed Apr 8, 2019
1 parent 018aecd commit 1118af2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/behat/classes/partial_named_selector.php
Expand Up @@ -89,6 +89,7 @@ public function __construct() {
'file' => 'file',
'filemanager' => 'filemanager',
'group_message' => 'group_message',
'group_message_conversation' => 'group_message_conversation',
'group_message_header' => 'group_message_header',
'group_message_member' => 'group_message_member',
'group_message_tab' => 'group_message_tab',
Expand Down Expand Up @@ -154,7 +155,10 @@ public function __construct() {
, 'group_message' => <<<XPATH
.//*[@data-conversation-id]//img[contains(@alt, %locator%)]/..
XPATH
, 'group_message_header' => <<<XPATH
, 'group_message_conversation' => <<<XPATH
.//*[@data-region='message-drawer' and contains(., %locator%)]//div[@data-region='content-message-container']
XPATH
, 'group_message_header' => <<<XPATH
.//*[@data-region='message-drawer']//div[@data-region='header-container']//*[text()[contains(., %locator%)]]
XPATH
, 'group_message_member' => <<<XPATH
Expand Down
30 changes: 29 additions & 1 deletion message/tests/behat/behat_message.php
Expand Up @@ -48,6 +48,19 @@ public function i_open_messaging() {
$this->execute("behat_general::i_click_on", [get_string('togglemessagemenu', 'core_message'), 'link']);
}

/**
* Open the messaging conversation list.
*
* @Given /^I open the "(?P<tab_string>(?:[^"]|\\")*)" conversations list/
* @param string $tab
*/
public function i_open_the_conversations_list(string $tab) {
$this->execute('behat_general::i_click_on', [
$this->escape($tab),
'group_message_tab'
]);
}

/**
* Open the messaging UI.
*
Expand Down Expand Up @@ -153,7 +166,7 @@ public function i_send_message_in_the_message_area($messagecontent) {
array("//textarea[@data-region='send-message-txt']", $this->escape($messagecontent))
);

$this->execute("behat_forms::press_button", get_string('send', 'message'));
$this->execute("behat_forms::press_button", get_string('sendmessage', 'message'));
}

/**
Expand Down Expand Up @@ -204,4 +217,19 @@ public function i_open_contact_menu() {
)
);
}

/**
* Select a user in a specific messaging UI conversations list.
*
* @Given /^I select "(?P<conv_name_string>(?:[^"]|\\")*)" conversation in the "(?P<list_name_string>(?:[^"]|\\")*)" conversations list$/
* @param string $convname
* @param string $listname
*/
public function i_select_conversation_in_the_conversations_list(string $convname, string $listname) {
$xpath = '//*[@data-region="message-drawer"]//div[@data-region="view-overview-'.
$this->escape($listname).
'"]//*[@data-conversation-id]//img[contains(@alt,"'.
$this->escape($convname).'")]';
$this->execute('behat_general::i_click_on', array($xpath, 'xpath_element'));
}
}

0 comments on commit 1118af2

Please sign in to comment.