2014-05-09 00:06:30 +04:00
|
|
|
/**
|
2018-09-26 20:20:53 +03:00
|
|
|
* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
2021-03-31 13:15:40 +03:00
|
|
|
* @author Abijeet <abijeetpatro@gmail.com>
|
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
* @author Jan C. Borchardt <hey@jancborchardt.net>
|
|
|
|
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
|
|
|
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
* @author Vincent Petry <vincent@nextcloud.com>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2018-09-26 20:20:53 +03:00
|
|
|
*
|
2021-03-31 13:15:40 +03:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2018-09-26 20:20:53 +03:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2021-03-31 13:15:40 +03:00
|
|
|
* GNU Affero General Public License for more details.
|
2018-09-26 20:20:53 +03:00
|
|
|
*
|
2021-03-31 13:15:40 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-09-26 20:20:53 +03:00
|
|
|
*
|
|
|
|
*/
|
2014-05-09 00:06:30 +04:00
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('OCA.Trashbin.FileList tests', function () {
|
|
|
|
var testFiles, alertStub, notificationStub, fileList, client;
|
2014-05-09 00:06:30 +04:00
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
beforeEach(function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
alertStub = sinon.stub(OC.dialogs, 'alert');
|
|
|
|
notificationStub = sinon.stub(OC.Notification, 'show');
|
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
client = new OC.Files.Client({
|
|
|
|
host: 'localhost',
|
|
|
|
port: 80,
|
|
|
|
root: '/remote.php/dav/trashbin/user',
|
|
|
|
useHTTPS: OC.getProtocol() === 'https'
|
|
|
|
});
|
|
|
|
|
2014-05-09 00:06:30 +04:00
|
|
|
// init parameters and test table elements
|
|
|
|
$('#testArea').append(
|
|
|
|
'<div id="app-content-trashbin">' +
|
2014-05-12 21:54:20 +04:00
|
|
|
// init horrible parameters
|
2014-05-09 00:06:30 +04:00
|
|
|
'<input type="hidden" id="dir" value="/"></input>' +
|
2014-05-12 21:54:20 +04:00
|
|
|
// set this but it shouldn't be used (could be the one from the
|
|
|
|
// files app)
|
2014-05-09 00:06:30 +04:00
|
|
|
'<input type="hidden" id="permissions" value="31"></input>' +
|
|
|
|
// dummy controls
|
|
|
|
'<div id="controls">' +
|
|
|
|
' <div class="actions creatable"></div>' +
|
|
|
|
' <div class="notCreatable"></div>' +
|
|
|
|
'</div>' +
|
|
|
|
// dummy table
|
|
|
|
// TODO: at some point this will be rendered by the fileList class itself!
|
2018-10-03 22:42:24 +03:00
|
|
|
'<table id="filestable" class="list-container view-grid">' +
|
2014-05-09 00:06:30 +04:00
|
|
|
'<thead><tr><th id="headerName" class="hidden">' +
|
2014-05-12 21:54:20 +04:00
|
|
|
'<input type="checkbox" id="select_all_trash" class="select-all">' +
|
2014-05-09 00:06:30 +04:00
|
|
|
'<span class="name">Name</span>' +
|
|
|
|
'<span class="selectedActions hidden">' +
|
2018-06-06 21:00:56 +03:00
|
|
|
'<a href="" class="actions-selected"><span class="icon icon-more"></span><span>Actions</span>' +
|
|
|
|
'</span>' +
|
2014-05-09 00:06:30 +04:00
|
|
|
'</th></tr></thead>' +
|
2014-05-12 21:54:20 +04:00
|
|
|
'<tbody id="fileList"></tbody>' +
|
2014-05-09 00:06:30 +04:00
|
|
|
'<tfoot></tfoot>' +
|
|
|
|
'</table>' +
|
|
|
|
'<div id="emptycontent">Empty content message</div>' +
|
|
|
|
'</div>'
|
|
|
|
);
|
|
|
|
|
|
|
|
testFiles = [{
|
|
|
|
id: 1,
|
|
|
|
type: 'file',
|
2018-09-26 20:20:53 +03:00
|
|
|
name: 'One.txt.d11111',
|
|
|
|
displayName: 'One.txt',
|
2014-05-09 00:06:30 +04:00
|
|
|
mtime: 11111000,
|
|
|
|
mimetype: 'text/plain',
|
|
|
|
etag: 'abc'
|
|
|
|
}, {
|
|
|
|
id: 2,
|
|
|
|
type: 'file',
|
2018-09-26 20:20:53 +03:00
|
|
|
name: 'Two.jpg.d22222',
|
|
|
|
displayName: 'Two.jpg',
|
2014-05-09 00:06:30 +04:00
|
|
|
mtime: 22222000,
|
|
|
|
mimetype: 'image/jpeg',
|
|
|
|
etag: 'def',
|
|
|
|
}, {
|
|
|
|
id: 3,
|
|
|
|
type: 'file',
|
2018-09-26 20:20:53 +03:00
|
|
|
name: 'Three.pdf.d33333',
|
|
|
|
displayName: 'Three.pdf',
|
2014-05-09 00:06:30 +04:00
|
|
|
mtime: 33333000,
|
|
|
|
mimetype: 'application/pdf',
|
|
|
|
etag: '123',
|
|
|
|
}, {
|
|
|
|
id: 4,
|
|
|
|
type: 'dir',
|
|
|
|
mtime: 99999000,
|
2018-09-26 20:20:53 +03:00
|
|
|
name: 'somedir.d99999',
|
|
|
|
displayName: 'somedir',
|
2014-05-09 00:06:30 +04:00
|
|
|
mimetype: 'httpd/unix-directory',
|
|
|
|
etag: '456'
|
|
|
|
}];
|
|
|
|
|
2014-05-20 18:01:34 +04:00
|
|
|
// register file actions like the trashbin App does
|
|
|
|
var fileActions = OCA.Trashbin.App._createFileActions(fileList);
|
|
|
|
fileList = new OCA.Trashbin.FileList(
|
|
|
|
$('#app-content-trashbin'), {
|
2018-06-06 21:00:56 +03:00
|
|
|
fileActions: fileActions,
|
|
|
|
multiSelectMenu: [{
|
2018-09-26 20:20:53 +03:00
|
|
|
name: 'restore',
|
|
|
|
displayName: t('files', 'Restore'),
|
|
|
|
iconClass: 'icon-history',
|
|
|
|
},
|
2018-06-06 21:00:56 +03:00
|
|
|
{
|
|
|
|
name: 'delete',
|
|
|
|
displayName: t('files', 'Delete'),
|
|
|
|
iconClass: 'icon-delete',
|
|
|
|
}
|
2018-09-26 20:20:53 +03:00
|
|
|
],
|
|
|
|
client: client
|
2014-05-20 18:01:34 +04:00
|
|
|
}
|
|
|
|
);
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
afterEach(function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
testFiles = undefined;
|
2014-06-27 15:36:18 +04:00
|
|
|
fileList.destroy();
|
2014-05-09 00:06:30 +04:00
|
|
|
fileList = undefined;
|
|
|
|
|
|
|
|
$('#dir').remove();
|
|
|
|
notificationStub.restore();
|
|
|
|
alertStub.restore();
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Initialization', function () {
|
|
|
|
it('Sorts by mtime by default', function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
expect(fileList._sort).toEqual('mtime');
|
2020-10-07 18:18:27 +03:00
|
|
|
expect(fileList._sortDirection).toEqual('asc');
|
2014-05-12 21:54:20 +04:00
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
it('Always returns read and delete permission', function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
expect(fileList.getDirectoryPermissions()).toEqual(OC.PERMISSION_READ | OC.PERMISSION_DELETE);
|
|
|
|
});
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Breadcrumbs', function () {
|
|
|
|
beforeEach(function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
var data = {
|
|
|
|
status: 'success',
|
|
|
|
data: {
|
|
|
|
files: testFiles,
|
|
|
|
permissions: 1
|
|
|
|
}
|
|
|
|
};
|
|
|
|
fakeServer.respondWith(/\/index\.php\/apps\/files_trashbin\/ajax\/list.php\?dir=%2Fsubdir/, [
|
2018-09-26 20:20:53 +03:00
|
|
|
200, {
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
},
|
|
|
|
JSON.stringify(data)
|
2014-05-12 21:54:20 +04:00
|
|
|
]);
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
it('links the breadcrumb to the trashbin view', function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
fileList.changeDirectory('/subdir', false, true);
|
|
|
|
fakeServer.respond();
|
|
|
|
var $crumbs = fileList.$el.find('#controls .crumb');
|
2017-11-08 20:11:33 +03:00
|
|
|
expect($crumbs.length).toEqual(3);
|
|
|
|
expect($crumbs.eq(1).find('a').text()).toEqual('Home');
|
2014-05-12 21:54:20 +04:00
|
|
|
expect($crumbs.eq(1).find('a').attr('href'))
|
2018-10-09 08:44:26 +03:00
|
|
|
.toEqual(OC.getRootPath() + '/index.php/apps/files?view=trashbin&dir=/');
|
2017-11-08 20:11:33 +03:00
|
|
|
expect($crumbs.eq(2).find('a').text()).toEqual('subdir');
|
|
|
|
expect($crumbs.eq(2).find('a').attr('href'))
|
2018-10-09 08:44:26 +03:00
|
|
|
.toEqual(OC.getRootPath() + '/index.php/apps/files?view=trashbin&dir=/subdir');
|
2014-05-12 21:54:20 +04:00
|
|
|
});
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Rendering rows', function () {
|
|
|
|
it('renders rows with the correct data when in root', function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
// dir listing is false when in root
|
|
|
|
$('#dir').val('/');
|
|
|
|
fileList.setFiles(testFiles);
|
|
|
|
var $rows = fileList.$el.find('tbody tr');
|
|
|
|
var $tr = $rows.eq(0);
|
|
|
|
expect($rows.length).toEqual(4);
|
|
|
|
expect($tr.attr('data-id')).toEqual('1');
|
|
|
|
expect($tr.attr('data-type')).toEqual('file');
|
|
|
|
expect($tr.attr('data-file')).toEqual('One.txt.d11111');
|
|
|
|
expect($tr.attr('data-size')).not.toBeDefined();
|
|
|
|
expect($tr.attr('data-etag')).toEqual('abc');
|
|
|
|
expect($tr.attr('data-permissions')).toEqual('9'); // read and delete
|
|
|
|
expect($tr.attr('data-mime')).toEqual('text/plain');
|
|
|
|
expect($tr.attr('data-mtime')).toEqual('11111000');
|
|
|
|
expect($tr.find('a.name').attr('href')).toEqual('#');
|
|
|
|
|
|
|
|
expect($tr.find('.nametext').text().trim()).toEqual('One.txt');
|
|
|
|
|
|
|
|
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
it('renders rows with the correct data when in root after calling setFiles with the same data set', function () {
|
2016-06-23 12:50:59 +03:00
|
|
|
// dir listing is false when in root
|
|
|
|
$('#dir').val('/');
|
|
|
|
fileList.setFiles(testFiles);
|
|
|
|
fileList.setFiles(fileList.files);
|
|
|
|
var $rows = fileList.$el.find('tbody tr');
|
|
|
|
var $tr = $rows.eq(0);
|
|
|
|
expect($rows.length).toEqual(4);
|
|
|
|
expect($tr.attr('data-id')).toEqual('1');
|
|
|
|
expect($tr.attr('data-type')).toEqual('file');
|
|
|
|
expect($tr.attr('data-file')).toEqual('One.txt.d11111');
|
|
|
|
expect($tr.attr('data-size')).not.toBeDefined();
|
|
|
|
expect($tr.attr('data-etag')).toEqual('abc');
|
|
|
|
expect($tr.attr('data-permissions')).toEqual('9'); // read and delete
|
|
|
|
expect($tr.attr('data-mime')).toEqual('text/plain');
|
|
|
|
expect($tr.attr('data-mtime')).toEqual('11111000');
|
|
|
|
expect($tr.find('a.name').attr('href')).toEqual('#');
|
|
|
|
|
|
|
|
expect($tr.find('.nametext').text().trim()).toEqual('One.txt');
|
|
|
|
|
|
|
|
expect(fileList.findFileEl('One.txt.d11111')[0]).toEqual($tr[0]);
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
it('renders rows with the correct data when in subdirectory', function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
// dir listing is true when in a subdir
|
|
|
|
$('#dir').val('/subdir');
|
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
fileList.setFiles(testFiles.map(function (file) {
|
|
|
|
file.name = file.displayName;
|
|
|
|
return file;
|
|
|
|
}));
|
2014-05-12 21:54:20 +04:00
|
|
|
var $rows = fileList.$el.find('tbody tr');
|
|
|
|
var $tr = $rows.eq(0);
|
|
|
|
expect($rows.length).toEqual(4);
|
|
|
|
expect($tr.attr('data-id')).toEqual('1');
|
|
|
|
expect($tr.attr('data-type')).toEqual('file');
|
|
|
|
expect($tr.attr('data-file')).toEqual('One.txt');
|
|
|
|
expect($tr.attr('data-size')).not.toBeDefined();
|
|
|
|
expect($tr.attr('data-etag')).toEqual('abc');
|
|
|
|
expect($tr.attr('data-permissions')).toEqual('9'); // read and delete
|
|
|
|
expect($tr.attr('data-mime')).toEqual('text/plain');
|
|
|
|
expect($tr.attr('data-mtime')).toEqual('11111000');
|
|
|
|
expect($tr.find('a.name').attr('href')).toEqual('#');
|
|
|
|
|
|
|
|
expect($tr.find('.nametext').text().trim()).toEqual('One.txt');
|
|
|
|
|
|
|
|
expect(fileList.findFileEl('One.txt')[0]).toEqual($tr[0]);
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
it('does not render a size column', function () {
|
2014-05-12 21:54:20 +04:00
|
|
|
expect(fileList.$el.find('tbody tr .filesize').length).toEqual(0);
|
|
|
|
});
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('File actions', function () {
|
|
|
|
describe('Deleting single files', function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
// TODO: checks ajax call
|
|
|
|
// TODO: checks spinner
|
|
|
|
// TODO: remove item after delete
|
|
|
|
// TODO: bring back item if delete failed
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Restoring single files', function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
// TODO: checks ajax call
|
|
|
|
// TODO: checks spinner
|
|
|
|
// TODO: remove item after restore
|
|
|
|
// TODO: bring back item if restore failed
|
|
|
|
});
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('file previews', function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
// TODO: check that preview URL is going through files_trashbin
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('loading file list', function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
// TODO: check that ajax URL is going through files_trashbin
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('breadcrumbs', function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
// TODO: test label + URL
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('elementToFile', function () {
|
2015-08-25 12:29:35 +03:00
|
|
|
var $tr;
|
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
beforeEach(function () {
|
2015-08-25 12:29:35 +03:00
|
|
|
fileList.setFiles(testFiles);
|
|
|
|
$tr = fileList.findFileEl('One.txt.d11111');
|
|
|
|
});
|
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
it('converts data attributes to file info structure', function () {
|
2015-08-25 12:29:35 +03:00
|
|
|
var fileInfo = fileList.elementToFile($tr);
|
|
|
|
expect(fileInfo.id).toEqual(1);
|
|
|
|
expect(fileInfo.name).toEqual('One.txt.d11111');
|
|
|
|
expect(fileInfo.displayName).toEqual('One.txt');
|
|
|
|
expect(fileInfo.mtime).toEqual(11111000);
|
|
|
|
expect(fileInfo.etag).toEqual('abc');
|
|
|
|
expect(fileInfo.permissions).toEqual(OC.PERMISSION_READ | OC.PERMISSION_DELETE);
|
|
|
|
expect(fileInfo.mimetype).toEqual('text/plain');
|
|
|
|
expect(fileInfo.type).toEqual('file');
|
|
|
|
});
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Global Actions', function () {
|
|
|
|
beforeEach(function () {
|
2014-05-09 00:06:30 +04:00
|
|
|
fileList.setFiles(testFiles);
|
|
|
|
fileList.findFileEl('One.txt.d11111').find('input:checkbox').click();
|
|
|
|
fileList.findFileEl('Three.pdf.d33333').find('input:checkbox').click();
|
|
|
|
fileList.findFileEl('somedir.d99999').find('input:checkbox').click();
|
2018-06-06 21:00:56 +03:00
|
|
|
fileList.$el.find('.actions-selected').click();
|
|
|
|
});
|
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
afterEach(function () {
|
2018-06-06 21:00:56 +03:00
|
|
|
fileList.$el.find('.actions-selected').click();
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
2018-06-06 21:00:56 +03:00
|
|
|
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Delete', function () {
|
|
|
|
it('Shows trashbin actions', function () {
|
2015-03-04 15:49:19 +03:00
|
|
|
// visible because a few files were selected
|
|
|
|
expect($('.selectedActions').is(':visible')).toEqual(true);
|
2018-06-06 21:00:56 +03:00
|
|
|
expect($('.selectedActions .item-delete').is(':visible')).toEqual(true);
|
|
|
|
expect($('.selectedActions .item-restore').is(':visible')).toEqual(true);
|
2015-03-04 15:49:19 +03:00
|
|
|
|
|
|
|
// check
|
|
|
|
fileList.$el.find('.select-all').click();
|
|
|
|
|
|
|
|
// stays visible
|
|
|
|
expect($('.selectedActions').is(':visible')).toEqual(true);
|
2018-06-06 21:00:56 +03:00
|
|
|
expect($('.selectedActions .item-delete').is(':visible')).toEqual(true);
|
|
|
|
expect($('.selectedActions .item-restore').is(':visible')).toEqual(true);
|
2015-03-04 15:49:19 +03:00
|
|
|
|
|
|
|
// uncheck
|
|
|
|
fileList.$el.find('.select-all').click();
|
|
|
|
|
|
|
|
// becomes hidden now
|
|
|
|
expect($('.selectedActions').is(':visible')).toEqual(false);
|
2018-06-06 21:00:56 +03:00
|
|
|
expect($('.selectedActions .item-delete').is(':visible')).toEqual(false);
|
|
|
|
expect($('.selectedActions .item-restore').is(':visible')).toEqual(false);
|
2015-03-04 15:49:19 +03:00
|
|
|
});
|
2020-11-10 11:50:46 +03:00
|
|
|
it('Deletes selected files when "Delete" clicked', function (done) {
|
2014-05-09 00:06:30 +04:00
|
|
|
var request;
|
2018-09-26 20:20:53 +03:00
|
|
|
var promise = fileList._onClickDeleteSelected({
|
|
|
|
preventDefault: function () {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var files = ["One.txt.d11111", "Three.pdf.d33333", "somedir.d99999"];
|
|
|
|
expect(fakeServer.requests.length).toEqual(files.length);
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
request = fakeServer.requests[i];
|
2018-10-09 08:44:26 +03:00
|
|
|
expect(request.url).toEqual(OC.getRootPath() + '/remote.php/dav/trashbin/user/trash/' + files[i]);
|
2018-09-26 20:20:53 +03:00
|
|
|
request.respond(200);
|
|
|
|
}
|
|
|
|
return promise.then(function () {
|
|
|
|
expect(fileList.findFileEl('One.txt.d11111').length).toEqual(0);
|
|
|
|
expect(fileList.findFileEl('Three.pdf.d33333').length).toEqual(0);
|
|
|
|
expect(fileList.findFileEl('somedir.d99999').length).toEqual(0);
|
|
|
|
expect(fileList.findFileEl('Two.jpg.d22222').length).toEqual(1);
|
2020-11-10 11:50:46 +03:00
|
|
|
}).then(done, done);
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
2020-11-10 11:50:46 +03:00
|
|
|
it('Deletes all files when all selected when "Delete" clicked', function (done) {
|
2014-05-09 00:06:30 +04:00
|
|
|
var request;
|
2014-05-12 21:54:20 +04:00
|
|
|
$('.select-all').click();
|
2018-09-26 20:20:53 +03:00
|
|
|
var promise = fileList._onClickDeleteSelected({
|
|
|
|
preventDefault: function () {
|
|
|
|
}
|
|
|
|
});
|
2014-05-09 00:06:30 +04:00
|
|
|
expect(fakeServer.requests.length).toEqual(1);
|
|
|
|
request = fakeServer.requests[0];
|
2018-10-09 08:44:26 +03:00
|
|
|
expect(request.url).toEqual(OC.getRootPath() + '/remote.php/dav/trashbin/user/trash');
|
2018-09-26 20:20:53 +03:00
|
|
|
request.respond(200);
|
|
|
|
return promise.then(function () {
|
|
|
|
expect(fileList.isEmpty).toEqual(true);
|
2020-11-10 11:50:46 +03:00
|
|
|
}).then(done, done);
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
|
|
|
});
|
2018-09-26 20:20:53 +03:00
|
|
|
describe('Restore', function () {
|
2020-11-10 11:50:46 +03:00
|
|
|
it('Restores selected files when "Restore" clicked', function (done) {
|
2014-05-09 00:06:30 +04:00
|
|
|
var request;
|
2018-09-26 20:20:53 +03:00
|
|
|
var promise = fileList._onClickRestoreSelected({
|
|
|
|
preventDefault: function () {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var files = ["One.txt.d11111", "Three.pdf.d33333", "somedir.d99999"];
|
|
|
|
expect(fakeServer.requests.length).toEqual(files.length);
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
request = fakeServer.requests[i];
|
2018-10-09 08:44:26 +03:00
|
|
|
expect(request.url).toEqual(OC.getRootPath() + '/remote.php/dav/trashbin/user/trash/' + files[i]);
|
|
|
|
expect(request.requestHeaders.Destination).toEqual(OC.getRootPath() + '/remote.php/dav/trashbin/user/restore/' + files[i]);
|
2018-09-26 20:20:53 +03:00
|
|
|
request.respond(200);
|
|
|
|
}
|
|
|
|
return promise.then(function() {
|
|
|
|
expect(fileList.findFileEl('One.txt.d11111').length).toEqual(0);
|
|
|
|
expect(fileList.findFileEl('Three.pdf.d33333').length).toEqual(0);
|
|
|
|
expect(fileList.findFileEl('somedir.d99999').length).toEqual(0);
|
|
|
|
expect(fileList.findFileEl('Two.jpg.d22222').length).toEqual(1);
|
2020-11-10 11:50:46 +03:00
|
|
|
}).then(done, done);
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
2020-11-10 11:50:46 +03:00
|
|
|
it('Restores all files when all selected when "Restore" clicked', function (done) {
|
2014-05-09 00:06:30 +04:00
|
|
|
var request;
|
2014-05-12 21:54:20 +04:00
|
|
|
$('.select-all').click();
|
2018-09-26 20:20:53 +03:00
|
|
|
var promise = fileList._onClickRestoreSelected({
|
|
|
|
preventDefault: function () {
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var files = ["One.txt.d11111", "Two.jpg.d22222", "Three.pdf.d33333", "somedir.d99999"];
|
|
|
|
expect(fakeServer.requests.length).toEqual(files.length);
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
request = fakeServer.requests[i];
|
2018-10-09 08:44:26 +03:00
|
|
|
expect(request.url).toEqual(OC.getRootPath() + '/remote.php/dav/trashbin/user/trash/' + files[i]);
|
|
|
|
expect(request.requestHeaders.Destination).toEqual(OC.getRootPath() + '/remote.php/dav/trashbin/user/restore/' + files[i]);
|
2018-09-26 20:20:53 +03:00
|
|
|
request.respond(200);
|
|
|
|
}
|
|
|
|
return promise.then(function() {
|
|
|
|
expect(fileList.isEmpty).toEqual(true);
|
2020-11-10 11:50:46 +03:00
|
|
|
}).then(done, done);
|
2014-05-09 00:06:30 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|