summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2017-12-22 08:58:19 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2017-12-22 09:13:47 +0100
commite24a1c51e8d960d83ad8672f40e6cbb5d2f45ce7 (patch)
tree924c140bcc3fd09fe2cab88fdd6c876af4079f7f /tests
parent8916735dd3f70f7e7466c7c8af95cbe6a130c1f0 (diff)
downloadnextcloud-server-e24a1c51e8d960d83ad8672f40e6cbb5d2f45ce7.tar.gz
nextcloud-server-e24a1c51e8d960d83ad8672f40e6cbb5d2f45ce7.zip
Wait for the shared link to be set in the acceptance tests
When clicking on "Share link" in the "Sharing" tab of the Files app an input field with the link appears. That input field already exists in the DOM, although empty, before clicking on "Share link", and when that is done the proper value is set and then the input field is shown. In the acceptance tests "getValue()" can return the value of hidden elements too, so as long as an element exists its value is returned without waiting for the field to be visible. Due to this if the test code runs too fast the "I write down the shared link" step could be executed before the proper value was set, so the shared link got in that case would be an empty value, and this would lead to failures when the following steps were executed. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 02be0937675..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();
}
/**
@@ -641,6 +650,20 @@ 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;