mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
Enhancement: Upgrade @babel/preset-env (#542)
This commit is contained in:
@@ -11,7 +11,8 @@ export default {
|
||||
return m.messages.filter(
|
||||
chat =>
|
||||
chat.created_at * 1000 > m.agent_last_seen_at * 1000 &&
|
||||
(chat.message_type === 0 && chat.private !== true)
|
||||
chat.message_type === 0 &&
|
||||
chat.private !== true
|
||||
).length;
|
||||
},
|
||||
readMessages(m) {
|
||||
|
||||
@@ -42,7 +42,8 @@ const getters = {
|
||||
return chat.messages.filter(
|
||||
chatMessage =>
|
||||
chatMessage.created_at * 1000 > chat.agent_last_seen_at * 1000 &&
|
||||
(chatMessage.message_type === 0 && chatMessage.private !== true)
|
||||
chatMessage.message_type === 0 &&
|
||||
chatMessage.private !== true
|
||||
).length;
|
||||
},
|
||||
getChatStatusFilter: ({ chatStatusFilter }) => chatStatusFilter,
|
||||
|
||||
@@ -78,13 +78,19 @@ export const actions = {
|
||||
}
|
||||
},
|
||||
updateAutoAssignment: async ({ commit }, { id, ...inboxParams }) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true });
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, {
|
||||
isUpdatingAutoAssignment: true,
|
||||
});
|
||||
try {
|
||||
const response = await InboxesAPI.update(id, inboxParams);
|
||||
commit(types.default.EDIT_INBOXES, response.data);
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false });
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, {
|
||||
isUpdatingAutoAssignment: false,
|
||||
});
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false });
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, {
|
||||
isUpdatingAutoAssignment: false,
|
||||
});
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -91,28 +91,40 @@ describe('#actions', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('#updateAutoAssignment', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
let updatedInbox = inboxList[0];
|
||||
const updatedInbox = inboxList[0];
|
||||
updatedInbox.enable_auto_assignment = false;
|
||||
|
||||
axios.patch.mockResolvedValue({ data: updatedInbox });
|
||||
await actions.updateAutoAssignment({ commit }, { id: updatedInbox.id, inbox: { enable_auto_assignment: false} });
|
||||
await actions.updateAutoAssignment(
|
||||
{ commit },
|
||||
{ id: updatedInbox.id, inbox: { enable_auto_assignment: false } }
|
||||
);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true }],
|
||||
[types.default.EDIT_INBOXES, updatedInbox],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false }],
|
||||
[
|
||||
types.default.SET_INBOXES_UI_FLAG,
|
||||
{ isUpdatingAutoAssignment: false },
|
||||
],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(
|
||||
actions.updateAutoAssignment({ commit }, { id: inboxList[0].id, inbox: { enable_auto_assignment: false} })
|
||||
actions.updateAutoAssignment(
|
||||
{ commit },
|
||||
{ id: inboxList[0].id, inbox: { enable_auto_assignment: false } }
|
||||
)
|
||||
).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false }],
|
||||
[
|
||||
types.default.SET_INBOXES_UI_FLAG,
|
||||
{ isUpdatingAutoAssignment: false },
|
||||
],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user