From 55f2ffe256c91a028cee95c3bbb37a093a1c0f81 Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Fri, 2 Aug 2024 16:05:17 +0200 Subject: [PATCH] fix(editor): Fix execution retry button (#10275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ --- .../workflow/WorkflowExecutionsCard.test.ts | 2 +- .../__tests__/useExecutionHelpers.test.ts | 21 +++++++++++++++++++ .../src/composables/useExecutionHelpers.ts | 6 +----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/editor-ui/src/components/executions/workflow/WorkflowExecutionsCard.test.ts b/packages/editor-ui/src/components/executions/workflow/WorkflowExecutionsCard.test.ts index ec85066474..2d5449e93d 100644 --- a/packages/editor-ui/src/components/executions/workflow/WorkflowExecutionsCard.test.ts +++ b/packages/editor-ui/src/components/executions/workflow/WorkflowExecutionsCard.test.ts @@ -51,7 +51,7 @@ describe('WorkflowExecutionsCard', () => { retryOf: '2', retrySuccessId: null, }, - false, + true, ], [ { diff --git a/packages/editor-ui/src/composables/__tests__/useExecutionHelpers.test.ts b/packages/editor-ui/src/composables/__tests__/useExecutionHelpers.test.ts index 29bd64ea42..465abeb173 100644 --- a/packages/editor-ui/src/composables/__tests__/useExecutionHelpers.test.ts +++ b/packages/editor-ui/src/composables/__tests__/useExecutionHelpers.test.ts @@ -47,4 +47,25 @@ describe('useExecutionHelpers()', () => { ); }); }); + + describe('isExecutionRetriable', () => { + const { isExecutionRetriable } = useExecutionHelpers(); + + it.each(['crashed', 'error'])('returns true when execution status is %s', (status) => { + expect(isExecutionRetriable({ status } as ExecutionSummary)).toEqual(true); + }); + + it.each(['canceled', 'new', 'running', 'success', 'unknown', 'waiting'])( + 'returns false when execution status is %s', + (status) => { + expect(isExecutionRetriable({ status } as ExecutionSummary)).toEqual(false); + }, + ); + + it('should return false if retrySuccessId is set', () => { + expect( + isExecutionRetriable({ status: 'crashed', retrySuccessId: '123' } as ExecutionSummary), + ).toEqual(false); + }); + }); }); diff --git a/packages/editor-ui/src/composables/useExecutionHelpers.ts b/packages/editor-ui/src/composables/useExecutionHelpers.ts index a00f5b639a..9740f8dc06 100644 --- a/packages/editor-ui/src/composables/useExecutionHelpers.ts +++ b/packages/editor-ui/src/composables/useExecutionHelpers.ts @@ -62,11 +62,7 @@ export function useExecutionHelpers() { } function isExecutionRetriable(execution: ExecutionSummary): boolean { - return ( - ['crashed', 'error'].includes(execution.status) && - !execution.retryOf && - !execution.retrySuccessId - ); + return ['crashed', 'error'].includes(execution.status) && !execution.retrySuccessId; } return {