Revert breaking change in registerSlashCommandWillBePostedHook (#28914)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
108efac918
Коммит
b94963d830
@@ -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'})),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Ссылка в новой задаче
Block a user