Feature: Availability Statuses (#874)

Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
Sojan Jose
2020-07-04 11:42:47 +05:30
committed by GitHub
parent bd87927576
commit c98907db49
35 changed files with 413 additions and 77 deletions

View File

@@ -93,4 +93,16 @@ describe('#actions', () => {
]);
});
});
describe('#updatePresence', () => {
it('sends correct actions if API is success', async () => {
const data = { users: { 1: 'online' }, contacts: { 2: 'online' } };
actions.updatePresence({ commit }, data);
expect(commit.mock.calls).toEqual([
[types.default.SET_AGENT_UPDATING_STATUS, true],
[types.default.UPDATE_AGENTS_PRESENCE, data],
[types.default.SET_AGENT_UPDATING_STATUS, false],
]);
});
});
});

View File

@@ -60,4 +60,40 @@ describe('#mutations', () => {
expect(state.records).toEqual([]);
});
});
describe('#UPDATE_AGENTS_PRESENCE', () => {
it('updates agent presence', () => {
const state = {
records: [
{
id: 1,
name: 'Agent1',
email: 'agent1@chatwoot.com',
availability_status: 'offline',
},
{
id: 2,
name: 'Agent1',
email: 'agent1@chatwoot.com',
availability_status: 'online',
},
],
};
mutations[types.default.UPDATE_AGENTS_PRESENCE](state, { '1': 'busy' });
expect(state.records).toEqual([
{
id: 1,
name: 'Agent1',
email: 'agent1@chatwoot.com',
availability_status: 'busy',
},
{
id: 2,
name: 'Agent1',
email: 'agent1@chatwoot.com',
},
]);
});
});
});