feat: Add an option to edit webhook URL (#2316)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Muhsin Keloth
2021-06-06 16:59:47 +05:30
committed by GitHub
parent 14b51e108a
commit 94a83ea995
8 changed files with 233 additions and 33 deletions

View File

@@ -52,6 +52,30 @@ describe('#actions', () => {
});
});
describe('#update', () => {
it('sends correct actions if API is success', async () => {
axios.patch.mockResolvedValue({
data: { payload: { webhook: webhooks[1] } },
});
await actions.update({ commit }, webhooks[1]);
expect(commit.mock.calls).toEqual([
[types.default.SET_WEBHOOK_UI_FLAG, { updatingItem: true }],
[types.default.UPDATE_WEBHOOK, webhooks[1]],
[types.default.SET_WEBHOOK_UI_FLAG, { updatingItem: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.put.mockRejectedValue({ message: 'Incorrect header' });
await expect(actions.update({ commit }, webhooks[0])).rejects.toThrow(
Error
);
expect(commit.mock.calls).toEqual([
[types.default.SET_WEBHOOK_UI_FLAG, { updatingItem: true }],
[types.default.SET_WEBHOOK_UI_FLAG, { updatingItem: false }],
]);
});
});
describe('#delete', () => {
it('sends correct actions if API is success', async () => {
axios.delete.mockResolvedValue({ data: webhooks[0] });

View File

@@ -30,4 +30,14 @@ describe('#mutations', () => {
expect(state.records).toEqual([]);
});
});
describe('#UPDATE_WEBHOOK', () => {
it('update webhook ', () => {
const state = {
records: [webhooks[0]],
};
mutations[types.default.UPDATE_WEBHOOK](state, webhooks[0]);
expect(state.records[0].url).toEqual('https://1.chatwoot.com');
});
});
});