Merge pull request #18 from NoelDeMartin/MOBILE-3320

MOBILE-3320 behat: Test messages settings
main
Pau Ferrer Ocaña 2021-05-19 18:03:46 +02:00 committed by GitHub
commit 720cba7fba
3 changed files with 40 additions and 19 deletions

View File

@ -0,0 +1,18 @@
@mod @mod_messages @app @javascript
Feature: Test messages settings
Background:
Given the following "users" exist:
| username |
| student1 |
Scenario: Modify settings
When I enter the app
And I log in as "student1"
And I press "Messages" in the app
And I press "Message preferences" in the app
And I select "My contacts only" in the app
Then "My contacts only" should be selected in the app
And I select "My contacts and anyone in my courses" in the app
Then "My contacts and anyone in my courses" should be selected in the app

View File

@ -205,7 +205,8 @@
const ariaCurrent = element.getAttribute('aria-current'); const ariaCurrent = element.getAttribute('aria-current');
if ( if (
(ariaCurrent && ariaCurrent !== 'false') || (ariaCurrent && ariaCurrent !== 'false') ||
(element.getAttribute('aria-selected') === 'true') (element.getAttribute('aria-selected') === 'true') ||
(element.getAttribute('aria-checked') === 'true')
) )
return true; return true;

View File

@ -423,7 +423,7 @@ class behat_app extends behat_base {
// Note there are two 'Log in' texts visible (the title and the button) so we have to use // Note there are two 'Log in' texts visible (the title and the button) so we have to use
// a 'near' value here. // a 'near' value here.
$this->i_press_near_in_the_app('Log in', 'Forgotten'); $this->i_press_in_the_app('Log in', 'Forgotten');
// Wait until the main page appears. // Wait until the main page appears.
$this->spin( $this->spin(
@ -510,27 +510,29 @@ class behat_app extends behat_base {
* Note it is difficult to use the standard 'click on' or 'press' steps because those do not * Note it is difficult to use the standard 'click on' or 'press' steps because those do not
* distinguish visible items and the app always has many non-visible items in the DOM. * distinguish visible items and the app always has many non-visible items in the DOM.
* *
* @Given /^I press "(?P<text_string>(?:[^"]|\\")*)" in the app$/ * @Then /^I press "(?P<text_string>(?:[^"]|\\")*)"(?: near "(?P<near_string>(?:[^"]|\\")*)")? in the app$/
* @param string $text Text identifying click target
* @throws DriverException If the press doesn't work
*/
public function i_press_in_the_app(string $text) {
$this->press($text);
}
/**
* Clicks on / touches something that is visible in the app, near some other text.
*
* This is the same as the other step, but when there are multiple matches, it picks the one
* nearest (in DOM terms) the second text. The second text should be an exact match, or a partial
* match that only has one result.
*
* @Given /^I press "(?P<text_string>(?:[^"]|\\")*)" near "(?P<nearby_string>(?:[^"]|\\")*)" in the app$/
* @param string $text Text identifying click target * @param string $text Text identifying click target
* @param string $near Text identifying a nearby unique piece of text * @param string $near Text identifying a nearby unique piece of text
* @throws DriverException If the press doesn't work * @throws DriverException If the press doesn't work
*/ */
public function i_press_near_in_the_app(string $text, string $near) { public function i_press_in_the_app($text, $near='') {
$this->press($text, $near);
}
/**
* Select an item from a list of options, such as a radio button.
*
* It may be necessary to use this step instead of "I press..." because radio buttons in Ionic are initialized
* with JavaScript, and clicks may not work until they are initialized properly which may cause flaky tests due
* to race conditions.
*
* @Then /^I select "(?P<text_string>(?:[^"]|\\")*)"(?: near "(?P<near_string>(?:[^"]|\\")*)")? in the app$/
* @param string $text Text identifying click target
* @param string $near Text identifying a nearby unique piece of text
* @throws DriverException If the press doesn't work
*/
public function i_select_in_the_app($text, $near='') {
$this->getSession()->wait(100);
$this->press($text, $near); $this->press($text, $near);
} }