MDL-57168 behat: Ensure drawer is open before clicking the link

This commit is contained in:
Rajesh Taneja 2016-11-28 07:57:31 +08:00
parent 3eabedbb92
commit 3df6e801b5
No known key found for this signature in database
GPG Key ID: B363F7FB787F80E4
3 changed files with 49 additions and 0 deletions

View File

@ -573,6 +573,41 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
);
}
/**
* Ensures that the provided node has a attribute value set. This step can be used to check if specific
* JS has finished modifying the node.
*
* @throws ExpectationException
* @param NodeElement $node
* @param string $attribute attribute name
* @param string $attributevalue attribute value to check.
* @return void Throws an exception if it times out without the element being visible
*/
protected function ensure_node_attribute_is_set($node, $attribute, $attributevalue) {
if (!$this->running_javascript()) {
return;
}
// Exception if it timesout and the element is still there.
$msg = 'The "' . $node->getXPath() . '" xpath node is not visible and it should be visible';
$exception = new ExpectationException($msg, $this->getSession());
// It will stop spinning once the $args[1]) == $args[2], and method returns true.
$this->spin(
function($context, $args) {
if ($args[0]->getAttribute($args[1]) == $args[2]) {
return true;
}
return false;
},
array($node, $attribute, $attributevalue),
self::EXTENDED_TIMEOUT,
$exception,
true
);
}
/**
* Ensures that the provided element is visible and we can interact with it.
*

View File

@ -11,6 +11,19 @@ body.behat-site {
.dropdown-item {
margin-top: 4px !important; /* stylelint-disable declaration-no-important */
}
// Remove following after MDL-57172 is fixed.
&.drawer-ease {
-webkit-transition: initial;
-moz-transition: initial;
transition: initial;
}
[data-region="drawer"] {
-webkit-transition: initial;
-moz-transition: initial;
transition: initial;
}
}
.phpinfo table,

View File

@ -93,6 +93,7 @@ class behat_theme_boost_behat_navigation extends behat_navigation {
$expanded = $node->getAttribute('aria-expanded');
if ($expanded === 'false') {
$node->click();
$this->ensure_node_attribute_is_set($node, 'aria-expanded', 'true');
$this->wait_for_pending_js();
}
}