aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-07-27 10:23:44 +0200
committerVincent Petry <vincent@nextcloud.com>2022-07-27 10:23:44 +0200
commit8be9b04981c4f0bdf0a2b8d424f55c797ad90a32 (patch)
treefb6783d017fc73e0f54435f464eda71ce0ebb169 /apps/files/tests
parent97462295587f4016066264edb6eed5d5e17903f3 (diff)
downloadnextcloud-server-8be9b04981c4f0bdf0a2b8d424f55c797ad90a32.tar.gz
nextcloud-server-8be9b04981c4f0bdf0a2b8d424f55c797ad90a32.zip
Remove legacy #dir element in files list
Removed legacy "#dir" input element in the DOM. Apps should use OCA.Files.App.currentFileList or OCA.Sharing.PublicApp.fileList and call getCurrentDirectory() to retrieve the current directory and changeDirectory() to change it. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/js/favoritesfilelistspec.js1
-rw-r--r--apps/files/tests/js/fileactionsSpec.js4
-rw-r--r--apps/files/tests/js/fileactionsmenuSpec.js4
-rw-r--r--apps/files/tests/js/filelistSpec.js30
4 files changed, 19 insertions, 20 deletions
diff --git a/apps/files/tests/js/favoritesfilelistspec.js b/apps/files/tests/js/favoritesfilelistspec.js
index 1049553c5bd..6cfc078cf26 100644
--- a/apps/files/tests/js/favoritesfilelistspec.js
+++ b/apps/files/tests/js/favoritesfilelistspec.js
@@ -30,7 +30,6 @@ describe('OCA.Files.FavoritesFileList tests', function() {
$('#testArea').append(
'<div id="app-content-container">' +
// init horrible parameters
- '<input type="hidden" id="dir" value="/"></input>' +
'<input type="hidden" id="permissions" value="31"></input>' +
// dummy controls
'<div class="files-controls">' +
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index 536688d291d..7ec9efc43d0 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -33,7 +33,6 @@ describe('OCA.Files.FileActions tests', function() {
clock = sinon.useFakeTimers();
// init horrible parameters
var $body = $('#testArea');
- $body.append('<input type="hidden" id="dir" value="/subdir"></input>');
$body.append('<input type="hidden" id="permissions" value="31"></input>');
$body.append('<table class="files-filestable list-container view-grid"><tbody class="files-fileList"></tbody></table>');
// dummy files table
@@ -66,13 +65,14 @@ describe('OCA.Files.FileActions tests', function() {
fileList = new OCA.Files.FileList($body, {
fileActions: fileActions
});
+ fileList.changeDirectory('/subdir', false, true);
});
afterEach(function() {
fileActions = null;
fileList.destroy();
fileList = undefined;
clock.restore();
- $('#dir, #permissions, .files-filestable').remove();
+ $('#permissions, .files-filestable').remove();
});
it('calling clear() clears file actions', function() {
fileActions.clear();
diff --git a/apps/files/tests/js/fileactionsmenuSpec.js b/apps/files/tests/js/fileactionsmenuSpec.js
index 4ede99dc333..a252e75c5e2 100644
--- a/apps/files/tests/js/fileactionsmenuSpec.js
+++ b/apps/files/tests/js/fileactionsmenuSpec.js
@@ -31,7 +31,6 @@ describe('OCA.Files.FileActionsMenu tests', function() {
beforeEach(function() {
// init horrible parameters
var $body = $('#testArea');
- $body.append('<input type="hidden" id="dir" value="/subdir"></input>');
$body.append('<input type="hidden" id="permissions" value="31"></input>');
// dummy files table
actionStub = sinon.stub();
@@ -39,6 +38,7 @@ describe('OCA.Files.FileActionsMenu tests', function() {
fileList = new OCA.Files.FileList($body, {
fileActions: fileActions
});
+ fileList.changeDirectory('/subdir', false, true);
fileActions.registerAction({
name: 'Testdropdown',
@@ -100,7 +100,7 @@ describe('OCA.Files.FileActionsMenu tests', function() {
fileList.destroy();
fileList = undefined;
menu.remove();
- $('#dir, #permissions, .files-filestable').remove();
+ $('#permissions, .files-filestable').remove();
});
describe('rendering', function() {
diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js
index 9b7c785ca44..e69a62c0c3e 100644
--- a/apps/files/tests/js/filelistSpec.js
+++ b/apps/files/tests/js/filelistSpec.js
@@ -104,7 +104,6 @@ describe('OCA.Files.FileList tests', function() {
$('#testArea').append(
'<div id="app-content-files">' +
// init horrible parameters
- '<input type="hidden" id="dir" value="/subdir"/>' +
'<input type="hidden" id="permissions" value="31"/>' +
// dummy controls
'<div class="files-controls">' +
@@ -186,6 +185,7 @@ describe('OCA.Files.FileList tests', function() {
fileList = new OCA.Files.FileList($('#app-content-files'), {
filesClient: filesClient,
config: filesConfig,
+ dir: '/subdir',
enableUpload: true,
multiSelectMenu: [{
name: 'copyMove',
@@ -218,7 +218,7 @@ describe('OCA.Files.FileList tests', function() {
});
describe('Getters', function() {
it('Returns the current directory', function() {
- $('#dir').val('/one/two/three');
+ fileList.changeDirectory('/one/two/three', false, true);
expect(fileList.getCurrentDirectory()).toEqual('/one/two/three');
});
it('Returns the directory permissions as int', function() {
@@ -553,7 +553,7 @@ describe('OCA.Files.FileList tests', function() {
$summary = $('.files-filestable .summary');
expect($summary.hasClass('hidden')).toEqual(true);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
- expect($('.emptycontent').hasClass('hidden')).toEqual(false);
+ expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
expect(fileList.isEmpty).toEqual(true);
});
});
@@ -612,7 +612,7 @@ describe('OCA.Files.FileList tests', function() {
expect($summary.find('.filesize').text()).toEqual('57 KB');
expect(fileList.isEmpty).toEqual(false);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
- expect($('.emptycontent').hasClass('hidden')).toEqual(true);
+ expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);
expect(notificationStub.notCalled).toEqual(true);
}).then(done, done);
@@ -682,7 +682,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.isEmpty).toEqual(true);
expect(fileList.files.length).toEqual(0);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
- expect($('.emptycontent').hasClass('hidden')).toEqual(false);
+ expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
}).then(done, done);
});
it('bring back deleted item when delete call failed', function(done) {
@@ -1143,22 +1143,22 @@ describe('OCA.Files.FileList tests', function() {
it('shows headers, summary and hide empty content message after setting files', function(){
fileList.setFiles(testFiles);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(false);
- expect($('.emptycontent').hasClass('hidden')).toEqual(true);
+ expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(true);
expect(fileList.$el.find('.summary').hasClass('hidden')).toEqual(false);
});
it('hides headers, summary and show empty content message after setting empty file list', function(){
fileList.setFiles([]);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
- expect($('.emptycontent').hasClass('hidden')).toEqual(false);
- expect($('.emptycontent .uploadmessage').hasClass('hidden')).toEqual(false);
+ expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
+ expect($('.emptyfilelist.emptycontent .uploadmessage').hasClass('hidden')).toEqual(false);
expect(fileList.$el.find('.summary').hasClass('hidden')).toEqual(true);
});
it('hides headers, upload message, and summary when list is empty and user has no creation permission', function(){
$('#permissions').val(0);
fileList.setFiles([]);
expect($('.files-filestable thead th').hasClass('hidden')).toEqual(true);
- expect($('.emptycontent').hasClass('hidden')).toEqual(false);
- expect($('.emptycontent .uploadmessage').hasClass('hidden')).toEqual(true);
+ expect($('.emptyfilelist.emptycontent').hasClass('hidden')).toEqual(false);
+ expect($('.emptyfilelist.emptycontent .uploadmessage').hasClass('hidden')).toEqual(true);
expect(fileList.$el.find('.summary').hasClass('hidden')).toEqual(true);
});
it('calling findFileEl() can find existing file element', function() {
@@ -1170,7 +1170,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.findFileEl('unexist.dat').length).toEqual(0);
});
it('only add file if in same current directory', function() {
- $('#dir').val('/current dir');
+ fileList.changeDirectory('/current dir', false, true);
var fileData = {
type: 'file',
name: 'testFile.txt',
@@ -1313,7 +1313,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.files).toEqual([]);
fileList.setFiles([]);
var $summary = $('.files-filestable .summary');
- var $emptycontent = fileList.$el.find(".emptycontent");
+ var $emptycontent = fileList.$el.find(".emptyfilelist.emptycontent");
var $nofilterresults = fileList.$el.find(".nofilterresults");
expect($emptycontent.length).toEqual(1);
expect($nofilterresults.length).toEqual(1);
@@ -1343,7 +1343,7 @@ describe('OCA.Files.FileList tests', function() {
expect(fileList.files).toEqual([]);
fileList.showMask();
fileList.setFiles(testFiles);
- var $emptycontent = fileList.$el.find(".emptycontent");
+ var $emptycontent = fileList.$el.find(".emptyfilelist.emptycontent");
var $nofilterresults = fileList.$el.find(".nofilterresults");
expect($emptycontent.length).toEqual(1);
expect($nofilterresults.length).toEqual(1);
@@ -1942,7 +1942,7 @@ describe('OCA.Files.FileList tests', function() {
.toEqual(OC.getRootPath() + '/remote.php/webdav/subdir/some%20file.txt');
expect(fileList.getDownloadUrl('some file.txt', '/anotherpath/abc'))
.toEqual(OC.getRootPath() + '/remote.php/webdav/anotherpath/abc/some%20file.txt');
- $('#dir').val('/');
+ fileList.changeDirectory('/', false, true);
expect(fileList.getDownloadUrl('some file.txt'))
.toEqual(OC.getRootPath() + '/remote.php/webdav/some%20file.txt');
});
@@ -2346,7 +2346,7 @@ describe('OCA.Files.FileList tests', function() {
redirectStub.restore();
});
it('Downloads root folder when all selected in root folder', function() {
- $('#dir').val('/');
+ fileList.changeDirectory('/', false, true);
$('.select-all').click();
$('.selectedActions .filesSelectMenu .download').click();
expect(redirectStub.calledOnce).toEqual(true);