Bugfix: Use server timestamp to set agent_last_seen_at (#1114)
This commit is contained in:
@@ -153,4 +153,28 @@ describe('#actions', () => {
|
||||
expect(commit.mock.calls).toEqual([[types.default.ADD_MESSAGE, message]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#markMessagesRead', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
it('sends correct mutations if api is successful', async () => {
|
||||
const lastSeen = new Date().getTime() / 1000;
|
||||
axios.post.mockResolvedValue({
|
||||
data: { id: 1, agent_last_seen_at: lastSeen },
|
||||
});
|
||||
await actions.markMessagesRead({ commit }, { id: 1 });
|
||||
jest.runAllTimers();
|
||||
expect(commit).toHaveBeenCalledTimes(1);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.MARK_MESSAGE_READ, { id: 1, lastSeen }],
|
||||
]);
|
||||
});
|
||||
it('sends correct mutations if api is unsuccessful', async () => {
|
||||
axios.post.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await actions.markMessagesRead({ commit }, { id: 1 });
|
||||
expect(commit.mock.calls).toEqual([]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,6 +20,13 @@ describe('#mutations', () => {
|
||||
{ id: 1, agent_last_seen_at: lastSeen },
|
||||
]);
|
||||
});
|
||||
|
||||
it('doesnot send any mutation if chat doesnot exist', () => {
|
||||
const state = { allConversations: [] };
|
||||
const lastSeen = new Date().getTime() / 1000;
|
||||
mutations[types.MARK_MESSAGE_READ](state, { id: 1, lastSeen });
|
||||
expect(state.allConversations).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#CLEAR_CURRENT_CHAT_WINDOW', () => {
|
||||
|
||||
Reference in New Issue
Block a user