diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-05-10 10:39:36 +0200 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2024-06-14 10:27:27 +0200 |
commit | e3bdf7251b44fc0c996a848e6fdaac370d024bcd (patch) | |
tree | 033d10bc15177f1a3571ef0350d58caf4252b509 /src | |
parent | 62eea8bcb4203a9a7ecab7f68612cbaace3b7482 (diff) |
test(capabilities): adjust tests for new changes
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/__mocks__/capabilities.ts | 159 | ||||
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js | 16 | ||||
-rw-r--r-- | src/composables/__tests__/useMessageInfo.spec.js | 2 | ||||
-rw-r--r-- | src/services/conversationsService.spec.js | 3 | ||||
-rw-r--r-- | src/store/messagesStore.spec.js | 2 | ||||
-rw-r--r-- | src/test-setup.js | 6 |
6 files changed, 174 insertions, 14 deletions
diff --git a/src/__mocks__/capabilities.ts b/src/__mocks__/capabilities.ts new file mode 100644 index 000000000..d7048b030 --- /dev/null +++ b/src/__mocks__/capabilities.ts @@ -0,0 +1,159 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { Capabilities } from '../types' + +export const mockedCapabilities: Capabilities = { + spreed: { + features: [ + 'audio', + 'video', + 'chat-v2', + 'conversation-v4', + 'guest-signaling', + 'empty-group-room', + 'guest-display-names', + 'multi-room-users', + 'favorites', + 'last-room-activity', + 'no-ping', + 'system-messages', + 'delete-messages', + 'mention-flag', + 'in-call-flags', + 'conversation-call-flags', + 'notification-levels', + 'invite-groups-and-mails', + 'locked-one-to-one-rooms', + 'read-only-rooms', + 'listable-rooms', + 'chat-read-marker', + 'chat-unread', + 'webinary-lobby', + 'start-call-flag', + 'chat-replies', + 'circles-support', + 'force-mute', + 'sip-support', + 'sip-support-nopin', + 'chat-read-status', + 'phonebook-search', + 'raise-hand', + 'room-description', + 'rich-object-sharing', + 'temp-user-avatar-api', + 'geo-location-sharing', + 'voice-message-sharing', + 'signaling-v3', + 'publishing-permissions', + 'clear-history', + 'direct-mention-flag', + 'notification-calls', + 'conversation-permissions', + 'rich-object-list-media', + 'rich-object-delete', + 'unified-search', + 'chat-permission', + 'silent-send', + 'silent-call', + 'send-call-notification', + 'talk-polls', + 'breakout-rooms-v1', + 'recording-v1', + 'avatar', + 'chat-get-context', + 'single-conversation-status', + 'chat-keep-notifications', + 'typing-privacy', + 'remind-me-later', + 'bots-v1', + 'markdown-messages', + 'media-caption', + 'session-state', + 'note-to-self', + 'recording-consent', + 'sip-support-dialout', + 'delete-messages-unlimited', + 'edit-messages', + 'silent-send-state', + 'chat-read-last', + 'federation-v1', + 'ban-v1', + ], + 'features-local': [ + 'favorites', + 'chat-read-status', + 'listable-rooms', + 'phonebook-search', + 'temp-user-avatar-api', + 'unified-search', + 'avatar', + 'remind-me-later', + 'note-to-self', + ], + config: { + attachments: { + allowed: true, + folder: '/Talk', + }, + call: { + enabled: true, + 'breakout-rooms': true, + recording: true, + 'recording-consent': 0, + 'supported-reactions': ['❤️', '🎉', '👏', '👍', '👎', '😂', '🤩', '🤔', '😲', '😥'], + 'predefined-backgrounds': ['1_office', '2_home', '3_abstract'], + 'can-upload-background': true, + 'sip-enabled': true, + 'sip-dialout-enabled': true, + 'can-enable-sip': true, + }, + chat: { + 'max-length': 32000, + 'read-privacy': 0, + 'has-translation-providers': true, + 'typing-privacy': 0, + }, + conversations: { + 'can-create': true, + }, + federation: { + enabled: false, + 'incoming-enabled': false, + 'outgoing-enabled': false, + 'only-trusted-servers': true, + }, + previews: { + 'max-gif-size': 3145728, + }, + signaling: { + 'session-ping-limit': 200, + }, + }, + 'config-local': { + attachments: [ + 'allowed', + 'folder', + ], + call: [ + 'predefined-backgrounds', + 'can-upload-background', + ], + chat: [ + 'read-privacy', + 'has-translation-providers', + 'typing-privacy', + ], + conversations: [ + 'can-create', + ], + federation: [], + previews: [ + 'max-gif-size', + ], + signaling: [], + }, + version: '20.0.0-dev.0', + } +} diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js index 5ce908605..aaa056fa2 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.spec.js @@ -18,18 +18,6 @@ import FilePreview from './FilePreview.vue' import storeConfig from '../../../../../store/storeConfig.js' -jest.mock('@nextcloud/capabilities', () => ({ - getCapabilities: jest.fn(() => ({ - spreed: { - config: { - previews: { - 'max-gif-size': 1024, - }, - }, - } - })), -})) - describe('FilePreview.vue', () => { let store let localVue @@ -312,8 +300,8 @@ describe('FilePreview.vue', () => { }) test('renders static preview for big GIF files', async () => { - // bigger than max from capability - propsData.size = '2048' + // 4 MB, bigger than max from capability (3 MB) + propsData.size = '4194304' const wrapper = shallowMount(FilePreview, { localVue, diff --git a/src/composables/__tests__/useMessageInfo.spec.js b/src/composables/__tests__/useMessageInfo.spec.js index 23ec0272d..edabd45a7 100644 --- a/src/composables/__tests__/useMessageInfo.spec.js +++ b/src/composables/__tests__/useMessageInfo.spec.js @@ -9,10 +9,12 @@ import { useConversationInfo } from '../useConversationInfo.js' import { useMessageInfo } from '../useMessageInfo.js' import { useStore } from '../useStore.js' +// Test messages with 'edit-messages' and without 'delete-messages-unlimited' feature jest.mock('@nextcloud/capabilities', () => ({ getCapabilities: jest.fn(() => ({ spreed: { features: ['edit-messages'], + 'features-local': [], }, })) })) diff --git a/src/services/conversationsService.spec.js b/src/services/conversationsService.spec.js index b2ed6e828..726c47d55 100644 --- a/src/services/conversationsService.spec.js +++ b/src/services/conversationsService.spec.js @@ -12,11 +12,14 @@ jest.mock('@nextcloud/axios', () => ({ get: jest.fn(), })) +// Test requests when federations invite are enabled jest.mock('@nextcloud/capabilities', () => ({ getCapabilities: jest.fn(() => ({ spreed: { features: ['federation-v1'], + 'features-local': [], config: { federation: { enabled: true, 'outgoing-enabled': true } }, + 'config-local': { federation: [] }, }, })) })) diff --git a/src/store/messagesStore.spec.js b/src/store/messagesStore.spec.js index c2538b769..e2ce0b247 100644 --- a/src/store/messagesStore.spec.js +++ b/src/store/messagesStore.spec.js @@ -60,6 +60,8 @@ jest.mock('@nextcloud/capabilities', () => ({ getCapabilities: jest.fn(() => ({ spreed: { features: ['chat-read-last'], + 'features-local': [], + 'config-local': { chat: [] }, }, })) })) diff --git a/src/test-setup.js b/src/test-setup.js index b7d7cab74..16bfdf2e8 100644 --- a/src/test-setup.js +++ b/src/test-setup.js @@ -9,6 +9,8 @@ import Vue from 'vue' import { translate, translatePlural } from '@nextcloud/l10n' +import { mockedCapabilities } from './__mocks__/capabilities.ts' + jest.mock('extendable-media-recorder', () => ({ MediaRecorder: jest.fn(), register: jest.fn(), @@ -28,6 +30,10 @@ jest.mock('@nextcloud/upload', () => ({ getUploader: jest.fn(), })) +jest.mock('@nextcloud/capabilities', () => ({ + getCapabilities: jest.fn(() => mockedCapabilities), +})) + window.IntersectionObserver = jest.fn(() => ({ observe: jest.fn(), unobserve: jest.fn(), |