diff --git a/apps/files/src/actions/sidebarAction.spec.ts b/apps/files/src/actions/sidebarAction.spec.ts index c378b85f1e51c..c2068826824dd 100644 --- a/apps/files/src/actions/sidebarAction.spec.ts +++ b/apps/files/src/actions/sidebarAction.spec.ts @@ -22,9 +22,57 @@ import { action } from './sidebarAction' import { expect } from '@jest/globals' import { FileAction } from '../services/FileAction' +import { File } from '@nextcloud/files' describe('Open sidebar action tests', () => { test('Default values', () => { expect(action).toBeInstanceOf(FileAction) + expect(action.id).toBe('details') + expect(action.displayName([], null)).toBe('Details') + expect(action.iconSvgInline([], null)).toBe('SvgMock') + expect(action.default).toBe(true) + expect(action.order).toBe(-50) + }) + + test('Enabled for ressources within user root folder', () => { + window.OCA = { Files: { Sidebar: {} } } + + const file = new File({ + id: 1, + source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', + owner: 'admin', + mime: 'text/plain', + }) + expect(action.enabled).toBeDefined() + // @ts-ignore we checked if it was defined + expect(action.enabled([file], null)).toBe(true) + }) + + test('Not enabled if no Sidebar', () => { + window.OCA = {} + + const file = new File({ + id: 1, + source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt', + owner: 'admin', + mime: 'text/plain', + }) + expect(action.enabled).toBeDefined() + // @ts-ignore we checked if it was defined + expect(action.enabled([file], null)).toBe(false) + }) + + test('Not enabled for external ressources', () => { + window.OCA = { Files: { Sidebar: {} } } + + const file = new File({ + id: 1, + source: 'https://domain.com/documents/admin/foobar.txt', + owner: 'admin', + mime: 'text/plain', + }) + expect(action.enabled).toBeDefined() + // @ts-ignore we checked if it was defined + expect(action.enabled([file], null)).toBe(false) }) })