feat: Refetch the active conversation messages on action cable reconnect (#6790)

This commit is contained in:
Muhsin Keloth
2023-04-24 10:17:12 +05:30
committed by GitHub
parent 474e65f4c8
commit 815322b27a
7 changed files with 204 additions and 11 deletions

View File

@@ -465,4 +465,66 @@ describe('#addMentions', () => {
['updateConversation', { id: 1, meta: { sender: { id: 1 } } }],
]);
});
it('#syncActiveConversationMessages', async () => {
const conversations = [
{
id: 1,
messages: [
{
id: 1,
content: 'Hello',
},
],
meta: { sender: { id: 1, name: 'john-doe' } },
inbox_id: 1,
},
];
axios.get.mockResolvedValue({
data: {
payload: [{ id: 2, content: 'Welcome' }],
meta: {
agent_last_seen_at: '2023-04-20T05:22:42.990Z',
},
},
});
await actions.syncActiveConversationMessages(
{
commit,
dispatch,
state: {
allConversations: conversations,
syncConversationsMessages: {
1: 1,
},
},
},
{ conversationId: 1 }
);
expect(commit.mock.calls).toEqual([
[
'conversationMetadata/SET_CONVERSATION_METADATA',
{
id: 1,
data: {
agent_last_seen_at: '2023-04-20T05:22:42.990Z',
},
},
],
[
'SET_MISSING_MESSAGES',
{
id: 1,
data: [
{ id: 1, content: 'Hello' },
{ id: 2, content: 'Welcome' },
],
},
],
[
'SET_LAST_MESSAGE_ID_FOR_SYNC_CONVERSATION',
{ conversationId: 1, messageId: null },
],
]);
});
});