summaryrefslogtreecommitdiffstats
path: root/tests/acceptance/features/bootstrap
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-11-23 12:56:52 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-11-23 15:13:15 +0100
commit75b734ec98156d4d1ca1b94dc99964e9c51b68bd (patch)
treec65a0989427d509bc8c3e5738b00876eeecff761 /tests/acceptance/features/bootstrap
parentd9ad31bd7fb6a24864b95ce049e17458f36d9165 (diff)
downloadnextcloud-server-75b734ec98156d4d1ca1b94dc99964e9c51b68bd.tar.gz
nextcloud-server-75b734ec98156d4d1ca1b94dc99964e9c51b68bd.zip
Add acceptance tests for folders that can not be reshared
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance/features/bootstrap')
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index a0d877a1aa9..b6c4e465ecb 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -269,6 +269,45 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function shareWithMenuButton($sharedWithName) {
+ return Locator::forThe()->css(".share-menu > .icon")->
+ descendantOf(self::sharedWithRow($sharedWithName))->
+ describedAs("Share with $sharedWithName menu button in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function shareWithMenu($sharedWithName) {
+ return Locator::forThe()->css(".share-menu > .menu")->
+ descendantOf(self::sharedWithRow($sharedWithName))->
+ describedAs("Share with $sharedWithName menu in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canReshareCheckbox($sharedWithName) {
+ // forThe()->checkbox("Can reshare") 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() = 'Can reshare']")->
+ descendantOf(self::shareWithMenu($sharedWithName))->
+ describedAs("Can reshare checkbox in the share with $sharedWithName menu in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function canReshareCheckboxInput($sharedWithName) {
+ return Locator::forThe()->checkbox("Can reshare")->
+ descendantOf(self::shareWithMenu($sharedWithName))->
+ describedAs("Can reshare checkbox input in the share with $sharedWithName menu in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function shareLinkRow() {
return Locator::forThe()->css(".linkShareView .shareWithList:first-child")->
descendantOf(self::detailsView())->
@@ -571,6 +610,17 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @When I set the share with :shareWithName as not reshareable
+ */
+ public function iSetTheShareWithAsNotReshareable($shareWithName) {
+ $this->showShareWithMenuIfNeeded($shareWithName);
+
+ $this->iSeeThatCanReshareTheShare($shareWithName);
+
+ $this->actor->find(self::canReshareCheckbox($shareWithName), 2)->click();
+ }
+
+ /**
* @Then I see that the current page is the Files app
*/
public function iSeeThatTheCurrentPageIsTheFilesApp() {
@@ -709,6 +759,36 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that resharing the file is not allowed
+ */
+ public function iSeeThatResharingTheFileIsNotAllowed() {
+ PHPUnit_Framework_Assert::assertEquals(
+ $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("disabled"), "disabled");
+ PHPUnit_Framework_Assert::assertEquals(
+ $this->actor->find(self::shareWithInput(), 10)->getWrappedElement()->getAttribute("placeholder"), "Resharing is not allowed");
+ }
+
+ /**
+ * @Then I see that :sharedWithName can reshare the share
+ */
+ public function iSeeThatCanReshareTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertTrue(
+ $this->actor->find(self::canReshareCheckboxInput($sharedWithName), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that :sharedWithName can not reshare the share
+ */
+ public function iSeeThatCanNotReshareTheShare($sharedWithName) {
+ $this->showShareWithMenuIfNeeded($sharedWithName);
+
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::canReshareCheckboxInput($sharedWithName), 10)->isChecked());
+ }
+
+ /**
* @Then I see that the download of the link share is hidden
*/
public function iSeeThatTheDownloadOfTheLinkShareIsHidden() {
@@ -809,4 +889,17 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
}
+ private function showShareWithMenuIfNeeded($shareWithName) {
+ // 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::shareWithMenu($shareWithName),
+ $timeout = 2 * $this->actor->getFindTimeoutMultiplier())) {
+ $this->actor->find(self::shareWithMenuButton($shareWithName), 10)->click();
+ }
+ }
+
}