diff --git a/src/components/CallView/shared/EmptyCallView.vue b/src/components/CallView/shared/EmptyCallView.vue index f30615fa335..f7efd3f932b 100644 --- a/src/components/CallView/shared/EmptyCallView.vue +++ b/src/components/CallView/shared/EmptyCallView.vue @@ -78,7 +78,8 @@ export default { }, isOneToOneConversation() { - return this.conversation && this.conversation.type === CONVERSATION.TYPE.ONE_TO_ONE + return this.conversation?.type === CONVERSATION.TYPE.ONE_TO_ONE + || this.conversation?.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER }, isPasswordRequestConversation() { diff --git a/src/components/ConversationIcon.vue b/src/components/ConversationIcon.vue index e935594c7c6..04f1ed20901 100644 --- a/src/components/ConversationIcon.vue +++ b/src/components/ConversationIcon.vue @@ -213,6 +213,7 @@ export default { isOneToOne() { return this.item.type === CONVERSATION.TYPE.ONE_TO_ONE + || this.item.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER }, conversationType() { diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.spec.js b/src/components/MessagesList/MessagesGroup/Message/Message.spec.js index 08b5b3f4fcc..2dcad1167a3 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/Message.spec.js @@ -320,6 +320,7 @@ describe('Message.vue', () => { function renderRichObject(message, messageParameters, expectedRichParameters) { messageProps.message = message messageProps.messageParameters = messageParameters + store.dispatch('processMessage', { token: TOKEN, message: messageProps }) const wrapper = shallowMount(Message, { localVue, store, @@ -744,7 +745,6 @@ describe('Message.vue', () => { propsData: messageProps, provide: injected, }) - const message = wrapper.findComponent({ name: 'NcRichText' }) expect(message.attributes('text')).toBe('test message') diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue index 2bb91125453..d6f1c226eca 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.vue +++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue @@ -446,10 +446,6 @@ export default { && this.messageType !== 'command' && this.messageType !== 'comment_deleted' }, - - isFileShareOnly() { - return Object.keys(Object(this.messageParameters)).some(key => key.startsWith('file')) && this.message === '{file}' - }, }, mounted() { diff --git a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.spec.js b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.spec.js index 391112074b1..2538a5dae37 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.spec.js +++ b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.spec.js @@ -13,6 +13,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import MessageButtonsBar from './../MessageButtonsBar/MessageButtonsBar.vue' +import * as useMessageInfoModule from '../../../../../composables/useMessageInfo.js' import { CONVERSATION, PARTICIPANT, ATTENDEE } from '../../../../../constants.js' import storeConfig from '../../../../../store/storeConfig.js' import { useIntegrationsStore } from '../../../../../stores/integrations.js' @@ -96,6 +97,7 @@ describe('MessageButtonsBar.vue', () => { }) describe('actions', () => { + let useMessageInfoSpy beforeEach(() => { store = new Store(testStoreConfig) @@ -103,6 +105,12 @@ describe('MessageButtonsBar.vue', () => { injected = { getMessagesListScroller: jest.fn(), } + + useMessageInfoSpy = jest.spyOn(useMessageInfoModule, 'useMessageInfo') + }) + + afterEach(() => { + useMessageInfoSpy.mockRestore() }) describe('reply action', () => { @@ -212,6 +220,9 @@ describe('MessageButtonsBar.vue', () => { } test('hides private reply action for own messages', async () => { + useMessageInfoSpy.mockReturnValue({ + isCurrentUserOwnMessage: () => true, + }) // using default message props which have the // actor id set to the current user testPrivateReplyActionVisible(false) @@ -244,6 +255,9 @@ describe('MessageButtonsBar.vue', () => { const mockDate = new Date('2020-05-07 10:00:00') jest.spyOn(global.Date, 'now') .mockImplementation(() => mockDate) + useMessageInfoSpy.mockReturnValue({ + isDeleteable: () => true, + }) const wrapper = shallowMount(MessageButtonsBar, { localVue, store, @@ -264,19 +278,8 @@ describe('MessageButtonsBar.vue', () => { /** * @param {boolean} visible Whether or not the delete action is visible - * @param {Date} mockDate The message date (deletion only works within 6h) */ - function testDeleteMessageVisible(visible, mockDate) { - store = new Store(testStoreConfig) - - // need to mock the date to be within 6h - if (!mockDate) { - mockDate = new Date('2020-05-07 10:00:00') - } - - jest.spyOn(global.Date, 'now') - .mockImplementation(() => mockDate) - + function testDeleteMessageVisible(visible) { const wrapper = shallowMount(MessageButtonsBar, { localVue, store, @@ -291,53 +294,16 @@ describe('MessageButtonsBar.vue', () => { expect(actionButton.exists()).toBe(visible) } - test('hides delete action when message is older than 6 hours', () => { - testDeleteMessageVisible(false, new Date('2020-05-07 15:24:00')) - }) - - test('hides delete action when the conversation is read-only', () => { - conversationProps.readOnly = CONVERSATION.STATE.READ_ONLY + test('hides delete action when it cannot be deleted', async () => { testDeleteMessageVisible(false) }) - test('show delete action for file messages', () => { - messageProps.message = '{file}' - messageProps.messageParameters.file = {} + test('show delete action when it can be deleted', () => { + useMessageInfoSpy.mockReturnValue({ + isDeleteable: () => true, + }) testDeleteMessageVisible(true) }) - - test('hides delete action on other people messages for non-moderators', () => { - messageProps.actorId = 'another-user' - conversationProps.type = CONVERSATION.TYPE.GROUP - testDeleteMessageVisible(false) - }) - - test('shows delete action on other people messages for moderators', () => { - messageProps.actorId = 'another-user' - conversationProps.type = CONVERSATION.TYPE.GROUP - conversationProps.participantType = PARTICIPANT.TYPE.MODERATOR - testDeleteMessageVisible(true, null) - }) - - test('shows delete action on other people messages for owner', () => { - messageProps.actorId = 'another-user' - conversationProps.type = CONVERSATION.TYPE.PUBLIC - conversationProps.participantType = PARTICIPANT.TYPE.OWNER - testDeleteMessageVisible(true, null) - }) - - test('does not show delete action even for guest moderators', () => { - messageProps.actorId = 'another-user' - conversationProps.type = CONVERSATION.TYPE.PUBLIC - conversationProps.participantType = PARTICIPANT.TYPE.GUEST_MODERATOR - testDeleteMessageVisible(false, null) - }) - - test('does not show delete action on other people messages in one to one conversations', () => { - messageProps.actorId = 'another-user' - conversationProps.type = CONVERSATION.TYPE.ONE_TO_ONE - testDeleteMessageVisible(false) - }) }) test('marks message as unread', async () => { diff --git a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue index 0ad7ce7e1ee..535db7157fc 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue @@ -85,7 +85,7 @@ {{ t('spreed', 'Edit message') }} -