Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-10-22 13:01:25 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-10-30 17:18:55 +0300
commitd4f39a9033e809b498dd577f9b7ce8e8ffcbb69d (patch)
tree07f5cc32bdd9a55fbd9c4868dc047193129b2e2a /tests/acceptance
parenta1e3098322f3747181466632f11764ee6a8232a0 (diff)
Add acceptance tests for hiding download in link shares
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests/acceptance')
-rw-r--r--tests/acceptance/features/app-files.feature26
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php61
-rw-r--r--tests/acceptance/features/bootstrap/FilesSharingAppContext.php40
3 files changed, 127 insertions, 0 deletions
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature
index 74490180ad3..70e085ca665 100644
--- a/tests/acceptance/features/app-files.feature
+++ b/tests/acceptance/features/app-files.feature
@@ -121,6 +121,32 @@ Feature: app-files
And I open the Share menu
Then I see that the Share menu is shown
+ Scenario: hide download in a public shared link
+ Given I act as John
+ And I am logged in
+ And I share the link for "welcome.txt"
+ And I set the download of the shared link as hidden
+ And I write down the shared link
+ When I act as Jane
+ And I visit the shared link I wrote down
+ And I see that the current page is the shared link I wrote down
+ Then I see that the download button is not shown
+ And I see that the Share menu button is not shown
+
+ Scenario: show download again in a public shared link
+ Given I act as John
+ And I am logged in
+ And I share the link for "welcome.txt"
+ And I set the download of the shared link as hidden
+ And I set the download of the shared link as shown
+ And I write down the shared link
+ When I act as Jane
+ And I visit the shared link I wrote down
+ And I see that the current page is the shared link I wrote down
+ Then I see that the download button is shown
+ And I open the Share menu
+ And I see that the Share menu is shown
+
Scenario: creation is not possible by default in a public shared folder
Given I act as John
And I am logged in
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 408995b9a83..4b648bfc544 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -235,6 +235,27 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function hideDownloadCheckbox() {
+ // 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())->
+ describedAs("Hide download checkbox in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function hideDownloadCheckboxInput() {
+ return Locator::forThe()->checkbox("Hide download")->
+ descendantOf(self::shareLinkMenu())->
+ describedAs("Hide download checkbox input in the details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function allowUploadAndEditingRadioButton() {
// forThe()->radio("Allow upload and editing") can not be used here;
// that would return the radio button itself, but the element that the
@@ -335,6 +356,28 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @When I set the download of the shared link as hidden
+ */
+ public function iSetTheDownloadOfTheSharedLinkAsHidden() {
+ $this->showShareLinkMenuIfNeeded();
+
+ $this->iSeeThatTheDownloadOfTheLinkShareIsShown();
+
+ $this->actor->find(self::hideDownloadCheckbox(), 2)->click();
+ }
+
+ /**
+ * @When I set the download of the shared link as shown
+ */
+ public function iSetTheDownloadOfTheSharedLinkAsShown() {
+ $this->showShareLinkMenuIfNeeded();
+
+ $this->iSeeThatTheDownloadOfTheLinkShareIsHidden();
+
+ $this->actor->find(self::hideDownloadCheckbox(), 2)->click();
+ }
+
+ /**
* @When I set the shared link as editable
*/
public function iSetTheSharedLinkAsEditable() {
@@ -461,6 +504,24 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that the download of the link share is hidden
+ */
+ public function iSeeThatTheDownloadOfTheLinkShareIsHidden() {
+ $this->showShareLinkMenuIfNeeded();
+
+ PHPUnit_Framework_Assert::assertTrue($this->actor->find(self::hideDownloadCheckboxInput(), 10)->isChecked());
+ }
+
+ /**
+ * @Then I see that the download of the link share is shown
+ */
+ public function iSeeThatTheDownloadOfTheLinkShareIsShown() {
+ $this->showShareLinkMenuIfNeeded();
+
+ PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::hideDownloadCheckboxInput(), 10)->isChecked());
+ }
+
+ /**
* @Then I see that the working icon for password protect is shown
*/
public function iSeeThatTheWorkingIconForPasswordProtectIsShown() {
diff --git a/tests/acceptance/features/bootstrap/FilesSharingAppContext.php b/tests/acceptance/features/bootstrap/FilesSharingAppContext.php
index 1fe12d5f42d..531184442dd 100644
--- a/tests/acceptance/features/bootstrap/FilesSharingAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesSharingAppContext.php
@@ -104,6 +104,14 @@ class FilesSharingAppContext implements Context, ActorAwareInterface {
}
/**
+ * @return Locator
+ */
+ public static function downloadButton() {
+ return Locator::forThe()->id("downloadFile")->
+ describedAs("Download button in Shared file page");
+ }
+
+ /**
* @When I visit the shared link I wrote down
*/
public function iVisitTheSharedLinkIWroteDown() {
@@ -199,10 +207,42 @@ class FilesSharingAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that the Share menu button is not shown
+ */
+ public function iSeeThatTheShareMenuButtonIsNotShown() {
+ try {
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::shareMenuButton())->isVisible());
+ } catch (NoSuchElementException $exception) {
+ }
+ }
+
+ /**
* @Then I see that the shared file preview shows the text :text
*/
public function iSeeThatTheSharedFilePreviewShowsTheText($text) {
PHPUnit_Framework_Assert::assertContains($text, $this->actor->find(self::textPreview(), 10)->getText());
}
+ /**
+ * @Then I see that the download button is shown
+ */
+ public function iSeeThatTheDownloadButtonIsShown() {
+ if (!WaitFor::elementToBeEventuallyShown(
+ $this->actor, self::downloadButton(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
+ PHPUnit_Framework_Assert::fail("The download button is not visible yet after $timeout seconds");
+ }
+ }
+
+ /**
+ * @Then I see that the download button is not shown
+ */
+ public function iSeeThatTheDownloadButtonIsNotShown() {
+ try {
+ PHPUnit_Framework_Assert::assertFalse(
+ $this->actor->find(self::downloadButton())->isVisible());
+ } catch (NoSuchElementException $exception) {
+ }
+ }
+
}