mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-26 16:04:59 +00:00
feat: Split reconnect logic PR (store) (#9520)
# Pull Request Template ## Description This PR includes store filter parts split from this [Reconnect PR](https://github.com/chatwoot/chatwoot/pull/9453)
This commit is contained in:
@@ -279,6 +279,66 @@ describe('#mutations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#SET_ALL_CONVERSATION', () => {
|
||||
it('set all conversation', () => {
|
||||
const state = { allConversations: [{ id: 1 }] };
|
||||
const data = [{ id: 1, name: 'test' }];
|
||||
mutations[types.SET_ALL_CONVERSATION](state, data);
|
||||
expect(state.allConversations).toEqual(data);
|
||||
});
|
||||
|
||||
it('set all conversation in reconnect if selected chat id and conversation id is the same', () => {
|
||||
const state = {
|
||||
allConversations: [{ id: 1, status: 'open' }],
|
||||
selectedChatId: 1,
|
||||
};
|
||||
const data = [{ id: 1, name: 'test', status: 'resolved' }];
|
||||
mutations[types.SET_ALL_CONVERSATION](state, data);
|
||||
expect(state.allConversations).toEqual(data);
|
||||
});
|
||||
|
||||
it('set all conversation in reconnect if selected chat id and conversation id is the same then do not update messages', () => {
|
||||
const state = {
|
||||
allConversations: [{ id: 1, messages: [{ id: 1, content: 'test' }] }],
|
||||
selectedChatId: 1,
|
||||
};
|
||||
const data = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'test',
|
||||
messages: [{ id: 1, content: 'updated message' }],
|
||||
},
|
||||
];
|
||||
const expected = [
|
||||
{ id: 1, name: 'test', messages: [{ id: 1, content: 'test' }] },
|
||||
];
|
||||
mutations[types.SET_ALL_CONVERSATION](state, data);
|
||||
expect(state.allConversations).toEqual(expected);
|
||||
});
|
||||
|
||||
it('set all conversation in reconnect if selected chat id and conversation id is not the same', () => {
|
||||
const state = {
|
||||
allConversations: [{ id: 1, status: 'open' }],
|
||||
selectedChatId: 2,
|
||||
};
|
||||
const data = [{ id: 1, name: 'test', status: 'resolved' }];
|
||||
mutations[types.SET_ALL_CONVERSATION](state, data);
|
||||
expect(state.allConversations).toEqual(data);
|
||||
});
|
||||
|
||||
it('set all conversation in reconnect if selected chat id and conversation id is not the same then update messages', () => {
|
||||
const state = {
|
||||
allConversations: [{ id: 1, messages: [{ id: 1, content: 'test' }] }],
|
||||
selectedChatId: 2,
|
||||
};
|
||||
const data = [
|
||||
{ id: 1, name: 'test', messages: [{ id: 1, content: 'tested' }] },
|
||||
];
|
||||
mutations[types.SET_ALL_CONVERSATION](state, data);
|
||||
expect(state.allConversations).toEqual(data);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#SET_ALL_ATTACHMENTS', () => {
|
||||
it('set all attachments', () => {
|
||||
const state = {
|
||||
@@ -411,4 +471,54 @@ describe('#mutations', () => {
|
||||
expect(state.contextMenuChatId).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#SET_CHAT_LIST_FILTERS', () => {
|
||||
it('set chat list filters', () => {
|
||||
const conversationFilters = {
|
||||
inboxId: 1,
|
||||
assigneeType: 'me',
|
||||
status: 'open',
|
||||
sortBy: 'created_at',
|
||||
page: 1,
|
||||
labels: ['label'],
|
||||
teamId: 1,
|
||||
conversationType: 'mention',
|
||||
};
|
||||
const state = { conversationFilters: conversationFilters };
|
||||
mutations[types.SET_CHAT_LIST_FILTERS](state, conversationFilters);
|
||||
expect(state.conversationFilters).toEqual(conversationFilters);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#UPDATE_CHAT_LIST_FILTERS', () => {
|
||||
it('update chat list filters', () => {
|
||||
const conversationFilters = {
|
||||
inboxId: 1,
|
||||
assigneeType: 'me',
|
||||
status: 'open',
|
||||
sortBy: 'created_at',
|
||||
page: 1,
|
||||
labels: ['label'],
|
||||
teamId: 1,
|
||||
conversationType: 'mention',
|
||||
};
|
||||
const state = { conversationFilters: conversationFilters };
|
||||
mutations[types.UPDATE_CHAT_LIST_FILTERS](state, {
|
||||
inboxId: 2,
|
||||
updatedWithin: 20,
|
||||
assigneeType: 'all',
|
||||
});
|
||||
expect(state.conversationFilters).toEqual({
|
||||
inboxId: 2,
|
||||
assigneeType: 'all',
|
||||
status: 'open',
|
||||
sortBy: 'created_at',
|
||||
page: 1,
|
||||
labels: ['label'],
|
||||
teamId: 1,
|
||||
conversationType: 'mention',
|
||||
updatedWithin: 20,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user