aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-07-06 18:35:53 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-07-11 13:52:28 +0200
commitf5f142d31be7e5e61bbf78e2a37d84bf7349a658 (patch)
tree27fa1d9ed605a879635d547387f9fde6ad21eec5 /apps/files_sharing/tests
parentb0418f730f183e74df155adf1327f8489bbc56bf (diff)
downloadnextcloud-server-f5f142d31be7e5e61bbf78e2a37d84bf7349a658.tar.gz
nextcloud-server-f5f142d31be7e5e61bbf78e2a37d84bf7349a658.zip
fix: adjust testing
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php120
-rw-r--r--apps/files_sharing/tests/js/appSpec.js125
2 files changed, 88 insertions, 157 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 2a2a7d940be..df63f61606f 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -576,6 +576,8 @@ class ShareAPIControllerTest extends TestCase {
$file->method('getPath')->willReturn('file');
$file->method('getStorage')->willReturn($storage);
$file->method('getParent')->willReturn($parentFolder);
+ $file->method('getSize')->willReturn(123465);
+ $file->method('getMTime')->willReturn(1234567890);
$file->method('getMimeType')->willReturn('myMimeType');
$folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
@@ -583,6 +585,8 @@ class ShareAPIControllerTest extends TestCase {
$folder->method('getPath')->willReturn('folder');
$folder->method('getStorage')->willReturn($storage);
$folder->method('getParent')->willReturn($parentFolder);
+ $folder->method('getSize')->willReturn(123465);
+ $folder->method('getMTime')->willReturn(1234567890);
$folder->method('getMimeType')->willReturn('myFolderMimeType');
[$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes();
@@ -637,6 +641,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => false,
'can_delete' => false,
'status' => [],
+ 'item_size' => 123465,
+ 'item_mtime' => 1234567890,
'attributes' => null,
];
$data[] = [$share, $expected];
@@ -689,6 +695,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123465,
+ 'item_mtime' => 1234567890,
'attributes' => null,
];
$data[] = [$share, $expected];
@@ -747,6 +755,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123465,
+ 'item_mtime' => 1234567890,
'attributes' => null,
];
$data[] = [$share, $expected];
@@ -3735,6 +3745,13 @@ class ShareAPIControllerTest extends TestCase {
$folder->method('getParent')->willReturn($parent);
$fileWithPreview->method('getParent')->willReturn($parent);
+ $file->method('getSize')->willReturn(123456);
+ $folder->method('getSize')->willReturn(123456);
+ $fileWithPreview->method('getSize')->willReturn(123456);
+ $file->method('getMTime')->willReturn(1234567890);
+ $folder->method('getMTime')->willReturn(1234567890);
+ $fileWithPreview->method('getMTime')->willReturn(1234567890);
+
$cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
$storage = $this->createMock(Storage::class);
@@ -3772,7 +3789,7 @@ class ShareAPIControllerTest extends TestCase {
// User backend down
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -3796,7 +3813,7 @@ class ShareAPIControllerTest extends TestCase {
'share_with_displayname' => 'recipient',
'share_with_displayname_unique' => 'recipient',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'mail_send' => 0,
'mimetype' => 'myMimeType',
'has_preview' => false,
@@ -3804,13 +3821,15 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => false,
'can_delete' => false,
'status' => [],
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
], $share, [], false
];
// User backend up
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiatorDN',
@@ -3823,7 +3842,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'ownerDN',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
@@ -3842,6 +3861,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => false,
'can_delete' => false,
'status' => [],
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
], $share, [
['owner', $owner],
@@ -3864,7 +3885,7 @@ class ShareAPIControllerTest extends TestCase {
// User backend down
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -3877,7 +3898,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
@@ -3896,6 +3917,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => false,
'can_delete' => false,
'status' => [],
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -3914,7 +3937,7 @@ class ShareAPIControllerTest extends TestCase {
// User backend down
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -3927,7 +3950,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'currentUser',
'displayname_file_owner' => 'currentUser',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
@@ -3946,6 +3969,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => true,
'can_delete' => true,
'status' => [],
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -3966,7 +3991,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_GROUP,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -3979,7 +4004,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
@@ -3996,6 +4021,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4014,7 +4041,7 @@ class ShareAPIControllerTest extends TestCase {
->setId(42);
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_GROUP,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4026,7 +4053,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'file',
'item_type' => 'file',
'storage_id' => 'storageId',
@@ -4043,6 +4070,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4064,7 +4093,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_LINK,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4097,6 +4126,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4119,7 +4150,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_LINK,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4151,6 +4182,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4170,7 +4203,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_REMOTE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4182,7 +4215,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4199,6 +4232,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4218,7 +4253,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_REMOTE_GROUP,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4230,7 +4265,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4247,6 +4282,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4267,7 +4304,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_CIRCLE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4280,7 +4317,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => '',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4298,6 +4335,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4316,7 +4355,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_CIRCLE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4328,7 +4367,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => '',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4346,6 +4385,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4364,7 +4405,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_CIRCLE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4376,7 +4417,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => '',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4394,6 +4435,8 @@ class ShareAPIControllerTest extends TestCase {
'hide_download' => 0,
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4427,7 +4470,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_EMAIL,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4439,7 +4482,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => '',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4459,6 +4502,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => false,
'can_delete' => false,
'password_expiration_time' => null,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4478,7 +4523,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_EMAIL,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4490,7 +4535,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'note' => '',
- 'label' => null,
+ 'label' => '',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
@@ -4510,6 +4555,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => false,
'can_delete' => false,
'password_expiration_time' => null,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4529,7 +4576,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4541,7 +4588,7 @@ class ShareAPIControllerTest extends TestCase {
'uid_file_owner' => 'currentUser',
'displayname_file_owner' => 'currentUser',
'note' => 'personal note',
- 'label' => null,
+ 'label' => '',
'path' => 'fileWithPreview',
'item_type' => 'file',
'storage_id' => 'storageId',
@@ -4560,6 +4607,8 @@ class ShareAPIControllerTest extends TestCase {
'can_edit' => true,
'can_delete' => true,
'status' => [],
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, [], false
];
@@ -4659,6 +4708,9 @@ class ShareAPIControllerTest extends TestCase {
$file->method('getParent')->willReturn($parent);
+ $file->method('getSize')->willReturn(123456);
+ $file->method('getMTime')->willReturn(1234567890);
+
$cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock();
$cache->method('getNumericStorageId')->willReturn(100);
$storage = $this->createMock(Storage::class);
@@ -4683,7 +4735,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_ROOM,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4712,6 +4764,8 @@ class ShareAPIControllerTest extends TestCase {
'label' => '',
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, false, []
];
@@ -4730,7 +4784,7 @@ class ShareAPIControllerTest extends TestCase {
$result[] = [
[
- 'id' => 42,
+ 'id' => '42',
'share_type' => IShare::TYPE_ROOM,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
@@ -4759,6 +4813,8 @@ class ShareAPIControllerTest extends TestCase {
'label' => '',
'can_edit' => false,
'can_delete' => false,
+ 'item_size' => 123456,
+ 'item_mtime' => 1234567890,
'attributes' => null,
], $share, true, [
'share_with_displayname' => 'recipientRoomName'
diff --git a/apps/files_sharing/tests/js/appSpec.js b/apps/files_sharing/tests/js/appSpec.js
deleted file mode 100644
index 4d2e5211d7c..00000000000
--- a/apps/files_sharing/tests/js/appSpec.js
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
-* @copyright 2014 Vincent Petry <pvince81@owncloud.com>
- *
- * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Vincent Petry <vincent@nextcloud.com>
- *
- * @license AGPL-3.0-or-later
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * 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/>.
- *
- */
-
-describe('OCA.Sharing.App tests', function() {
- var App = OCA.Sharing.App;
- var fileListIn;
- var fileListOut;
-
- beforeEach(function() {
- $('#testArea').append(
- '<div id="app-navigation">' +
- '<ul><li data-id="files"><a>Files</a></li>' +
- '<li data-id="sharingin"><a></a></li>' +
- '<li data-id="sharingout"><a></a></li>' +
- '</ul></div>' +
- '<div id="app-content">' +
- '<div id="app-content-files" class="hidden">' +
- '</div>' +
- '<div id="app-content-sharingin" class="hidden">' +
- '</div>' +
- '<div id="app-content-sharingout" class="hidden">' +
- '</div>' +
- '</div>' +
- '</div>'
- );
- fileListIn = App.initSharingIn($('#app-content-sharingin'));
- fileListOut = App.initSharingOut($('#app-content-sharingout'));
- });
- afterEach(function() {
- App.destroy();
- });
-
- describe('initialization', function() {
- it('inits sharing-in list on show', function() {
- expect(fileListIn._sharedWithUser).toEqual(true);
- });
- it('inits sharing-out list on show', function() {
- expect(fileListOut._sharedWithUser).toBeFalsy();
- });
- });
- describe('file actions', function() {
- it('provides default file actions', function() {
- _.each([fileListIn, fileListOut], function(fileList) {
- var fileActions = fileList.fileActions;
-
- expect(fileActions.actions.all).toBeDefined();
- expect(fileActions.actions.all.Delete).toBeDefined();
- expect(fileActions.actions.all.Rename).toBeDefined();
- expect(fileActions.actions.all.Download).toBeDefined();
-
- expect(fileActions.defaults.dir).toEqual('Open');
- });
- });
- it('provides custom file actions', function() {
- var actionStub = sinon.stub();
- // regular file action
- OCA.Files.fileActions.register(
- 'all',
- 'RegularTest',
- OC.PERMISSION_READ,
- OC.imagePath('core', 'actions/shared'),
- actionStub
- );
-
- App._inFileList = null;
- fileListIn = App.initSharingIn($('#app-content-sharingin'));
-
- expect(fileListIn.fileActions.actions.all.RegularTest).toBeDefined();
- });
- it('redirects to files app when opening a directory', function() {
- var oldList = OCA.Files.App.fileList;
- // dummy new list to make sure it exists
- OCA.Files.App.fileList = new OCA.Files.FileList($('<table><thead></thead><tbody></tbody></table>'));
-
- var setActiveViewStub = sinon.stub(OCA.Files.App, 'setActiveView');
- // create dummy table so we can click the dom
- var $table = '<table><thead></thead><tbody class="files-fileList"></tbody></table>';
- $('#app-content-sharingin').append($table);
-
- App._inFileList = null;
- fileListIn = App.initSharingIn($('#app-content-sharingin'));
-
- fileListIn.setFiles([{
- name: 'testdir',
- type: 'dir',
- path: '/somewhere/inside/subdir',
- counterParts: ['user2'],
- shareOwner: 'user2'
- }]);
-
- fileListIn.findFileEl('testdir').find('td .nametext').click();
-
- expect(OCA.Files.App.fileList.getCurrentDirectory()).toEqual('/somewhere/inside/subdir/testdir');
-
- expect(setActiveViewStub.calledOnce).toEqual(true);
- expect(setActiveViewStub.calledWith('files')).toEqual(true);
-
- setActiveViewStub.restore();
-
- // restore old list
- OCA.Files.App.fileList = oldList;
- });
- });
-});