diff --git a/webapp/channels/src/actions/views/create_comment.test.jsx b/webapp/channels/src/actions/views/create_comment.test.jsx index c52c1808c6..948b4ff475 100644 --- a/webapp/channels/src/actions/views/create_comment.test.jsx +++ b/webapp/channels/src/actions/views/create_comment.test.jsx @@ -243,6 +243,16 @@ describe('rhs view actions', () => { expect(executeCommand).not.toHaveBeenCalled(); }); + test('it should not error in case of an empty response', async () => { + HookActions.runSlashCommandWillBePostedHooks.mockImplementation(() => () => ({data: {}})); + + const res = await store.dispatch(submitCommand(channelId, rootId, draft)); + expect(res).toStrictEqual({}); + + expect(HookActions.runSlashCommandWillBePostedHooks).toHaveBeenCalled(); + expect(executeCommand).not.toHaveBeenCalled(); + }); + test('it calls submitPost on error.sendMessage', async () => { jest.mock('actions/channel_actions', () => ({ executeCommand: jest.fn((message, _args, resolve, reject) => reject({sendMessage: 'test'})), diff --git a/webapp/channels/src/actions/views/create_comment.tsx b/webapp/channels/src/actions/views/create_comment.tsx index 5bf9585d32..b988340e68 100644 --- a/webapp/channels/src/actions/views/create_comment.tsx +++ b/webapp/channels/src/actions/views/create_comment.tsx @@ -110,7 +110,10 @@ export function submitCommand(channelId: string, rootId: string, draft: PostDraf return {error: hookResult.error}; } else if (!hookResult.data!.message && !hookResult.data!.args) { // do nothing with an empty return from a hook - return {error: new Error('command not submitted due to plugin hook')}; + // this is allowed by the registerSlashCommandWillBePostedHook API in case + // a plugin intercepts and handles the command on the client side + // but doesn't require it to be sent to the server. (e.g., /call start). + return {}; } message = hookResult.data!.message;