summaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2014-05-21 06:27:07 -0400
committerBjörn Schießle <schiessle@owncloud.com>2014-05-21 06:27:07 -0400
commit88d26aac7bded0267a7af4ba26a7534a73851e55 (patch)
tree6b92e314b42d8082206e1ecfd995b7adace0eace /apps/files/tests
parent319942bccb0f08abd694219b1c7bcf1e71d589c4 (diff)
parent5a0281add84b0754404c9fa617c4f527fcef04dc (diff)
downloadnextcloud-server-88d26aac7bded0267a7af4ba26a7534a73851e55.tar.gz
nextcloud-server-88d26aac7bded0267a7af4ba26a7534a73851e55.zip
Merge pull request #8612 from owncloud/share-updateshareiconsafterrename
[master] Fixed issues with renaming
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/filelistSpec.js65
1 files changed, 52 insertions, 13 deletions
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index bfc983c7483..a3dc5b255a1 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -468,6 +468,22 @@ describe('OCA.Files.FileList tests', function() {
});
});
describe('Renaming files', function() {
+ function doCancelRename() {
+ var $input;
+ for (var i = 0; i < testFiles.length; i++) {
+ fileList.add(testFiles[i]);
+ }
+
+ // trigger rename prompt
+ fileList.rename('One.txt');
+ $input = fileList.$fileList.find('input.filename');
+ // keep same name
+ $input.val('One.txt');
+ // trigger submit because triggering blur doesn't work in all browsers
+ $input.closest('form').trigger('submit');
+
+ expect(fakeServer.requests.length).toEqual(0);
+ }
function doRename() {
var $input, request;
@@ -486,12 +502,6 @@ describe('OCA.Files.FileList tests', function() {
request = fakeServer.requests[0];
expect(request.url.substr(0, request.url.indexOf('?'))).toEqual(OC.webroot + '/index.php/apps/files/ajax/rename.php');
expect(OC.parseQueryString(request.url)).toEqual({'dir': '/subdir', newname: 'Tu_after_three.txt', file: 'One.txt'});
-
- // element is renamed before the request finishes
- expect(fileList.findFileEl('One.txt').length).toEqual(0);
- expect(fileList.findFileEl('Tu_after_three.txt').length).toEqual(1);
- // input is gone
- expect(fileList.$fileList.find('input.filename').length).toEqual(0);
}
it('Inserts renamed file entry at correct position if rename ajax call suceeded', function() {
doRename();
@@ -542,22 +552,51 @@ describe('OCA.Files.FileList tests', function() {
$tr = fileList.findFileEl('Tu_after_three.txt');
expect($tr.find('a.name').attr('href')).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=Tu_after_three.txt');
});
- // FIXME: fix this in the source code!
- xit('Correctly updates file link after rename when path has same name', function() {
- var $tr;
- // evil case: because of buggy code
- $('#dir').val('/One.txt/subdir');
+ it('Triggers "fileActionsReady" event after rename', function() {
+ var handler = sinon.stub();
+ fileList.$fileList.on('fileActionsReady', handler);
doRename();
-
+ expect(handler.notCalled).toEqual(true);
fakeServer.requests[0].respond(200, {'Content-Type': 'application/json'}, JSON.stringify({
status: 'success',
data: {
name: 'Tu_after_three.txt'
}
}));
+ expect(handler.calledOnce).toEqual(true);
+ expect(fileList.$fileList.find('.test').length).toEqual(0);
+ });
+ it('Leaves the summary alone when reinserting renamed element', function() {
+ var $summary = $('#filestable .summary');
+ doRename();
+ fakeServer.requests[0].respond(200, {'Content-Type': 'application/json'}, JSON.stringify({
+ status: 'success',
+ data: {
+ name: 'Tu_after_three.txt'
+ }
+ }));
+ expect($summary.find('.info').text()).toEqual('1 folder and 3 files');
+ });
+ it('Leaves the summary alone when cancel renaming', function() {
+ var $summary = $('#filestable .summary');
+ doCancelRename();
+ expect($summary.find('.info').text()).toEqual('1 folder and 3 files');
+ });
+ it('Hides actions while rename in progress', function() {
+ var $tr;
+ doRename();
+ // element is renamed before the request finishes
$tr = fileList.findFileEl('Tu_after_three.txt');
- expect($tr.find('a.name').attr('href')).toEqual(OC.webroot + '/index.php/apps/files/ajax/download.php?dir=%2Fsubdir&files=One.txt');
+ expect($tr.length).toEqual(1);
+ expect(fileList.findFileEl('One.txt').length).toEqual(0);
+ // file actions are hidden
+ expect($tr.find('.action').hasClass('hidden')).toEqual(true);
+ expect($tr.find('.fileactions').hasClass('hidden')).toEqual(true);
+
+ // input and form are gone
+ expect(fileList.$fileList.find('input.filename').length).toEqual(0);
+ expect(fileList.$fileList.find('form').length).toEqual(0);
});
});
describe('Moving files', function() {