Feature: Add ability to disable auto assignment of conversations (#513)
This commit is contained in:
@@ -11,6 +11,7 @@ export const state = {
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isUpdatingAutoAssignment: false,
|
||||
isDeleting: false,
|
||||
},
|
||||
};
|
||||
@@ -76,6 +77,17 @@ export const actions = {
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
updateAutoAssignment: async ({ commit }, { id, ...inboxParams }) => {
|
||||
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 });
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false });
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
delete: async ({ commit }, inboxId) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isDeleting: true });
|
||||
try {
|
||||
|
||||
@@ -91,6 +91,31 @@ describe('#actions', () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#updateAutoAssignment', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
let 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} });
|
||||
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 }],
|
||||
]);
|
||||
});
|
||||
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} })
|
||||
).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdatingAutoAssignment: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#delete', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
|
||||
@@ -8,6 +8,7 @@ export default [
|
||||
page_id: '12345',
|
||||
widget_color: null,
|
||||
website_token: null,
|
||||
enable_auto_assignment: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@@ -18,6 +19,7 @@ export default [
|
||||
page_id: null,
|
||||
widget_color: '#7B64FF',
|
||||
website_token: 'randomid123',
|
||||
enable_auto_assignment: true,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
@@ -28,6 +30,7 @@ export default [
|
||||
page_id: null,
|
||||
widget_color: '#68BC00',
|
||||
website_token: 'randomid124',
|
||||
enable_auto_assignment: true,
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
@@ -38,5 +41,6 @@ export default [
|
||||
page_id: null,
|
||||
widget_color: '#68BC00',
|
||||
website_token: 'randomid125',
|
||||
enable_auto_assignment: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('#getters', () => {
|
||||
page_id: '12345',
|
||||
widget_color: null,
|
||||
website_token: null,
|
||||
enable_auto_assignment: true,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,6 +33,7 @@ describe('#getters', () => {
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isUpdatingAutoAssignment: false,
|
||||
isDeleting: false,
|
||||
},
|
||||
};
|
||||
@@ -40,6 +42,7 @@ describe('#getters', () => {
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isUpdating: false,
|
||||
isUpdatingAutoAssignment: false,
|
||||
isDeleting: false,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user