Chore: Web widget Inbox Tech Debts (#738)
* Chore: Webwidget Inbox Tech Debts * Additional customization options creating Web Widget * Changes to edit Page for Web Widget * Remove the WebWidget API end points * Minor chores Address: #680, #502 Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
@@ -79,18 +79,7 @@ export const actions = {
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
updateWebsiteChannel: async ({ commit }, { id, ...inboxParams }) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdating: true });
|
||||
try {
|
||||
const response = await WebChannel.update(id, inboxParams);
|
||||
commit(types.default.EDIT_INBOXES, response.data);
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdating: false });
|
||||
} catch (error) {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, { isUpdating: false });
|
||||
throw new Error(error);
|
||||
}
|
||||
},
|
||||
updateAutoAssignment: async ({ commit }, { id, ...inboxParams }) => {
|
||||
updateInbox: async ({ commit }, { id, ...inboxParams }) => {
|
||||
commit(types.default.SET_INBOXES_UI_FLAG, {
|
||||
isUpdatingAutoAssignment: true,
|
||||
});
|
||||
|
||||
@@ -70,35 +70,13 @@ describe('#actions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#updateWebsiteChannel', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.patch.mockResolvedValue({ data: inboxList[0] });
|
||||
await actions.updateWebsiteChannel({ commit }, inboxList[0]);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.EDIT_INBOXES, inboxList[0]],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(
|
||||
actions.updateWebsiteChannel({ commit }, inboxList[0])
|
||||
).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: true }],
|
||||
[types.default.SET_INBOXES_UI_FLAG, { isUpdating: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#updateAutoAssignment', () => {
|
||||
describe('#updateInbox', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
const updatedInbox = inboxList[0];
|
||||
updatedInbox.enable_auto_assignment = false;
|
||||
|
||||
axios.patch.mockResolvedValue({ data: updatedInbox });
|
||||
await actions.updateAutoAssignment(
|
||||
await actions.updateInbox(
|
||||
{ commit },
|
||||
{ id: updatedInbox.id, inbox: { enable_auto_assignment: false } }
|
||||
);
|
||||
@@ -114,7 +92,7 @@ describe('#actions', () => {
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.patch.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(
|
||||
actions.updateAutoAssignment(
|
||||
actions.updateInbox(
|
||||
{ commit },
|
||||
{ id: inboxList[0].id, inbox: { enable_auto_assignment: false } }
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user