diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-02 12:13:43 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-09 17:13:30 +0200 |
commit | 24c01695bb0023fa85dab29cf7170d9596456d5b (patch) | |
tree | 1369336c1531024d3b67fa6fff2eafad24b6ad92 /apps/files_sharing/src | |
parent | 691f570237e26398aa22f40c0efca23141d5583e (diff) | |
download | nextcloud-server-24c01695bb0023fa85dab29cf7170d9596456d5b.tar.gz nextcloud-server-24c01695bb0023fa85dab29cf7170d9596456d5b.zip |
test: Adjust Typescript definitions for OCP and OC
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files_sharing/src')
7 files changed, 24 insertions, 22 deletions
diff --git a/apps/files_sharing/src/actions/acceptShareAction.spec.ts b/apps/files_sharing/src/actions/acceptShareAction.spec.ts index 14ff88fa885..848bdc5496b 100644 --- a/apps/files_sharing/src/actions/acceptShareAction.spec.ts +++ b/apps/files_sharing/src/actions/acceptShareAction.spec.ts @@ -5,6 +5,7 @@ import { action } from './acceptShareAction' import { expect } from '@jest/globals' import { File, Permission, View, FileAction } from '@nextcloud/files' +import { ShareType } from '@nextcloud/sharing' import eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import '../main' @@ -103,7 +104,7 @@ describe('Accept share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -130,7 +131,7 @@ describe('Accept share action execute tests', () => { attributes: { id: 123, remote: 3, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -156,7 +157,7 @@ describe('Accept share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -168,7 +169,7 @@ describe('Accept share action execute tests', () => { permissions: Permission.READ, attributes: { id: 456, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -195,7 +196,7 @@ describe('Accept share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) diff --git a/apps/files_sharing/src/actions/openInFilesAction.spec.ts b/apps/files_sharing/src/actions/openInFilesAction.spec.ts index d48e3ac8144..aa73f020bc0 100644 --- a/apps/files_sharing/src/actions/openInFilesAction.spec.ts +++ b/apps/files_sharing/src/actions/openInFilesAction.spec.ts @@ -57,6 +57,7 @@ describe('Open in files action enabled tests', () => { describe('Open in files action execute tests', () => { test('Open in files', async () => { const goToRouteMock = jest.fn() + // @ts-expect-error We only mock what needed, we do not need Files.Router.goTo or Files.Navigation window.OCP = { Files: { Router: { goToRoute: goToRouteMock } } } const file = new File({ diff --git a/apps/files_sharing/src/actions/rejectShareAction.spec.ts b/apps/files_sharing/src/actions/rejectShareAction.spec.ts index dc4c9a69601..e4d37cd952c 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.spec.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.spec.ts @@ -5,6 +5,7 @@ import { action } from './rejectShareAction' import { expect } from '@jest/globals' import { File, Folder, Permission, View, FileAction } from '@nextcloud/files' +import { ShareType } from '@nextcloud/sharing' import eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import '../main' @@ -96,7 +97,7 @@ describe('Reject share action enabled tests', () => { owner: 'admin', permissions: Permission.READ, attributes: { - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) const folder2 = new Folder({ @@ -106,7 +107,7 @@ describe('Reject share action enabled tests', () => { permissions: Permission.READ, attributes: { remote_id: 1, - share_type: window.OC.Share.SHARE_TYPE_REMOTE_GROUP, + share_type: ShareType.RemoteGroup, }, }) @@ -130,7 +131,7 @@ describe('Reject share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -157,7 +158,7 @@ describe('Reject share action execute tests', () => { attributes: { id: 123, remote: 3, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -183,7 +184,7 @@ describe('Reject share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -195,7 +196,7 @@ describe('Reject share action execute tests', () => { permissions: Permission.READ, attributes: { id: 456, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -222,7 +223,7 @@ describe('Reject share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) diff --git a/apps/files_sharing/src/actions/rejectShareAction.ts b/apps/files_sharing/src/actions/rejectShareAction.ts index 5c3dc619f2c..ce47e0b5f13 100644 --- a/apps/files_sharing/src/actions/rejectShareAction.ts +++ b/apps/files_sharing/src/actions/rejectShareAction.ts @@ -8,6 +8,7 @@ import { emit } from '@nextcloud/event-bus' import { generateOcsUrl } from '@nextcloud/router' import { registerFileAction, FileAction } from '@nextcloud/files' import { translatePlural as n } from '@nextcloud/l10n' +import { ShareType } from '@nextcloud/sharing' import axios from '@nextcloud/axios' import CloseSvg from '@mdi/svg/svg/close.svg?raw' @@ -30,7 +31,7 @@ export const action = new FileAction({ // disable rejecting group shares from the pending list because they anyway // land back into that same list after rejecting them if (nodes.some(node => node.attributes.remote_id - && node.attributes.share_type === window.OC.Share.SHARE_TYPE_REMOTE_GROUP)) { + && node.attributes.share_type === ShareType.RemoteGroup)) { return false } diff --git a/apps/files_sharing/src/actions/restoreShareAction.spec.ts b/apps/files_sharing/src/actions/restoreShareAction.spec.ts index f35d0d0ef18..8132c76fe2b 100644 --- a/apps/files_sharing/src/actions/restoreShareAction.spec.ts +++ b/apps/files_sharing/src/actions/restoreShareAction.spec.ts @@ -5,6 +5,7 @@ import { action } from './restoreShareAction' import { expect } from '@jest/globals' import { File, Permission, View, FileAction } from '@nextcloud/files' +import { ShareType } from '@nextcloud/sharing' import eventBus from '@nextcloud/event-bus' import axios from '@nextcloud/axios' import '../main' @@ -103,7 +104,7 @@ describe('Restore share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -129,7 +130,7 @@ describe('Restore share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -141,7 +142,7 @@ describe('Restore share action execute tests', () => { permissions: Permission.READ, attributes: { id: 456, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) @@ -168,7 +169,7 @@ describe('Restore share action execute tests', () => { permissions: Permission.READ, attributes: { id: 123, - share_type: window.OC.Share.SHARE_TYPE_USER, + share_type: ShareType.User, }, }) diff --git a/apps/files_sharing/src/main.ts b/apps/files_sharing/src/main.ts index aaa07fddc36..3170fbc2a7b 100644 --- a/apps/files_sharing/src/main.ts +++ b/apps/files_sharing/src/main.ts @@ -4,10 +4,6 @@ */ // register default shares types -if (!window.OC) { - window.OC = {} -} - Object.assign(window.OC, { Share: { SHARE_TYPE_USER: 0, diff --git a/apps/files_sharing/src/views/shares.ts b/apps/files_sharing/src/views/shares.ts index e43c75b3a5e..98b68ee25e2 100644 --- a/apps/files_sharing/src/views/shares.ts +++ b/apps/files_sharing/src/views/shares.ts @@ -4,6 +4,7 @@ */ import { translate as t } from '@nextcloud/l10n' import { View, getNavigation } from '@nextcloud/files' +import { ShareType } from '@nextcloud/sharing' import AccountClockSvg from '@mdi/svg/svg/account-clock.svg?raw' import AccountGroupSvg from '@mdi/svg/svg/account-group.svg?raw' import AccountPlusSvg from '@mdi/svg/svg/account-plus.svg?raw' @@ -86,7 +87,7 @@ export default () => { columns: [], - getContents: () => getContents(false, true, false, false, [window.OC.Share.SHARE_TYPE_LINK]), + getContents: () => getContents(false, true, false, false, [ShareType.Link]), })) Navigation.register(new View({ |