feat: Update the slack integration-flow to allow users to select the channel (#7637)

This commit is contained in:
Pranav Raj S
2023-07-28 14:50:30 -07:00
committed by GitHub
parent 4d8ba0148c
commit 9ddd428935
28 changed files with 593 additions and 131 deletions

View File

@@ -31,21 +31,42 @@ describe('#actions', () => {
describe('#connectSlack:', () => {
it('sends correct actions if API is success', async () => {
let data = { id: 'slack', enabled: true };
let data = { hooks: [{ id: 'slack', enabled: false }] };
axios.post.mockResolvedValue({ data: data });
await actions.connectSlack({ commit });
expect(commit.mock.calls).toEqual([
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdating: true }],
[types.SET_INTEGRATIONS_UI_FLAG, { isCreatingSlack: true }],
[types.ADD_INTEGRATION, data],
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdating: false }],
[types.SET_INTEGRATIONS_UI_FLAG, { isCreatingSlack: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.post.mockRejectedValue(errorMessage);
await actions.connectSlack({ commit });
await expect(actions.connectSlack({ commit })).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdating: true }],
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdating: false }],
[types.SET_INTEGRATIONS_UI_FLAG, { isCreatingSlack: true }],
[types.SET_INTEGRATIONS_UI_FLAG, { isCreatingSlack: false }],
]);
});
});
describe('#updateSlack', () => {
it('sends correct actions if API is success', async () => {
let data = { hooks: [{ id: 'slack', enabled: false }] };
axios.patch.mockResolvedValue({ data: data });
await actions.updateSlack({ commit }, { referenceId: '12345' });
expect(commit.mock.calls).toEqual([
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdatingSlack: true }],
[types.ADD_INTEGRATION, data],
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdatingSlack: false }],
]);
});
it('sends correct actions if API is error', async () => {
axios.patch.mockRejectedValue(errorMessage);
await expect(actions.updateSlack({ commit })).rejects.toThrow(Error);
expect(commit.mock.calls).toEqual([
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdatingSlack: true }],
[types.SET_INTEGRATIONS_UI_FLAG, { isUpdatingSlack: false }],
]);
});
});