Skip to content

Commit

Permalink
MDL-51014 behat: Wait for filepicker to load repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Johnson authored and sammarshallou committed Aug 10, 2015
1 parent 57739a7 commit c5639c9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/behat/behat_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ protected function open_add_file_window($filemanagernode, $repositoryname) {
$this->ensure_node_is_visible($add);
$add->click();

// Wait for the default repository (if any) to load. This checks that
// the relevant div exists and that it does not include the loading image.
$this->ensure_element_exists(
"//div[contains(concat(' ', normalize-space(@class), ' '), ' file-picker ')]" .
"//div[contains(concat(' ', normalize-space(@class), ' '), ' fp-content ')]" .
"[not(descendant::div[contains(concat(' ', normalize-space(@class), ' '), ' fp-content-loading ')])]",
'xpath_element');

// Getting the repository link and opening it.
$repoexception = new ExpectationException('The "' . $repositoryname . '" repository has not been found', $this->getSession());

Expand All @@ -210,7 +218,11 @@ protected function open_add_file_window($filemanagernode, $repositoryname) {

// Selecting the repo.
$this->ensure_node_is_visible($repositorylink);
$repositorylink->click();
if (!$repositorylink->getParent()->getParent()->hasClass('active')) {
// If the repository link is active, then the repository is already loaded.
// Clicking it while it's active causes issues, so only click it when it isn't (see MDL-51014).
$repositorylink->click();
}
}

/**
Expand Down

0 comments on commit c5639c9

Please sign in to comment.