Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stable10]Add acceptance test for checking changing sharing permissions #35296

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions tests/acceptance/features/bootstrap/WebUIFilesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/features/lib/FilesPageBasic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
3 changes: 3 additions & 0 deletions tests/acceptance/features/lib/FilesPageCRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
20 changes: 20 additions & 0 deletions tests/acceptance/features/lib/FilesPageElement/FileActionsMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
13 changes: 13 additions & 0 deletions tests/acceptance/features/lib/FilesPageElement/FileRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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