diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-01 00:37:56 +0200 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2024-09-10 14:05:42 +0200 |
commit | 696447d3acd77f928aec3dea622ccbb8ee784778 (patch) | |
tree | 9bdbcdc348c22d0f69b0f18551ab57c6e01f255c /apps/files_sharing/src/services/SharingService.spec.ts | |
parent | 3c2ead71330b2510b2266c9883d1d0b157424425 (diff) | |
download | nextcloud-server-696447d3acd77f928aec3dea622ccbb8ee784778.tar.gz nextcloud-server-696447d3acd77f928aec3dea622ccbb8ee784778.zip |
fix(files): Correctly parse external shares for files UI
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files_sharing/src/services/SharingService.spec.ts')
-rw-r--r-- | apps/files_sharing/src/services/SharingService.spec.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/apps/files_sharing/src/services/SharingService.spec.ts b/apps/files_sharing/src/services/SharingService.spec.ts index ed3a0cb6590..ef9690d094e 100644 --- a/apps/files_sharing/src/services/SharingService.spec.ts +++ b/apps/files_sharing/src/services/SharingService.spec.ts @@ -287,6 +287,25 @@ describe('SharingService share to Node mapping', () => { tags: [window.OC.TAG_FAVORITE], } + const remoteFile = { + mimetype: 'text/markdown', + mtime: 1688721600, + permissions: 19, + type: 'file', + file_id: 1234, + id: 4, + share_type: Type.SHARE_TYPE_USER, + parent: null, + remote: 'http://exampe.com', + remote_id: '12345', + share_token: 'share-token', + name: '/test.md', + mountpoint: '/shares/test.md', + owner: 'owner-uid', + user: 'sharee-uid', + accepted: true, + } + test('File', async () => { jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({ data: { @@ -346,6 +365,35 @@ describe('SharingService share to Node mapping', () => { expect(folder.attributes.favorite).toBe(1) }) + test('Remote file', async () => { + jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({ + data: { + ocs: { + data: [remoteFile], + }, + }, + })) + + const shares = await getContents(false, true, false, false) + + expect(axios.get).toHaveBeenCalledTimes(1) + expect(shares.contents).toHaveLength(1) + + const file = shares.contents[0] as File + expect(file).toBeInstanceOf(File) + expect(file.fileid).toBe(1234) + expect(file.source).toBe('http://localhost/remote.php/dav/files/test/shares/test.md') + expect(file.owner).toBe('owner-uid') + expect(file.mime).toBe('text/markdown') + expect(file.mtime?.getTime()).toBe(remoteFile.mtime * 1000) + // not available for remote shares + expect(file.size).toBe(undefined) + expect(file.permissions).toBe(0) + expect(file.root).toBe('/files/test') + expect(file.attributes).toBeInstanceOf(Object) + expect(file.attributes.favorite).toBe(0) + }) + test('Empty', async () => { jest.spyOn(logger, 'error').mockImplementationOnce(() => {}) jest.spyOn(axios, 'get').mockReturnValueOnce(Promise.resolve({ |