Skip to content

Commit

Permalink
Merge branch 'MDL-59883-master' of git://github.com/andrewnicols/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Oct 3, 2017
2 parents 34ecee1 + bc01fbb commit 9376583
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion calendar/tests/behat/calendar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Feature: Perform basic calendar functionality
And I follow "This month"
And I click on "Really awesome event!" "link"
And "Course 1" "link" should exist in the "Really awesome event!" "dialogue"
And I click on ".close" "css_element" in the "Really awesome event!" "dialogue"
And I click on "Close" "button"
And I log out
And I log in as "student2"
And I follow "This month"
Expand Down
26 changes: 23 additions & 3 deletions lib/behat/classes/partial_named_selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ public function __construct() {
$this->registerNamedXpath($name, $xpath);
}

foreach (self::$customreplacements as $from => $tos) {
$this->registerReplacement($from, implode(' or ', $tos));
}

$this->registerReplacement('%iconMatch%', "(contains(concat(' ', @class, ' '), ' icon ') or name() = 'img')");
$this->registerReplacement('%imgAltMatch%', './/*[%iconMatch% and (%altMatch% or %titleMatch%)]');
parent::__construct();
}

/**
* @var Allowed types when using text selectors arguments.
* @var array Allowed types when using text selectors arguments.
*/
protected static $allowedtextselectors = array(
'activity' => 'activity',
Expand All @@ -73,7 +77,7 @@ public function __construct() {
);

/**
* @var Allowed types when using selector arguments.
* @var array Allowed types when using selector arguments.
*/
protected static $allowedselectors = array(
'activity' => 'activity',
Expand Down Expand Up @@ -113,7 +117,7 @@ public function __construct() {
* xpaths that represents that names and includes a placeholder that
* will be replaced by the locator. These are Moodle's own xpaths.
*
* @var XPaths for moodle elements.
* @var array XPaths for moodle elements.
*/
protected static $moodleselectors = array(
'activity' => <<<XPATH
Expand Down Expand Up @@ -203,6 +207,22 @@ public function __construct() {
],
];

/**
* Mink comes with a number of named replacements.
* Sometimes we want to add our own.
*
* @var array XPaths for moodle elements.
*/
protected static $customreplacements = [
'%buttonMatch%' => [
'upstream' => '%idOrNameMatch% or %valueMatch% or %titleMatch%',
'aria' => '%ariaLabelMatch%',
],
'%ariaLabelMatch%' => [
'moodle' => 'contains(./@aria-label, %locator%)',
],
];

/**
* Allowed selectors getter.
*
Expand Down
2 changes: 1 addition & 1 deletion repository/tests/behat/cancel_add_file.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: A selected file can be cancelled
And I click on "Recent files" "link" in the ".fp-repo-area" "css_element"
And I click on "//a[contains(concat(' ', normalize-space(@class), ' '), ' fp-file ')][normalize-space(.)='empty.txt']" "xpath_element"
And I click on ".moodle-dialogue-focused .fp-select .fp-select-cancel" "css_element"
And I click on ".moodle-dialogue-focused.filepicker .yui3-button.closebutton" "css_element"
And I click on "Close" "button" in the "File picker" "dialogue"
And I press "Save and display"
Then I should see "upload_users.csv"
And I should not see "empty.txt"
Expand Down

0 comments on commit 9376583

Please sign in to comment.