diff --git a/apps/files/js/detailsview.js b/apps/files/js/detailsview.js index aed1736693..7e2a5f0e8a 100644 --- a/apps/files/js/detailsview.js +++ b/apps/files/js/detailsview.js @@ -117,16 +117,6 @@ * Renders this details view */ render: function() { - // remove old instances - var $appSidebar = $('#app-sidebar'); - if ($appSidebar.length === 0) { - this.$el.insertAfter($('#app-content')); - } else { - if ($appSidebar[0] !== this.el) { - $appSidebar.replaceWith(this.$el) - } - } - var templateVars = { closeLabel: t('files', 'Close') }; diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 7d4dc76daf..93a695e969 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -568,11 +568,35 @@ } this._currentFileModel = model; + + this._replaceDetailsViewElementIfNeeded(); + this._detailsView.setFileInfo(model); - this._detailsView.render(); this._detailsView.$el.scrollTop(0); }, + /** + * Replaces the current details view element with the details view + * element of this file list. + * + * Each file list has its own DetailsView object, and each one has its + * own root element, but there can be just one details view/sidebar + * element in the document. This helper method replaces the current + * details view/sidebar element in the document with the element from + * the DetailsView object of this file list. + */ + _replaceDetailsViewElementIfNeeded: function() { + var $appSidebar = $('#app-sidebar'); + if ($appSidebar.length === 0) { + this._detailsView.$el.insertAfter($('#app-content')); + } else if ($appSidebar[0] !== this._detailsView.el) { + // "replaceWith()" can not be used here, as it removes the old + // element instead of just detaching it. + this._detailsView.$el.insertBefore($appSidebar); + $appSidebar.detach(); + } + }, + /** * Event handler for when the window size changed */ diff --git a/tests/acceptance/features/app-comments.feature b/tests/acceptance/features/app-comments.feature index a5bdb0aa74..1ee113d0aa 100644 --- a/tests/acceptance/features/app-comments.feature +++ b/tests/acceptance/features/app-comments.feature @@ -6,3 +6,26 @@ Feature: app-comments And I open the "Comments" tab in the details view When I create a new comment with "Hello world" as message Then I see a comment with "Hello world" as message + + Scenario: open the comments for a different file + Given I am logged in + And I create a new folder named "Folder" + And I open the details view for "welcome.txt" + And I open the "Comments" tab in the details view + And I create a new comment with "Hello world" as message + And I see a comment with "Hello world" as message + When I open the details view for "Folder" + # The "Comments" tab should already be opened + Then I see that there are no comments + + Scenario: write a comment in a file right after writing a comment in another file + Given I am logged in + And I create a new folder named "Folder" + And I open the details view for "Folder" + And I open the "Comments" tab in the details view + And I create a new comment with "Comment in Folder" as message + And I open the details view for "welcome.txt" + # The "Comments" tab should already be opened + When I create a new comment with "Comment in welcome.txt" as message + Then I see a comment with "Comment in welcome.txt" as message + And I see that there is no comment with "Comment in Folder" as message diff --git a/tests/acceptance/features/app-files-tags.feature b/tests/acceptance/features/app-files-tags.feature index 3da24b7e1c..d606c7a88a 100644 --- a/tests/acceptance/features/app-files-tags.feature +++ b/tests/acceptance/features/app-files-tags.feature @@ -8,6 +8,17 @@ Feature: app-files-tags 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: show the input field for tags in the details view after closing and opening the details view again + Given I am logged in + And I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + And I see that the details view is closed + And I open the details view for "welcome.txt" + And I see that the details view is open + 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: show the input field for tags in the details view after the sharing tab has loaded Given I am logged in And I open the details view for "welcome.txt" diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature index 74490180ad..89d622493c 100644 --- a/tests/acceptance/features/app-files.feature +++ b/tests/acceptance/features/app-files.feature @@ -1,5 +1,42 @@ Feature: app-files + Scenario: open and close the details view + Given I am logged in + When I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + Then I see that the details view is closed + + Scenario: open and close the details view twice + Given I am logged in + And I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + And I see that the details view is closed + When I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + Then I see that the details view is closed + + Scenario: open and close the details view again after coming back from a different section + Given I am logged in + And I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + And I see that the details view is closed + And I open the "Recent" section + And I see that the current section is "Recent" + And I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + And I see that the details view is closed + When I open the "All files" section + And I see that the current section is "All files" + And I open the details view for "welcome.txt" + And I see that the details view is open + And I close the details view + Then I see that the details view is closed + Scenario: viewing a favorite file in its folder shows the correct sidebar view Given I am logged in And I create a new folder named "other" @@ -262,3 +299,22 @@ Feature: app-files 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 + + Scenario: mark a file as favorite in the details view + Given I am logged in + And I open the details view for "welcome.txt" + And I see that the details view is open + When I mark the file as favorite in the details view + Then I see that "welcome.txt" is marked as favorite + And I see that the file is marked as favorite in the details view + + Scenario: unmark a file as favorite in the details view + Given I am logged in + And I open the details view for "welcome.txt" + And I see that the details view is open + And I mark the file as favorite in the details view + And I see that "welcome.txt" is marked as favorite + And I see that the file is marked as favorite in the details view + When I unmark the file as favorite in the details view + Then I see that "welcome.txt" is not marked as favorite + And I see that the file is not marked as favorite in the details view diff --git a/tests/acceptance/features/bootstrap/CommentsAppContext.php b/tests/acceptance/features/bootstrap/CommentsAppContext.php index 13d8af4e60..5d19412c30 100644 --- a/tests/acceptance/features/bootstrap/CommentsAppContext.php +++ b/tests/acceptance/features/bootstrap/CommentsAppContext.php @@ -62,6 +62,15 @@ class CommentsAppContext implements Context, ActorAwareInterface { describedAs("Comment with text \"$text\" in details view in Files app"); } + /** + * @return Locator + */ + public static function emptyContent() { + return Locator::forThe()->css(".emptycontent")-> + descendantOf(FilesAppContext::detailsView())-> + describedAs("Empty content in details view in Files app"); + } + /** * @When /^I create a new comment with "([^"]*)" as message$/ */ @@ -70,6 +79,14 @@ class CommentsAppContext implements Context, ActorAwareInterface { $this->actor->find(self::submitNewCommentButton())->click(); } + /** + * @Then /^I see that there are no comments$/ + */ + public function iSeeThatThereAreNoComments() { + PHPUnit_Framework_Assert::assertTrue( + $this->actor->find(self::emptyContent(), 10)->isVisible()); + } + /** * @Then /^I see a comment with "([^"]*)" as message$/ */ @@ -77,4 +94,15 @@ class CommentsAppContext implements Context, ActorAwareInterface { PHPUnit_Framework_Assert::assertTrue( $this->actor->find(self::commentWithText($commentText), 10)->isVisible()); } + + /** + * @Then /^I see that there is no comment with "([^"]*)" as message$/ + */ + public function iSeeThatThereIsNoCommentWithAsMessage($commentText) { + try { + PHPUnit_Framework_Assert::assertFalse( + $this->actor->find(self::commentWithText($commentText))->isVisible()); + } catch (NoSuchElementException $exception) { + } + } } diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index ab9fc8fe29..8758678494 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -86,6 +86,33 @@ class FilesAppContext implements Context, ActorAwareInterface { describedAs("File name in details view in Files app"); } + /** + * @return Locator + */ + public static function favoriteActionInFileDetailsInDetailsView() { + return Locator::forThe()->css(".action-favorite")-> + descendantOf(self::fileDetailsInDetailsView())-> + describedAs("Favorite action in file details in details view in Files app"); + } + + /** + * @return Locator + */ + public static function notFavoritedStateIconInFileDetailsInDetailsView() { + return Locator::forThe()->css(".icon-star")-> + descendantOf(self::favoriteActionInFileDetailsInDetailsView())-> + describedAs("Not favorited state icon in file details in details view in Files app"); + } + + /** + * @return Locator + */ + public static function favoritedStateIconInFileDetailsInDetailsView() { + return Locator::forThe()->css(".icon-starred")-> + descendantOf(self::favoriteActionInFileDetailsInDetailsView())-> + describedAs("Favorited state icon in file details in details view in Files app"); + } + /** * @return Locator */ @@ -316,6 +343,24 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyUrlMenuItem(), 2)->getWrappedElement()->getAttribute("data-clipboard-text"); } + /** + * @When I mark the file as favorite in the details view + */ + public function iMarkTheFileAsFavoriteInTheDetailsView() { + $this->iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView(); + + $this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click(); + } + + /** + * @When I unmark the file as favorite in the details view + */ + public function iUnmarkTheFileAsFavoriteInTheDetailsView() { + $this->iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView(); + + $this->actor->find(self::favoriteActionInFileDetailsInDetailsView(), 10)->click(); + } + /** * @When I check the tag :tag in the dropdown for tags in the details view */ @@ -400,6 +445,22 @@ class FilesAppContext implements Context, ActorAwareInterface { $this->actor->find(self::fileNameInDetailsView(), 10)->getText(), $fileName); } + /** + * @Then I see that the file is marked as favorite in the details view + */ + public function iSeeThatTheFileIsMarkedAsFavoriteInTheDetailsView() { + PHPUnit_Framework_Assert::assertNotNull( + $this->actor->find(self::favoritedStateIconInFileDetailsInDetailsView(), 10)); + } + + /** + * @Then I see that the file is not marked as favorite in the details view + */ + public function iSeeThatTheFileIsNotMarkedAsFavoriteInTheDetailsView() { + PHPUnit_Framework_Assert::assertNotNull( + $this->actor->find(self::notFavoritedStateIconInFileDetailsInDetailsView(), 10)); + } + /** * @Then I see that the input field for tags in the details view is shown */