diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.spec.js b/src/components/LeftSidebar/ConversationsList/Conversation.spec.js
index a6434108e8e..5a6ab3ad4fd 100644
--- a/src/components/LeftSidebar/ConversationsList/Conversation.spec.js
+++ b/src/components/LeftSidebar/ConversationsList/Conversation.spec.js
@@ -530,10 +530,22 @@ describe('Conversation.vue', () => {
expect(toggleFavoriteAction).toHaveBeenCalledWith(expect.anything(), item)
})
+ test('marks conversation as unread', async () => {
+ const markConversationUnreadAction = jest.fn().mockResolvedValueOnce()
+ testStoreConfig.modules.conversationsStore.actions.markConversationUnread = markConversationUnreadAction
+
+ const action = shallowMountAndGetAction('Mark as unread')
+ expect(action.exists()).toBe(true)
+
+ await action.find('button').trigger('click')
+
+ expect(markConversationUnreadAction).toHaveBeenCalledWith(expect.anything(), { token: item.token })
+ })
test('marks conversation as read', async () => {
const clearLastReadMessageAction = jest.fn().mockResolvedValueOnce()
testStoreConfig.modules.conversationsStore.actions.clearLastReadMessage = clearLastReadMessageAction
+ item.unreadMessages = 1
const action = shallowMountAndGetAction('Mark as read')
expect(action.exists()).toBe(true)
diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue
index 94224fd844e..1376e4997b3 100644
--- a/src/components/LeftSidebar/ConversationsList/Conversation.vue
+++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue
@@ -62,13 +62,22 @@
@click.stop.prevent="handleCopyLink">
{{ t('spreed', 'Copy link') }}
-
{{ t('spreed', 'Mark as read') }}
+
+
+
+
+ {{ t('spreed', 'Mark as unread') }}
+
({
deleteConversation: jest.fn(),
setConversationPermissions: jest.fn(),
setCallPermissions: jest.fn(),
+ setConversationUnread: jest.fn(),
}))
describe('conversationsStore', () => {
@@ -583,6 +586,31 @@ describe('conversationsStore', () => {
expect(changedConversation.unreadMention).toBe(false)
})
+ test('marks conversation as unread', async () => {
+ testConversation.unreadMessages = 0
+
+ const response = {
+ data: {
+ ocs: {
+ data: { ...testConversation, unreadMessages: 1 },
+ },
+ },
+ }
+ fetchConversation.mockResolvedValue(response)
+
+ store.dispatch('addConversation', testConversation)
+
+ store.dispatch('markConversationUnread', { token: testToken })
+
+ await flushPromises()
+
+ expect(setConversationUnread).toHaveBeenCalled()
+ expect(fetchConversation).toHaveBeenCalled()
+
+ const changedConversation = store.getters.conversation(testToken)
+ expect(changedConversation.unreadMessages).toBe(1)
+ })
+
test('updates last common read message', () => {
testConversation.lastCommonReadMessage = {
id: 999,