Add acceptance tests for hiding download in link shares

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-10-22 12:01:25 +02:00
parent a1e3098322
commit d4f39a9033
3 changed files with 127 additions and 0 deletions

View File

@ -121,6 +121,32 @@ Feature: app-files
And I open the Share menu And I open the Share menu
Then I see that the Share menu is shown 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 Scenario: creation is not possible by default in a public shared folder
Given I act as John Given I act as John
And I am logged in And I am logged in

View File

@ -232,6 +232,27 @@ class FilesAppContext implements Context, ActorAwareInterface {
describedAs("Copy link menu item in the share link menu in the details view in Files app"); describedAs("Copy link menu item in the share link menu in the details view in Files app");
} }
/**
* @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 * @return Locator
*/ */
@ -334,6 +355,28 @@ class FilesAppContext implements Context, ActorAwareInterface {
$this->actor->find(self::itemInDropdownForTag($tag), 10)->click(); $this->actor->find(self::itemInDropdownForTag($tag), 10)->click();
} }
/**
* @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 * @When I set the shared link as editable
*/ */
@ -460,6 +503,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 * @Then I see that the working icon for password protect is shown
*/ */

View File

@ -103,6 +103,14 @@ class FilesSharingAppContext implements Context, ActorAwareInterface {
describedAs("Text preview in Shared file page"); describedAs("Text preview in Shared file page");
} }
/**
* @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 * @When I visit the shared link I wrote down
*/ */
@ -198,6 +206,17 @@ class FilesSharingAppContext implements Context, ActorAwareInterface {
$this->actor->find(self::saveItemInShareMenu())->isVisible()); $this->actor->find(self::saveItemInShareMenu())->isVisible());
} }
/**
* @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 * @Then I see that the shared file preview shows the text :text
*/ */
@ -205,4 +224,25 @@ class FilesSharingAppContext implements Context, ActorAwareInterface {
PHPUnit_Framework_Assert::assertContains($text, $this->actor->find(self::textPreview(), 10)->getText()); 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) {
}
}
} }