diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2017-12-22 10:35:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-22 10:35:27 +0100 |
commit | 1477b971b29925a1b7708871c426cf47fae231ad (patch) | |
tree | 0777e748d53c07c1869b0cbb1e8f5606f156a5c0 | |
parent | d0e7b0d8c3bc24922644c605a3fa61b467a40a65 (diff) | |
parent | e24a1c51e8d960d83ad8672f40e6cbb5d2f45ce7 (diff) | |
download | nextcloud-server-1477b971b29925a1b7708871c426cf47fae231ad.tar.gz nextcloud-server-1477b971b29925a1b7708871c426cf47fae231ad.zip |
Merge pull request #7605 from nextcloud/wait-for-the-shared-link-to-be-set-in-the-acceptance-tests
Wait for the shared link to be set in the acceptance tests
-rw-r--r-- | tests/acceptance/features/bootstrap/FilesAppContext.php | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 338823a9478..4951dc43f1d 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -452,7 +452,16 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Given I write down the shared link */ public function iWriteDownTheSharedLink() { - $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::shareLinkField(), 10)->getValue(); + // The shared link field always exists in the DOM (once the "Sharing" + // tab is loaded), but its value is the actual shared link only when it + // is visible. + if (!$this->waitForElementToBeEventuallyShown( + self::shareLinkField(), + $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { + PHPUnit_Framework_Assert::fail("The shared link was not shown yet after $timeout seconds"); + } + + $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::shareLinkField())->getValue(); } /** @@ -606,7 +615,9 @@ class FilesAppContext implements Context, ActorAwareInterface { * @When I see that the :tabName tab in the details view is eventually loaded */ public function iSeeThatTheTabInTheDetailsViewIsEventuallyLoaded($tabName) { - if (!$this->waitForElementToBeEventuallyNotShown(self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName), $timeout = 10)) { + if (!$this->waitForElementToBeEventuallyNotShown( + self::loadingIconForTabInCurrentSectionDetailsViewNamed($tabName), + $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { PHPUnit_Framework_Assert::fail("The $tabName tab in the details view has not been loaded after $timeout seconds"); } } @@ -622,7 +633,9 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Then I see that the working icon for password protect is eventually not shown */ public function iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown() { - if (!$this->waitForElementToBeEventuallyNotShown(self::passwordProtectWorkingIcon(), $timeout = 10)) { + if (!$this->waitForElementToBeEventuallyNotShown( + self::passwordProtectWorkingIcon(), + $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { PHPUnit_Framework_Assert::fail("The working icon for password protect is still shown after $timeout seconds"); } } @@ -637,10 +650,24 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown(); } + private function waitForElementToBeEventuallyShown($elementLocator, $timeout = 10, $timeoutStep = 1) { + $actor = $this->actor; + + $elementShownCallback = function() use ($actor, $elementLocator) { + try { + return $actor->find($elementLocator)->isVisible(); + } catch (NoSuchElementException $exception) { + return false; + } + }; + + return Utils::waitFor($elementShownCallback, $timeout, $timeoutStep); + } + private function waitForElementToBeEventuallyNotShown($elementLocator, $timeout = 10, $timeoutStep = 1) { $actor = $this->actor; - $elementNotFoundCallback = function() use ($actor, $elementLocator) { + $elementNotShownCallback = function() use ($actor, $elementLocator) { try { return !$actor->find($elementLocator)->isVisible(); } catch (NoSuchElementException $exception) { @@ -648,6 +675,6 @@ class FilesAppContext implements Context, ActorAwareInterface { } }; - return Utils::waitFor($elementNotFoundCallback, $timeout, $timeoutStep); + return Utils::waitFor($elementNotShownCallback, $timeout, $timeoutStep); } } |