1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-08-16 16:40:30 +03:00

fix(editor): Prevent running workflows using keyboard shortcuts if execution is disabled (#9644)

This commit is contained in:
Milorad FIlipović 2024-06-06 10:41:40 +02:00 committed by GitHub
parent 7aea8243fe
commit e9e3b254fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -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', () => {

View File

@ -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: [] });