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

Fix rendering of the sidebar in Files app #12577

Merged
merged 5 commits into from
Nov 22, 2018
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
10 changes: 0 additions & 10 deletions apps/files/js/detailsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,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')
};
Expand Down
26 changes: 25 additions & 1 deletion apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,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
*/
Expand Down
23 changes: 23 additions & 0 deletions tests/acceptance/features/app-comments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions tests/acceptance/features/app-files-tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
56 changes: 56 additions & 0 deletions tests/acceptance/features/app-files.feature
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -292,3 +329,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
28 changes: 28 additions & 0 deletions tests/acceptance/features/bootstrap/CommentsAppContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ public static function commentWithText($text) {
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$/
*/
Expand All @@ -70,11 +79,30 @@ public function iCreateANewCommentWithAsMessage($commentText) {
$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$/
*/
public function iSeeACommentWithAsMessage($commentText) {
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) {
}
}
}
61 changes: 61 additions & 0 deletions tests/acceptance/features/bootstrap/FilesAppContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,33 @@ public static function fileNameInDetailsView() {
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
*/
Expand Down Expand Up @@ -372,6 +399,24 @@ public function iWriteDownTheSharedLink() {
$this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyLinkButton(), 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
*/
Expand Down Expand Up @@ -500,6 +545,22 @@ public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) {
$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
*/
Expand Down