aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <github@jus.li>2018-01-11 12:27:07 +0100
committerGitHub <noreply@github.com>2018-01-11 12:27:07 +0100
commit7de3cced7a4d137ee0eeaecf7d5a1010c5589369 (patch)
tree6261459b97de43c5bda58ad91098e45543dbaec5
parent7e48344eb145f79602ace8d0210d49a57de8ed00 (diff)
parentdab4a70bcf75878cf1542d010f5894e5c7e272ea (diff)
downloadnextcloud-server-7de3cced7a4d137ee0eeaecf7d5a1010c5589369.tar.gz
nextcloud-server-7de3cced7a4d137ee0eeaecf7d5a1010c5589369.zip
Merge pull request #7783 from nextcloud/fix-empty-details-view-after-renaming-a-file
Fix empty details view after renaming a file
-rw-r--r--apps/files/js/filelist.js2
-rw-r--r--apps/files/tests/js/filelistSpec.js49
-rw-r--r--tests/acceptance/features/app-files.feature7
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php50
4 files changed, 94 insertions, 14 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 7a4ea492752..e50b402dea8 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -2266,7 +2266,7 @@
function updateInList(fileInfo) {
self.updateRow(tr, fileInfo);
- self._updateDetailsView(fileInfo, false);
+ self._updateDetailsView(fileInfo.name, false);
}
// TODO: too many nested blocks, move parts into functions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index fc5a6c18f95..08da15b8a88 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -612,6 +612,12 @@ describe('OCA.Files.FileList tests', function() {
beforeEach(function() {
deferredRename = $.Deferred();
renameStub = sinon.stub(filesClient, 'move').returns(deferredRename.promise());
+
+ for (var i = 0; i < testFiles.length; i++) {
+ var file = testFiles[i];
+ file.path = '/some/subdir';
+ fileList.add(file, {silent: true});
+ }
});
afterEach(function() {
renameStub.restore();
@@ -619,9 +625,6 @@ describe('OCA.Files.FileList tests', function() {
function doCancelRename() {
var $input;
- for (var i = 0; i < testFiles.length; i++) {
- fileList.add(testFiles[i]);
- }
// trigger rename prompt
fileList.rename('One.txt');
@@ -636,12 +639,6 @@ describe('OCA.Files.FileList tests', function() {
function doRename() {
var $input;
- for (var i = 0; i < testFiles.length; i++) {
- var file = testFiles[i];
- file.path = '/some/subdir';
- fileList.add(file, {silent: true});
- }
-
// trigger rename prompt
fileList.rename('One.txt');
$input = fileList.$fileList.find('input.filename');
@@ -677,6 +674,36 @@ describe('OCA.Files.FileList tests', function() {
expect(notificationStub.calledOnce).toEqual(true);
});
+ it('Shows renamed file details if rename ajax call suceeded', function() {
+ fileList.showDetailsView('One.txt');
+
+ expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
+ expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
+ expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt');
+
+ doRename();
+
+ deferredRename.resolve(201);
+
+ expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
+ expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
+ expect(fileList._detailsView.getFileInfo().get('name')).toEqual('Tu_after_three.txt');
+ });
+ it('Shows again file details if rename ajax call failed', function() {
+ fileList.showDetailsView('One.txt');
+
+ expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
+ expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
+ expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt');
+
+ doRename();
+
+ deferredRename.reject(403);
+
+ expect($('#app-sidebar').hasClass('disappear')).toEqual(false);
+ expect(fileList._detailsView.getFileInfo().get('id')).toEqual(1);
+ expect(fileList._detailsView.getFileInfo().get('name')).toEqual('One.txt');
+ });
it('Correctly updates file link after rename', function() {
var $tr;
doRename();
@@ -731,10 +758,6 @@ describe('OCA.Files.FileList tests', function() {
it('Validates the file name', function() {
var $input, $tr;
- for (var i = 0; i < testFiles.length; i++) {
- fileList.add(testFiles[i], {silent: true});
- }
-
$tr = fileList.findFileEl('One.txt');
expect($tr.find('a.name').css('display')).not.toEqual('none');
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature
index 2cb43611b9a..ef3d07ae499 100644
--- a/tests/acceptance/features/app-files.feature
+++ b/tests/acceptance/features/app-files.feature
@@ -23,6 +23,13 @@ Feature: app-files
When I open the details view for "welcome.txt"
Then I see that the details view for "All files" section is open
+ Scenario: rename a file with the details view open
+ Given I am logged in
+ And I open the details view for "welcome.txt"
+ When I rename "welcome.txt" to "farewell.txt"
+ Then I see that the file list contains a file named "farewell.txt"
+ And I see that the file name shown in the details view is "farewell.txt"
+
Scenario: open the menu in a public shared link
Given I act as John
And I am logged in
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 4951dc43f1d..117f3b54fb8 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -89,6 +89,15 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function fileNameInCurrentSectionDetailsView() {
+ return Locator::forThe()->css(".fileName")->
+ descendantOf(self::currentSectionDetailsView())->
+ describedAs("File name in current section details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetailsText) {
return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
descendantOf(self::fileDetailsInCurrentSectionDetailsView())->
@@ -319,6 +328,14 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function renameInputForFile($fileName) {
+ return Locator::forThe()->css("input.filename")->descendantOf(self::rowForFile($fileName))->
+ describedAs("Rename input for file $fileName in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function shareActionForFile($fileName) {
return Locator::forThe()->css(".action-share")->descendantOf(self::rowForFile($fileName))->
describedAs("Share action for file $fileName in Files app");
@@ -350,6 +367,13 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function renameMenuItem() {
+ return self::fileActionsMenuItemFor("Rename");
+ }
+
+ /**
+ * @return Locator
+ */
public static function addToFavoritesMenuItem() {
return self::fileActionsMenuItemFor("Add to favorites");
}
@@ -418,6 +442,17 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Given I rename :fileName1 to :fileName2
+ */
+ public function iRenameTo($fileName1, $fileName2) {
+ $this->actor->find(self::fileActionsMenuButtonForFile($fileName1), 10)->click();
+
+ $this->actor->find(self::renameMenuItem(), 2)->click();
+
+ $this->actor->find(self::renameInputForFile($fileName1), 10)->setValue($fileName2 . "\r");
+ }
+
+ /**
* @Given I mark :fileName as favorite
*/
public function iMarkAsFavorite($fileName) {
@@ -543,6 +578,13 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that the file list contains a file named :fileName
+ */
+ public function iSeeThatTheFileListContainsAFileNamed($fileName) {
+ PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::rowForFile($fileName), 10));
+ }
+
+ /**
* @Then I see that :fileName1 precedes :fileName2 in the file list
*/
public function iSeeThatPrecedesInTheFileList($fileName1, $fileName2) {
@@ -564,6 +606,14 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Then I see that the file name shown in the details view is :fileName
+ */
+ public function iSeeThatTheFileNameShownInTheDetailsViewIs($fileName) {
+ PHPUnit_Framework_Assert::assertEquals(
+ $this->actor->find(self::fileNameInCurrentSectionDetailsView(), 10)->getText(), $fileName);
+ }
+
+ /**
* @Then I see that the input field for tags in the details view is shown
*/
public function iSeeThatTheInputFieldForTagsInTheDetailsViewIsShown() {