diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-01-22 12:36:13 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-01-22 12:36:13 +0100 |
commit | 42457c8b232bb2f7a1e2f92004f59151a7d80cd8 (patch) | |
tree | 85829384c9b6f9df27648fd41bf3c835b94e1d77 | |
parent | 4fcabf167e121497bfae4dcdec0b8eb7e8f9d483 (diff) | |
download | nextcloud-server-42457c8b232bb2f7a1e2f92004f59151a7d80cd8.tar.gz nextcloud-server-42457c8b232bb2f7a1e2f92004f59151a7d80cd8.zip |
Add acceptance tests for moving and copying selections to another folder
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | tests/acceptance/features/app-files.feature | 39 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FileListContext.php | 87 |
2 files changed, 126 insertions, 0 deletions
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature index dc2b52f39d7..d5a607e209f 100644 --- a/tests/acceptance/features/app-files.feature +++ b/tests/acceptance/features/app-files.feature @@ -150,6 +150,24 @@ Feature: app-files And I enter in the folder named "Destination" And I see that the file list contains a file named "welcome.txt" + Scenario: move a selection to another folder + Given I am logged in + And I create a new folder named "Folder" + And I create a new folder named "Not selected folder" + And I create a new folder named "Destination" + When I select "welcome.txt" + And I select "Folder" + And I start the move or copy operation for the selected files + And I select "Destination" in the file picker + And I move to the last selected folder in the file picker + Then I see that the file list does not contain a file named "welcome.txt" + And I see that the file list does not contain a file named "Folder" + And I see that the file list contains a file named "Not selected folder" + And I enter in the folder named "Destination" + And I see that the file list contains a file named "welcome.txt" + And I see that the file list contains a file named "Folder" + And I see that the file list does not contain a file named "Not selected folder" + Scenario: copy a file to another folder Given I am logged in And I create a new folder named "Destination" @@ -163,6 +181,27 @@ Feature: app-files And I open the Files app And I see that the file list contains a file named "welcome.txt" + Scenario: copy a selection to another folder + Given I am logged in + And I create a new folder named "Folder" + And I create a new folder named "Not selected folder" + And I create a new folder named "Destination" + When I select "welcome.txt" + And I select "Folder" + And I start the move or copy operation for the selected files + And I select "Destination" in the file picker + And I copy to the last selected folder in the file picker + Then I enter in the folder named "Destination" + # The files will appear in the destination once the copy operation finishes + And I see that the file list contains a file named "welcome.txt" + And I see that the file list contains a file named "Folder" + And I see that the file list does not contain a file named "Not selected folder" + # The Files app is open again to reload the file list in the root folder + And I open the Files app + And I see that the file list contains a file named "welcome.txt" + And I see that the file list contains a file named "Folder" + And I see that the file list contains a file named "Not selected folder" + Scenario: rename a file with the details view open Given I am logged in And I open the details view for "welcome.txt" diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php index 55db746c7c1..cdf2e6acc6e 100644 --- a/tests/acceptance/features/bootstrap/FileListContext.php +++ b/tests/acceptance/features/bootstrap/FileListContext.php @@ -133,6 +133,48 @@ class FileListContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function fileListHeader($fileListAncestor) { + return Locator::forThe()->css("thead")-> + descendantOf($fileListAncestor)-> + describedAs("Header in file list"); + } + + /** + * @return Locator + */ + public static function selectedFilesActionsMenuButton($fileListAncestor) { + return Locator::forThe()->css(".actions-selected")-> + descendantOf(self::fileListHeader($fileListAncestor))-> + describedAs("Selected files actions menu button in file list"); + } + + /** + * @return Locator + */ + public static function selectedFilesActionsMenu() { + return Locator::forThe()->css(".filesSelectMenu")-> + describedAs("Selected files actions menu in file list"); + } + + /** + * @return Locator + */ + private static function selectedFilesActionsMenuItemFor($itemText) { + return Locator::forThe()->xpath("//a[normalize-space() = '$itemText']")-> + descendantOf(self::selectedFilesActionsMenu())-> + describedAs($itemText . " item in selected files actions menu in file list"); + } + + /** + * @return Locator + */ + public static function moveOrCopySelectedFilesMenuItem() { + return self::selectedFilesActionsMenuItemFor("Move or copy"); + } + + /** + * @return Locator + */ public static function rowForFile($fileListAncestor, $fileName) { return Locator::forThe()->xpath("//*[@id = 'fileList']//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName']/ancestor::tr")-> descendantOf($fileListAncestor)-> @@ -151,6 +193,26 @@ class FileListContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function selectionCheckboxForFile($fileListAncestor, $fileName) { + // Note that the element that the user interacts with is the label, not + // the checbox itself. + return Locator::forThe()->css(".selection label")-> + descendantOf(self::rowForFile($fileListAncestor, $fileName))-> + describedAs("Selection checkbox for file $fileName in file list"); + } + + /** + * @return Locator + */ + public static function selectionCheckboxInputForFile($fileListAncestor, $fileName) { + return Locator::forThe()->css(".selection input[type=checkbox]")-> + descendantOf(self::rowForFile($fileListAncestor, $fileName))-> + describedAs("Selection checkbox input for file $fileName in file list"); + } + + /** + * @return Locator + */ public static function favoriteMarkForFile($fileListAncestor, $fileName) { return Locator::forThe()->css(".favorite-mark")-> descendantOf(self::rowForFile($fileListAncestor, $fileName))-> @@ -304,6 +366,24 @@ class FileListContext implements Context, ActorAwareInterface { } /** + * @Given I select :fileName + */ + public function iSelect($fileName) { + $this->iSeeThatIsNotSelected($fileName); + + $this->actor->find(self::selectionCheckboxForFile($this->fileListAncestor, $fileName), 10)->click(); + } + + /** + * @Given I start the move or copy operation for the selected files + */ + public function iStartTheMoveOrCopyOperationForTheSelectedFiles() { + $this->actor->find(self::selectedFilesActionsMenuButton($this->fileListAncestor), 10)->click(); + + $this->actor->find(self::moveOrCopySelectedFilesMenuItem(), 2)->click(); + } + + /** * @Given I open the details view for :fileName */ public function iOpenTheDetailsViewFor($fileName) { @@ -446,6 +526,13 @@ class FileListContext implements Context, ActorAwareInterface { } /** + * @Then I see that :fileName is not selected + */ + public function iSeeThatIsNotSelected($fileName) { + PHPUnit_Framework_Assert::assertFalse($this->actor->find(self::selectionCheckboxInputForFile($this->fileListAncestor, $fileName), 10)->isChecked()); + } + + /** * @Then I see that :fileName is marked as favorite */ public function iSeeThatIsMarkedAsFavorite($fileName) { |