Skip to content

Commit 3b3a9f5

Browse files
authored
[UiActions] Don't throw an error if there are no compatible actions to execute (#78917) (#78939)
1 parent efb5c25 commit 3b3a9f5

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/plugins/ui_actions/public/tests/execute_trigger_actions.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { openContextMenu } from '../context_menu';
2222
import { uiActionsPluginMock } from '../mocks';
2323
import { Trigger } from '../triggers';
2424
import { TriggerId, ActionType } from '../types';
25-
import { wait } from '@testing-library/dom';
25+
import { waitFor } from '@testing-library/dom';
2626

2727
jest.mock('../context_menu');
2828

@@ -85,7 +85,7 @@ test('executes a single action mapped to a trigger', async () => {
8585
expect(executeFn).toBeCalledWith(expect.objectContaining(context));
8686
});
8787

88-
test('throws an error if there are no compatible actions to execute', async () => {
88+
test("doesn't throw an error if there are no compatible actions to execute", async () => {
8989
const { setup, doStart } = uiActions;
9090
const trigger: Trigger = {
9191
id: 'MY-TRIGGER' as TriggerId,
@@ -98,9 +98,7 @@ test('throws an error if there are no compatible actions to execute', async () =
9898
const start = doStart();
9999
await expect(
100100
start.executeTriggerActions('MY-TRIGGER' as TriggerId, context)
101-
).rejects.toMatchObject(
102-
new Error('No compatible actions found to execute for trigger [triggerId = MY-TRIGGER].')
103-
);
101+
).resolves.toBeUndefined();
104102
});
105103

106104
test('does not execute an incompatible action', async () => {
@@ -149,7 +147,7 @@ test('shows a context menu when more than one action is mapped to a trigger', as
149147

150148
jest.runAllTimers();
151149

152-
await wait(() => {
150+
await waitFor(() => {
153151
expect(executeFn).toBeCalledTimes(0);
154152
expect(openContextMenu).toHaveBeenCalledTimes(1);
155153
});
@@ -197,7 +195,7 @@ test("doesn't show a context menu for auto executable actions", async () => {
197195

198196
jest.runAllTimers();
199197

200-
await wait(() => {
198+
await waitFor(() => {
201199
expect(executeFn).toBeCalledTimes(2);
202200
expect(openContextMenu).toHaveBeenCalledTimes(0);
203201
});

src/plugins/ui_actions/public/triggers/trigger_internal.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ export class TriggerInternal<T extends TriggerId> {
3535
const triggerId = this.trigger.id;
3636
const actions = await this.service.getTriggerCompatibleActions!(triggerId, context);
3737

38-
if (!actions.length) {
39-
throw new Error(
40-
`No compatible actions found to execute for trigger [triggerId = ${triggerId}].`
41-
);
42-
}
43-
4438
await Promise.all([
4539
actions.map((action) =>
4640
this.service.executionService.execute({

0 commit comments

Comments
 (0)