feat: Add ability to create a new conversation if the previous conversation is resolved (#2512)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Muhsin Keloth
2021-06-30 21:09:44 +05:30
committed by GitHub
parent e6e9916fdb
commit f0f66c7da6
13 changed files with 119 additions and 16 deletions

View File

@@ -5,10 +5,10 @@ const commit = jest.fn();
jest.mock('widget/helpers/axios');
describe('#actions', () => {
describe('#update', () => {
describe('#get attributes', () => {
it('sends mutation if api is success', async () => {
API.get.mockResolvedValue({ data: { id: 1, status: 'bot' } });
await actions.get({ commit });
await actions.getAttributes({ commit });
expect(commit.mock.calls).toEqual([
['SET_CONVERSATION_ATTRIBUTES', { id: 1, status: 'bot' }],
['conversation/setMetaUserLastSeenAt', undefined, { root: true }],
@@ -16,12 +16,12 @@ describe('#actions', () => {
});
it('doesnot send mutation if api is error', async () => {
API.get.mockRejectedValue({ message: 'Invalid Headers' });
await actions.get({ commit });
await actions.getAttributes({ commit });
expect(commit.mock.calls).toEqual([]);
});
});
describe('#update', () => {
describe('#update attributes', () => {
it('sends correct mutations', () => {
actions.update({ commit }, { id: 1, status: 'bot' });
expect(commit).toBeCalledWith('UPDATE_CONVERSATION_ATTRIBUTES', {
@@ -30,4 +30,10 @@ describe('#actions', () => {
});
});
});
describe('#clear attributes', () => {
it('sends correct mutations', () => {
actions.clearConversationAttributes({ commit });
expect(commit).toBeCalledWith('CLEAR_CONVERSATION_ATTRIBUTES');
});
});
});

View File

@@ -30,4 +30,15 @@ describe('#mutations', () => {
expect(state).toEqual({ id: 1, status: 'bot' });
});
});
describe('#CLEAR_CONVERSATION_ATTRIBUTES', () => {
it('clear status if it is same conversation', () => {
const state = { id: 1, status: 'open' };
mutations.CLEAR_CONVERSATION_ATTRIBUTES(state, {
id: 1,
status: 'open',
});
expect(state).toEqual({ id: '', status: '' });
});
});
});