From 8b0a48f53010378e497e4cc362fda75a958cf363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 25 Oct 2024 10:48:41 +0200 Subject: [PATCH] fix(editor): Prevent running workflow that has issues if listening to webhook (#11402) --- .../composables/__tests__/useRunWorkflow.spec.ts | 16 ++++++++++++++++ .../editor-ui/src/composables/useRunWorkflow.ts | 5 +++++ .../editor-ui/src/plugins/i18n/locales/en.json | 1 + 3 files changed, 22 insertions(+) diff --git a/packages/editor-ui/src/composables/__tests__/useRunWorkflow.spec.ts b/packages/editor-ui/src/composables/__tests__/useRunWorkflow.spec.ts index 608fc36e870e7..08fa852b3926e 100644 --- a/packages/editor-ui/src/composables/__tests__/useRunWorkflow.spec.ts +++ b/packages/editor-ui/src/composables/__tests__/useRunWorkflow.spec.ts @@ -23,6 +23,7 @@ vi.mock('@/stores/workflows.store', () => ({ getCurrentWorkflow: vi.fn().mockReturnValue({ id: '123' }), getNodeByName: vi.fn(), getExecution: vi.fn(), + nodeIssuesExit: vi.fn(), }), })); @@ -124,6 +125,21 @@ describe('useRunWorkflow({ router })', () => { expect(uiStore.addActiveAction).toHaveBeenCalledWith('workflowRunning'); }); + it('should prevent running a webhook-based workflow that has issues', async () => { + const { runWorkflowApi } = useRunWorkflow({ router }); + vi.mocked(workflowsStore).nodesIssuesExist = true; + vi.mocked(workflowsStore).runWorkflow.mockResolvedValue({ + executionId: '123', + waitingForWebhook: true, + }); + + await expect(runWorkflowApi({} as IStartRunData)).rejects.toThrow( + 'workflowRun.showError.resolveOutstandingIssues', + ); + + vi.mocked(workflowsStore).nodesIssuesExist = false; + }); + it('should handle workflow run failure', async () => { const { runWorkflowApi } = useRunWorkflow({ router }); diff --git a/packages/editor-ui/src/composables/useRunWorkflow.ts b/packages/editor-ui/src/composables/useRunWorkflow.ts index 8369921f8a119..658e35b3c6229 100644 --- a/packages/editor-ui/src/composables/useRunWorkflow.ts +++ b/packages/editor-ui/src/composables/useRunWorkflow.ts @@ -81,6 +81,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType