From 37238725d632afb8f09db1f60c46dacaa3e701ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 22 Dec 2017 08:57:50 +0100 Subject: [PATCH 1/3] Fix typo in callback name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- tests/acceptance/features/bootstrap/FilesAppContext.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 338823a947892..17ad55d45a9df 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -640,7 +640,7 @@ public function iShareTheLinkForProtectedByThePassword($fileName, $password) { 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 +648,6 @@ private function waitForElementToBeEventuallyNotShown($elementLocator, $timeout } }; - return Utils::waitFor($elementNotFoundCallback, $timeout, $timeoutStep); + return Utils::waitFor($elementNotShownCallback, $timeout, $timeoutStep); } } From 8916735dd3f70f7e7466c7c8af95cbe6a130c1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 22 Dec 2017 09:12:29 +0100 Subject: [PATCH 2/3] Add missing timeout multiplier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- tests/acceptance/features/bootstrap/FilesAppContext.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 17ad55d45a9df..02be093767575 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -606,7 +606,9 @@ public function iSeeThatTheTagInTheDropdownForTagsInTheDetailsViewIsNotChecked($ * @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 +624,9 @@ public function iSeeThatTheWorkingIconForPasswordProtectIsShown() { * @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"); } } From e24a1c51e8d960d83ad8672f40e6cbb5d2f45ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 22 Dec 2017 08:58:19 +0100 Subject: [PATCH 3/3] Wait for the shared link to be set in the acceptance tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../features/bootstrap/FilesAppContext.php | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 02be093767575..4951dc43f1d9a 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -452,7 +452,16 @@ public function iShareTheLinkFor($fileName) { * @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 @@ public function iShareTheLinkForProtectedByThePassword($fileName, $password) { $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;