diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-07-05 14:54:26 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-07-05 14:54:26 +0200 |
commit | 6fa5c33af4a214e695942e05bb50f564e09d1f44 (patch) | |
tree | 65ec51d92894f0a5edfa13ce38da7efa0c7a843c | |
parent | f3c25e177f428d0438d73505915e4bf110c835b7 (diff) | |
download | nextcloud-server-6fa5c33af4a214e695942e05bb50f564e09d1f44.tar.gz nextcloud-server-6fa5c33af4a214e695942e05bb50f564e09d1f44.zip |
Add acceptance tests for sorting of favorite files
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | tests/acceptance/features/app-files.feature | 19 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FilesAppContext.php | 86 |
2 files changed, 105 insertions, 0 deletions
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature index 8d32508513a..c968ae53ce4 100644 --- a/tests/acceptance/features/app-files.feature +++ b/tests/acceptance/features/app-files.feature @@ -68,3 +68,22 @@ Feature: app-files And I see that the "Sharing" tab in the details view is eventually loaded When I open the input field for tags in the details view Then I see that the input field for tags in the details view is shown + + Scenario: marking a file as favorite causes the file list to be sorted again + Given I am logged in + And I create a new folder named "A name alphabetically lower than welcome.txt" + And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list + When I mark "welcome.txt" as favorite + Then I see that "welcome.txt" is marked as favorite + And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list + + Scenario: unmarking a file as favorite causes the file list to be sorted again + Given I am logged in + And I create a new folder named "A name alphabetically lower than welcome.txt" + And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list + And I mark "welcome.txt" as favorite + And I see that "welcome.txt" is marked as favorite + And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list + When I unmark "welcome.txt" as favorite + Then I see that "welcome.txt" is not marked as favorite + And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 52f69c66796..631eb60393d 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -216,6 +216,40 @@ class FilesAppContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function createMenuButton() { + return Locator::forThe()->css("#controls .button.new")-> + descendantOf(self::currentSectionMainView())-> + describedAs("Create menu button in Files app"); + } + + /** + * @return Locator + */ + public static function createNewFolderMenuItem() { + return self::createMenuItemFor("New folder"); + } + + /** + * @return Locator + */ + public static function createNewFolderMenuItemNameInput() { + return Locator::forThe()->css(".filenameform input")-> + descendantOf(self::createNewFolderMenuItem())-> + describedAs("Name input in create new folder menu item in Files app"); + } + + /** + * @return Locator + */ + private static function createMenuItemFor($newType) { + return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' newFileMenu ')]//span[normalize-space() = '$newType']/ancestor::li")-> + descendantOf(self::currentSectionMainView())-> + describedAs("Create $newType menu item in Files app"); + } + + /** + * @return Locator + */ public static function rowForFile($fileName) { return Locator::forThe()->xpath("//*[@id = 'fileList']//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName']/ancestor::tr")-> descendantOf(self::currentSectionMainView())-> @@ -225,6 +259,15 @@ class FilesAppContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function rowForFilePreceding($fileName1, $fileName2) { + return Locator::forThe()->xpath("//preceding-sibling::tr//span[contains(concat(' ', normalize-space(@class), ' '), ' nametext ') and normalize-space() = '$fileName1']/ancestor::tr")-> + descendantOf(self::rowForFile($fileName2))-> + describedAs("Row for file $fileName1 preceding $fileName2 in Files app"); + } + + /** + * @return Locator + */ public static function favoriteActionForFile($fileName) { return Locator::forThe()->css(".action-favorite")->descendantOf(self::rowForFile($fileName))-> describedAs("Favorite action for file $fileName in Files app"); @@ -233,6 +276,14 @@ class FilesAppContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function notFavoritedStateIconForFile($fileName) { + return Locator::forThe()->css(".icon-star")->descendantOf(self::favoriteActionForFile($fileName))-> + describedAs("Not favorited state icon for file $fileName in Files app"); + } + + /** + * @return Locator + */ public static function favoritedStateIconForFile($fileName) { return Locator::forThe()->css(".icon-starred")->descendantOf(self::favoriteActionForFile($fileName))-> describedAs("Favorited state icon for file $fileName in Files app"); @@ -294,6 +345,16 @@ class FilesAppContext implements Context, ActorAwareInterface { } /** + * @Given I create a new folder named :folderName + */ + public function iCreateANewFolderNamed($folderName) { + $this->actor->find(self::createMenuButton(), 10)->click(); + + $this->actor->find(self::createNewFolderMenuItem(), 2)->click(); + $this->actor->find(self::createNewFolderMenuItemNameInput(), 2)->setValue($folderName . "\r"); + } + + /** * @Given I open the :section section */ public function iOpenTheSection($section) { @@ -327,6 +388,17 @@ class FilesAppContext implements Context, ActorAwareInterface { * @Given I mark :fileName as favorite */ public function iMarkAsFavorite($fileName) { + $this->iSeeThatIsNotMarkedAsFavorite($fileName); + + $this->actor->find(self::favoriteActionForFile($fileName), 10)->click(); + } + + /** + * @Given I unmark :fileName as favorite + */ + public function iUnmarkAsFavorite($fileName) { + $this->iSeeThatIsMarkedAsFavorite($fileName); + $this->actor->find(self::favoriteActionForFile($fileName), 10)->click(); } @@ -414,6 +486,13 @@ class FilesAppContext implements Context, ActorAwareInterface { } /** + * @Then I see that :fileName1 precedes :fileName2 in the file list + */ + public function iSeeThatPrecedesInTheFileList($fileName1, $fileName2) { + PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFilePreceding($fileName1, $fileName2), 10)); + } + + /** * @Then I see that :fileName is marked as favorite */ public function iSeeThatIsMarkedAsFavorite($fileName) { @@ -421,6 +500,13 @@ class FilesAppContext implements Context, ActorAwareInterface { } /** + * @Then I see that :fileName is not marked as favorite + */ + public function iSeeThatIsNotMarkedAsFavorite($fileName) { + PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::notFavoritedStateIconForFile($fileName), 10)); + } + + /** * @Then I see that the input field for tags in the details view is shown */ public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() { |