From baa7be6a86416990247f4d25d142a1237e1e105f Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Mon, 29 Apr 2019 11:01:14 +0800 Subject: [PATCH] MDL-65169 core_message: add behat step allowing searching for a string New step: 'I search for "xx" in messaging'. --- message/tests/behat/behat_message.php | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/message/tests/behat/behat_message.php b/message/tests/behat/behat_message.php index ea079ccd182..973739bd161 100644 --- a/message/tests/behat/behat_message.php +++ b/message/tests/behat/behat_message.php @@ -109,18 +109,7 @@ class behat_message extends behat_base { public function i_select_user_in_messaging($userfullname) { $this->i_open_messaging(); - $this->execute('behat_general::i_click_on', [get_string('search', 'core'), 'field']); - - $this->execute('behat_forms::i_set_the_field_with_xpath_to', - [ - "//*[@data-region='message-drawer']//input[@data-region='search-input']", - $this->escape($userfullname) - ] - ); - - $this->execute('behat_general::i_click_on', ['[data-action="search"]', 'css_element']); - - $this->execute('behat_general::wait_until_the_page_is_ready'); + $this->i_search_for_string_in_messaging($userfullname); // Need to limit the click to the search results because the 'view-contact-profile' elements // can occur in two separate divs on the page. @@ -136,6 +125,27 @@ class behat_message extends behat_base { $this->execute('behat_general::wait_until_the_page_is_ready'); } + /** + * Search for a string using the messaging search. + * + * @Given /^I search for "(?P(?:[^"]|\\")*)" in messaging$/ + * @param string $string the search string. + */ + public function i_search_for_string_in_messaging($string) { + $this->execute('behat_general::i_click_on', [get_string('search', 'core'), 'field']); + + $this->execute('behat_forms::i_set_the_field_with_xpath_to', + [ + "//*[@data-region='message-drawer']//input[@data-region='search-input']", + $this->escape($string) + ] + ); + + $this->execute('behat_general::i_click_on', ['[data-action="search"]', 'css_element']); + + $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. *