From ee3d5265702279eae642abfa303856ca6525c50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Wed, 2 Sep 2020 12:04:04 +0200 Subject: [PATCH] fixup! Adjust acceptance tests to changes in @nextcloud/vue 2.6.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- .../bootstrap/FilesAppSharingContext.php | 140 +++++++++++------- 1 file changed, 90 insertions(+), 50 deletions(-) diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php index 5683363619a56..24ab36548ebbf 100644 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php @@ -203,109 +203,117 @@ public static function copyLinkButton() { /** * @return Locator */ - public static function shareLinkMenuButton() { - return Locator::forThe()->css(".sharing-entry__actions .action-item__menutoggle")-> + public static function shareLinkMenuTrigger() { + return Locator::forThe()->css(".sharing-entry__actions .trigger")-> descendantOf(self::shareLinkRow())-> + describedAs("Share link menu trigger in the details view in Files app"); + } + + /** + * @return Locator + */ + public static function shareLinkMenuButton() { + return Locator::forThe()->css(".action-item__menutoggle")-> + descendantOf(self::shareLinkMenuTrigger())-> describedAs("Share link menu button in the details view in Files app"); } /** * @return Locator */ - public static function shareLinkMenu() { - return Locator::forThe()->css(".sharing-entry__actions .action-item__menu")-> - descendantOf(self::shareLinkRow())-> + public static function shareLinkMenu($shareLinkMenuTriggerElement) { + return Locator::forThe()->xpath("//*[@id = " . $shareLinkMenuTriggerElement->getWrappedElement()->getXpath() . "/@aria-describedby]")-> describedAs("Share link menu in the details view in Files app"); } /** * @return Locator */ - public static function hideDownloadCheckbox() { + public static function hideDownloadCheckbox($shareLinkMenuTriggerElement) { // forThe()->checkbox("Hide download") can not be used here; that would // return the checkbox itself, but the element that the user interacts // with is the label. return Locator::forThe()->xpath("//label[normalize-space() = 'Hide download']")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Hide download checkbox in the details view in Files app"); } /** * @return Locator */ - public static function hideDownloadCheckboxInput() { + public static function hideDownloadCheckboxInput($shareLinkMenuTriggerElement) { return Locator::forThe()->checkbox("Hide download")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Hide download checkbox input in the details view in Files app"); } /** * @return Locator */ - public static function allowUploadAndEditingRadioButton() { + public static function allowUploadAndEditingRadioButton($shareLinkMenuTriggerElement) { // forThe()->radio("Allow upload and editing") can not be used here; // that would return the radio button itself, but the element that the // user interacts with is the label. return Locator::forThe()->xpath("//label[normalize-space() = 'Allow upload and editing']")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Allow upload and editing radio button in the details view in Files app"); } /** * @return Locator */ - public static function passwordProtectCheckbox() { + public static function passwordProtectCheckbox($shareLinkMenuTriggerElement) { // forThe()->checkbox("Password protect") can not be used here; that // would return the checkbox itself, but the element that the user // interacts with is the label. return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect']")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Password protect checkbox in the details view in Files app"); } /** * @return Locator */ - public static function passwordProtectCheckboxInput() { + public static function passwordProtectCheckboxInput($shareLinkMenuTriggerElement) { return Locator::forThe()->checkbox("Password protect")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Password protect checkbox input in the details view in Files app"); } /** * @return Locator */ - public static function passwordProtectField() { - return Locator::forThe()->css(".share-link-password input.action-input__input")->descendantOf(self::shareLinkMenu())-> + public static function passwordProtectField($shareLinkMenuTriggerElement) { + return Locator::forThe()->css(".share-link-password input.action-input__input")->descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Password protect field in the details view in Files app"); } /** * @return Locator */ - public static function disabledPasswordProtectField() { - return Locator::forThe()->css(".share-link-password input.action-input__input[disabled]")->descendantOf(self::shareLinkMenu())-> + public static function disabledPasswordProtectField($shareLinkMenuTriggerElement) { + return Locator::forThe()->css(".share-link-password input.action-input__input[disabled]")->descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Disabled password protect field in the details view in Files app"); } /** * @return Locator */ - public static function passwordProtectByTalkCheckbox() { + public static function passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement) { // forThe()->checkbox("Password protect by Talk") can not be used here; // that would return the checkbox itself, but the element that the user // interacts with is the label. return Locator::forThe()->xpath("//label[normalize-space() = 'Password protect by Talk']")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Password protect by Talk checkbox in the details view in Files app"); } /** * @return Locator */ - public static function passwordProtectByTalkCheckboxInput() { + public static function passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement) { return Locator::forThe()->checkbox("Password protect by Talk")-> - descendantOf(self::shareLinkMenu())-> + descendantOf(self::shareLinkMenu($shareLinkMenuTriggerElement))-> describedAs("Password protect by Talk checkbox input in the details view in Files app"); } @@ -336,15 +344,17 @@ public function iShareWith($fileName, $shareWithName) { * @Given I write down the shared link */ public function iWriteDownTheSharedLink() { + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + // Close the share link menu if it is open to ensure that it does not // cover the copy link button. if (!WaitFor::elementToBeEventuallyNotShown( $this->actor, - self::shareLinkMenu(), + self::shareLinkMenu($shareLinkMenuTriggerElement), $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { // It may not be possible to click on the menu button (due to the // menu itself covering it), so "Esc" key is pressed instead. - $this->actor->find(self::shareLinkMenu(), 2)->getWrappedElement()->keyPress(27); + $this->actor->find(self::shareLinkMenu($shareLinkMenuTriggerElement), 2)->getWrappedElement()->keyPress(27); } $this->actor->find(self::copyLinkButton(), 10)->click(); @@ -363,7 +373,8 @@ public function iSetTheDownloadOfTheSharedLinkAsHidden() { $this->iSeeThatTheDownloadOfTheLinkShareIsShown(); - $this->actor->find(self::hideDownloadCheckbox(), 2)->click(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + $this->actor->find(self::hideDownloadCheckbox($shareLinkMenuTriggerElement), 2)->click(); } /** @@ -374,7 +385,8 @@ public function iSetTheDownloadOfTheSharedLinkAsShown() { $this->iSeeThatTheDownloadOfTheLinkShareIsHidden(); - $this->actor->find(self::hideDownloadCheckbox(), 2)->click(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + $this->actor->find(self::hideDownloadCheckbox($shareLinkMenuTriggerElement), 2)->click(); } /** @@ -383,7 +395,8 @@ public function iSetTheDownloadOfTheSharedLinkAsShown() { public function iSetTheSharedLinkAsEditable() { $this->showShareLinkMenuIfNeeded(); - $this->actor->find(self::allowUploadAndEditingRadioButton(), 2)->click(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + $this->actor->find(self::allowUploadAndEditingRadioButton($shareLinkMenuTriggerElement), 2)->click(); } /** @@ -392,9 +405,10 @@ public function iSetTheSharedLinkAsEditable() { public function iProtectTheSharedLinkWithThePassword($password) { $this->showShareLinkMenuIfNeeded(); - $this->actor->find(self::passwordProtectCheckbox(), 2)->click(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + $this->actor->find(self::passwordProtectCheckbox($shareLinkMenuTriggerElement), 2)->click(); - $this->actor->find(self::passwordProtectField(), 2)->setValue($password . "\r"); + $this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 2)->setValue($password . "\r"); } /** @@ -405,7 +419,8 @@ public function iSetThePasswordOfTheSharedLinkAsProtectedByTalk() { $this->iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk(); - $this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement), 2)->click(); } /** @@ -416,7 +431,8 @@ public function iSetThePasswordOfTheSharedLinkAsNotProtectedByTalk() { $this->iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk(); - $this->actor->find(self::passwordProtectByTalkCheckbox(), 2)->click(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement), 2)->click(); } /** @@ -487,7 +503,7 @@ public function iSeeThatResharingTheFileIsNotAllowed() { public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertEquals( $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); } @@ -498,7 +514,7 @@ public function iSeeThatCanNotBeAllowedToEditTheShare($sharedWithName) { public function iSeeThatCanEditTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertTrue( $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -509,7 +525,7 @@ public function iSeeThatCanEditTheShare($sharedWithName) { public function iSeeThatCanNotEditTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertFalse( $this->actor->find(self::canEditCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -520,7 +536,7 @@ public function iSeeThatCanNotEditTheShare($sharedWithName) { public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertEquals( $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->getWrappedElement()->getAttribute("disabled"), "disabled"); } @@ -531,7 +547,7 @@ public function iSeeThatCanNotBeAllowedToCreateInTheShare($sharedWithName) { public function iSeeThatCanCreateInTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertTrue( $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -542,7 +558,7 @@ public function iSeeThatCanCreateInTheShare($sharedWithName) { public function iSeeThatCanNotCreateInTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertFalse( $this->actor->find(self::canCreateCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -553,7 +569,7 @@ public function iSeeThatCanNotCreateInTheShare($sharedWithName) { public function iSeeThatCanReshareTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertTrue( $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -564,7 +580,7 @@ public function iSeeThatCanReshareTheShare($sharedWithName) { public function iSeeThatCanNotReshareTheShare($sharedWithName) { $this->showShareWithMenuIfNeeded($sharedWithName); - $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 2); + $shareWithMenuTriggerElement = $this->actor->find(self::shareWithMenuTrigger($sharedWithName), 10); PHPUnit_Framework_Assert::assertFalse( $this->actor->find(self::canReshareCheckboxInput($sharedWithName, $shareWithMenuTriggerElement), 10)->isChecked()); } @@ -575,7 +591,8 @@ public function iSeeThatCanNotReshareTheShare($sharedWithName) { public function iSeeThatTheDownloadOfTheLinkShareIsHidden() { $this->showShareLinkMenuIfNeeded(); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput(), 10)->isChecked()); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); + PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -584,18 +601,35 @@ public function iSeeThatTheDownloadOfTheLinkShareIsHidden() { public function iSeeThatTheDownloadOfTheLinkShareIsShown() { $this->showShareLinkMenuIfNeeded(); - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput(), 10)->isChecked()); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); + PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** * @Then I see that the password protect is disabled while loading */ public function iSeeThatThePasswordProtectIsDisabledWhileLoading() { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::disabledPasswordProtectField(), 10)); + // Due to the additional time needed to find the menu trigger element it + // could happen that the request to modify the password protect was + // completed and the field enabled again even before finding the + // disabled field started. Therefore, if the disabled field could not be + // found it is just assumed that it was already enabled again. + // Nevertheless, this check should be done anyway to ensure that the + // following scenario steps are not executed before the request to the + // server was done. + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); + + try { + $this->actor->find(self::disabledPasswordProtectField($shareLinkMenuTriggerElement), 5); + } catch (NoSuchElementException $exception) { + echo "The password protect field was not found disabled after " . (5 * $this->actor->getFindTimeoutMultiplier()) . " seconds, assumming that it was disabled and enabled again before the check started and continuing"; + + return; + } if (!WaitFor::elementToBeEventuallyNotShown( $this->actor, - self::disabledPasswordProtectField(), + self::disabledPasswordProtectField($shareLinkMenuTriggerElement), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { PHPUnit_Framework_Assert::fail("The password protect field is still disabled after $timeout seconds"); } @@ -607,8 +641,9 @@ public function iSeeThatThePasswordProtectIsDisabledWhileLoading() { public function iSeeThatTheLinkShareIsPasswordProtected() { $this->showShareLinkMenuIfNeeded(); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput(), 10)->isChecked(), "Password protect checkbox is checked"); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectField(), 10)->isVisible(), "Password protect field is visible"); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); + PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked(), "Password protect checkbox is checked"); + PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectField($shareLinkMenuTriggerElement), 10)->isVisible(), "Password protect field is visible"); } /** @@ -617,7 +652,8 @@ public function iSeeThatTheLinkShareIsPasswordProtected() { public function iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk() { $this->showShareLinkMenuIfNeeded(); - PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput(), 10)->isChecked()); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); + PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -626,7 +662,8 @@ public function iSeeThatThePasswordOfTheLinkShareIsProtectedByTalk() { public function iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk() { $this->showShareLinkMenuIfNeeded(); - PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput(), 10)->isChecked()); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); + PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::passwordProtectByTalkCheckboxInput($shareLinkMenuTriggerElement), 10)->isChecked()); } /** @@ -635,9 +672,10 @@ public function iSeeThatThePasswordOfTheLinkShareIsNotProtectedByTalk() { public function iSeeThatTheCheckboxToProtectThePasswordOfTheLinkShareByTalkIsNotShown() { $this->showShareLinkMenuIfNeeded(); + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 10); try { PHPUnit_Framework_Assert::assertFalse( - $this->actor->find(self::passwordProtectByTalkCheckbox())->isVisible()); + $this->actor->find(self::passwordProtectByTalkCheckbox($shareLinkMenuTriggerElement))->isVisible()); } catch (NoSuchElementException $exception) { } } @@ -652,13 +690,15 @@ public function iShareTheLinkForProtectedByThePassword($fileName, $password) { } private function showShareLinkMenuIfNeeded() { + $shareLinkMenuTriggerElement = $this->actor->find(self::shareLinkMenuTrigger(), 2); + // In some cases the share menu is hidden after clicking on an action of // the menu. Therefore, if the menu is visible, wait a little just in // case it is in the process of being hidden due to a previous action, // in which case it is shown again. if (WaitFor::elementToBeEventuallyNotShown( $this->actor, - self::shareLinkMenu(), + self::shareLinkMenu($shareLinkMenuTriggerElement), $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) { $this->actor->find(self::shareLinkMenuButton(), 10)->click(); }