summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-01-11 02:47:11 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-01-11 02:47:11 +0100
commitf29c1cf13ae4f5dd38c7476c55ff5e23916bd6f4 (patch)
tree81c0292920f43204fbc1df1b20a141c0ccb16e33 /apps/files/tests
parent7a088cfcf56a841f16023a64a442620fd20c0c6e (diff)
downloadnextcloud-server-f29c1cf13ae4f5dd38c7476c55ff5e23916bd6f4.tar.gz
nextcloud-server-f29c1cf13ae4f5dd38c7476c55ff5e23916bd6f4.zip
Fix empty details view after renaming a file
"FileList._updateDetailsView" expects either a file name (as a string) or a file model (as an "OCA.File.FileInfoModel"), but when called through "updateInList" an "OC.Files.FileInfo" object was given instead. As the given attribute was not a model "_updateDetailsView" treated it as a file name and tried to get the model for that file, which failed and caused the details view to be emptied. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/filelistSpec.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index a03d2fa1cc7..08da15b8a88 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -674,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();