Skip to content

Commit

Permalink
fix(editor): Prevent running workflows using keyboard shortcuts if ex…
Browse files Browse the repository at this point in the history
…ecution is disabled (#9644)
  • Loading branch information
MiloradFilipovic authored Jun 6, 2024
1 parent 7aea824 commit e9e3b25
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions cypress/e2e/7-workflow-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: [] });
Expand Down

0 comments on commit e9e3b25

Please sign in to comment.