From e9e3b254fe10e6b9b1783e931caadf792866d3fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Thu, 6 Jun 2024 10:41:40 +0200 Subject: [PATCH] fix(editor): Prevent running workflows using keyboard shortcuts if execution is disabled (#9644) --- cypress/e2e/7-workflow-actions.cy.ts | 27 +++++++++++++++++++++++ packages/editor-ui/src/views/NodeView.vue | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/7-workflow-actions.cy.ts b/cypress/e2e/7-workflow-actions.cy.ts index ebbd39638f..c0875d93f7 100644 --- a/cypress/e2e/7-workflow-actions.cy.ts +++ b/cypress/e2e/7-workflow-actions.cy.ts @@ -312,6 +312,33 @@ describe('Workflow Actions', () => { WorkflowPage.getters.canvasNodePlusEndpointByName(EDIT_FIELDS_SET_NODE_NAME).click(); WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible'); }); + + it('should run workflow on button click', () => { + WorkflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME); + WorkflowPage.actions.saveWorkflowOnButtonClick(); + WorkflowPage.getters.executeWorkflowButton().click(); + WorkflowPage.getters.successToast().should('contain.text', 'Workflow executed successfully'); + }); + + it('should run workflow using keyboard shortcut', () => { + WorkflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME); + WorkflowPage.actions.saveWorkflowOnButtonClick(); + cy.get('body').type(META_KEY, { delay: 500, release: false }).type('{enter}'); + WorkflowPage.getters.successToast().should('contain.text', 'Workflow executed successfully'); + }); + + it('should not run empty workflows', () => { + // Clear the canvas + cy.get('body').type(META_KEY, { delay: 500, release: false }).type('a'); + cy.get('body').type('{backspace}'); + WorkflowPage.getters.canvasNodes().should('have.length', 0); + // Button should be disabled + WorkflowPage.getters.executeWorkflowButton().should('be.disabled'); + // Keyboard shortcut should not work + cy.get('body').type(META_KEY, { delay: 500, release: false }).type('{enter}'); + WorkflowPage.getters.successToast().should('not.exist'); + }); + }); describe('Menu entry Push To Git', () => { diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index fede51abc6..a978e3c594 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1643,7 +1643,7 @@ export default defineComponent({ source: NODE_CREATOR_OPEN_SOURCES.TAB, createNodeActive: !this.createNodeActive && !this.isReadOnlyRoute && !this.readOnlyEnv, }); - } else if (e.key === 'Enter' && ctrlModifier && !readOnly) { + } else if (e.key === 'Enter' && ctrlModifier && !readOnly && !this.isExecutionDisabled) { void this.onRunWorkflow(); } else if (e.key === 'S' && shiftModifier && !readOnly) { void this.onAddNodes({ nodes: [{ type: STICKY_NODE_TYPE }], connections: [] });