diff --git a/tests/acceptance/features/bootstrap/WebUIFilesContext.php b/tests/acceptance/features/bootstrap/WebUIFilesContext.php index 7a7f71f270f5..76ce913f754c 100644 --- a/tests/acceptance/features/bootstrap/WebUIFilesContext.php +++ b/tests/acceptance/features/bootstrap/WebUIFilesContext.php @@ -1655,6 +1655,60 @@ public function itShouldNotBePossibleToDeleteFileFolderUsingTheWebUI($name) { } } + /** + * @Then it should be possible to delete file/folder :name using the webUI + * + * @param string $name + * + * @return void + * @throws \Exception + */ + public function itShouldBePossibleToDeleteFileFolderUsingTheWebUI($name) { + $this->deleteTheFileUsingTheWebUI($name, true); + } + + /** + * @Then /^the option to (delete|rename|download)\s?(?:file|folder) "([^"]*)" should (not|)\s?be available in the webUI$/ + * + * @param string $action + * @param string $name + * @param string $shouldOrNot + * + * @return void + * @throws \Exception + */ + public function optionShouldNotBeAvailable($action, $name, $shouldOrNot) { + $visible = $shouldOrNot !== "not"; + $pageObject = $this->getCurrentPageObject(); + $session = $this->getSession(); + $pageObject->waitTillPageIsLoaded($session); + $fileRow = $pageObject->findFileRowByName($name, $session); + $action = \ucfirst($action); + if ($visible) { + PHPUnit\Framework\Assert::assertTrue($fileRow->isActionLabelAvailable($action, $session)); + } else { + PHPUnit\Framework\Assert::assertFalse($fileRow->isActionLabelAvailable($action, $session)); + } + $fileRow->clickFileActionButton(); + } + + /** + * @Then /^the option to upload file should (not|)\s?be available in the webUI$/ + * + * @param string $shouldOrNot + * + * @return void + * @throws \Exception + */ + public function uploadButtonShouldNotBeVisible($shouldOrNot) { + $visible = $shouldOrNot !== "not"; + if ($visible) { + PHPUnit\Framework\Assert::assertTrue($this->getCurrentPageObject()->isUploadButtonAvailable()); + } else { + PHPUnit\Framework\Assert::assertFalse($this->getCurrentPageObject()->isUploadButtonAvailable()); + } + } + /** * @Then the files action menu should be completely visible after opening it using the webUI * diff --git a/tests/acceptance/features/lib/FilesPageBasic.php b/tests/acceptance/features/lib/FilesPageBasic.php index 32076ab51628..eb14fd07297e 100644 --- a/tests/acceptance/features/lib/FilesPageBasic.php +++ b/tests/acceptance/features/lib/FilesPageBasic.php @@ -51,6 +51,7 @@ abstract class FilesPageBasic extends OwncloudPage { protected $appSettingsContentId = "app-settings-content"; protected $styleOfCheckboxWhenVisible = "display: block;"; protected $detailsDialogXpath = "//*[contains(@id, 'app-sidebar') and not(contains(@class, 'disappear'))]"; + protected $newFileFolderButtonXpath = './/*[@id="controls"]//a[@class="button new"]'; /** * @return string @@ -649,4 +650,17 @@ public function enableShowHiddenFilesSettings() { ); $showHiddenFilesCheckBox->click(); } + + /** + * Return is New File/folder button is available in the webUI + * + * @return boolean + */ + public function isUploadButtonAvailable() { + $btn = $this->find("xpath", $this->newFileFolderButtonXpath); + if ($btn === null) { + return false; + } + return $btn->isVisible(); + } } diff --git a/tests/acceptance/features/lib/FilesPageCRUD.php b/tests/acceptance/features/lib/FilesPageCRUD.php index d8940b91f023..5181f0df46e9 100644 --- a/tests/acceptance/features/lib/FilesPageCRUD.php +++ b/tests/acceptance/features/lib/FilesPageCRUD.php @@ -416,6 +416,9 @@ public function deleteFile( $message = "INFORMATION: retried to delete file '$name' $counter times"; echo $message; \error_log($message); + if ($counter === $maxRetries) { + throw new \Exception($message); + } } } diff --git a/tests/acceptance/features/lib/FilesPageElement/FileActionsMenu.php b/tests/acceptance/features/lib/FilesPageElement/FileActionsMenu.php index 40e8f602e604..fbba563e9e08 100644 --- a/tests/acceptance/features/lib/FilesPageElement/FileActionsMenu.php +++ b/tests/acceptance/features/lib/FilesPageElement/FileActionsMenu.php @@ -218,4 +218,24 @@ public function getRenameActionLabel() { public function getActionLabelLocalized($action) { return $this->findButton($action)->getText(); } + + /** + * return if the Action label is visible + * + * @param string $action ("Delete"|"Rename"|"Details") + * + * @return boolean + */ + public function isActionLabelVisible($action) { + $xpathLocator = \sprintf($this->fileActionXpath, $action); + $this->waitTillElementIsNotNull($xpathLocator); + $button = $this->menuElement->find( + "xpath", + $xpathLocator + ); + if (!$button) { + return false; + } + return $button->isVisible(); + } } diff --git a/tests/acceptance/features/lib/FilesPageElement/FileRow.php b/tests/acceptance/features/lib/FilesPageElement/FileRow.php index d0d90eefb46d..be2e52a01aff 100644 --- a/tests/acceptance/features/lib/FilesPageElement/FileRow.php +++ b/tests/acceptance/features/lib/FilesPageElement/FileRow.php @@ -572,4 +572,17 @@ public function getHighlightsElement() { ); return $element; } + + /** + * Returns if action menu is Available in the fileRow + * + * @param string $actionLabel + * @param Session $session + * + * @return boolean + */ + public function isActionLabelAvailable($actionLabel, Session $session) { + $actionMenu = $this->openFileActionsMenu($session); + return $actionMenu->isActionLabelVisible($actionLabel); + } } diff --git a/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature b/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature index 494cba0399a1..6d3f2f17acc2 100644 --- a/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature +++ b/tests/acceptance/features/webUISharingPublic/shareByPublicLink.feature @@ -424,3 +424,60 @@ Feature: Share by public link #Then the following folder should be listed on the webUI #| newfolder | #| newfolder | + + Scenario: Permissions work correctly on public link share with upload-write-without-modify + Given the user has created a new public link for folder "simple-folder" using the webUI with + | permission | upload-write-without-modify | + When the public accesses the last created public link using the webUI + Then the option to rename file "lorem.txt" should not be available in the webUI + And the option to delete file "lorem.txt" should not be available in the webUI + And the option to upload file should be available in the webUI + + Scenario: Permissions work correctly on public link share with read-write + Given the user has created a new public link for folder "simple-folder" using the webUI with + | permission | read-write | + When the public accesses the last created public link using the webUI + Then the option to rename file "lorem.txt" should be available in the webUI + And the option to delete file "lorem.txt" should be available in the webUI + And the option to upload file should be available in the webUI + + Scenario: User tries to upload existing file in public link share with permissions upload-write-without-modify + Given the user has created a new public link for folder "simple-folder" using the webUI with + | permission | upload-write-without-modify | + And the public accesses the last created public link using the webUI + When the user uploads file "lorem.txt" using the webUI + Then a notification should be displayed on the webUI with the text "The file lorem.txt already exists" + And file "lorem.txt" should be listed on the webUI + And file "lorem (2).txt" should not be listed on the webUI + + Scenario: User tries to upload existing file in public link share with permissions read-write + Given the user has created a new public link for folder "simple-folder" using the webUI with + | permission | read-write | + And the public accesses the last created public link using the webUI + When the user uploads file "lorem.txt" keeping both new and existing files using the webUI + Then file "lorem.txt" should be listed on the webUI + And file "lorem (2).txt" should be listed on the webUI + + Scenario: Editing the permission on a existing share from read-write to upload-write-without-modify works correctly + Given the user has created a new public link for folder "simple-folder" using the webUI with + | permission | read-write | + And the public accesses the last created public link using the webUI + Then it should be possible to delete file "lorem.txt" using the webUI + When the user browses to the files page + And the user opens the share dialog for folder "simple-folder" + And the user opens the public link share tab + And the user changes the permission of the public link named "Public link" to "upload-write-without-modify" + And the public accesses the last created public link using the webUI + Then the option to delete file "lorem-big.txt" should not be available in the webUI + + Scenario: Editing the permission on a existing share from upload-write-without-modify to read-write works correctly + Given the user has created a new public link for folder "simple-folder" using the webUI with + | permission | upload-write-without-modify | + And the public accesses the last created public link using the webUI + Then the option to delete file "lorem.txt" should not be available in the webUI + When the user browses to the files page + And the user opens the share dialog for folder "simple-folder" + And the user opens the public link share tab + And the user changes the permission of the public link named "Public link" to "read-write" + And the public accesses the last created public link using the webUI + Then it should be possible to delete file "lorem-big.txt" using the webUI \ No newline at end of file