From 245c63f216c1074f8857f123e1dfae9b2b2b29bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Tue, 4 Jun 2024 13:26:57 +0200 Subject: [PATCH] fix(editor): Skip disabled nodes when detecting workflow issues (#9610) --- cypress/e2e/7-workflow-actions.cy.ts | 103 +++++++++++------- cypress/pages/workflow.ts | 7 +- .../editor-ui/src/stores/workflows.store.ts | 4 +- 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/cypress/e2e/7-workflow-actions.cy.ts b/cypress/e2e/7-workflow-actions.cy.ts index bbb781c78e..ebbd39638f 100644 --- a/cypress/e2e/7-workflow-actions.cy.ts +++ b/cypress/e2e/7-workflow-actions.cy.ts @@ -6,6 +6,7 @@ import { EDIT_FIELDS_SET_NODE_NAME, INSTANCE_MEMBERS, INSTANCE_OWNER, + NOTION_NODE_NAME, } from '../constants'; import { WorkflowPage as WorkflowPageClass } from '../pages/workflow'; import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows'; @@ -53,6 +54,30 @@ describe('Workflow Actions', () => { WorkflowPage.getters.isWorkflowActivated(); }); + it('should not be be able to activate workflow when nodes have errors', () => { + WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME); + WorkflowPage.actions.addNodeToCanvas(NOTION_NODE_NAME); + WorkflowPage.actions.saveWorkflowOnButtonClick(); + WorkflowPage.getters.successToast().should('exist'); + WorkflowPage.actions.clickWorkflowActivator(); + WorkflowPage.getters.errorToast().should('exist'); + }); + + it('should be be able to activate workflow when nodes with errors are disabled', () => { + WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME); + WorkflowPage.actions.addNodeToCanvas(NOTION_NODE_NAME); + WorkflowPage.actions.saveWorkflowOnButtonClick(); + WorkflowPage.getters.successToast().should('exist'); + // First, try to activate the workflow with errors + WorkflowPage.actions.clickWorkflowActivator(); + WorkflowPage.getters.errorToast().should('exist'); + // Now, disable the node with errors + WorkflowPage.getters.canvasNodes().last().click(); + WorkflowPage.actions.hitDisableNodeShortcut(); + WorkflowPage.actions.activateWorkflow(); + WorkflowPage.getters.isWorkflowActivated(); + }); + it('should save new workflow after renaming', () => { WorkflowPage.actions.renameWorkflow(NEW_WORKFLOW_NAME); WorkflowPage.getters.isWorkflowSaved(); @@ -162,45 +187,47 @@ describe('Workflow Actions', () => { it('should update workflow settings', () => { cy.visit(WorkflowPages.url); - WorkflowPages.getters.workflowCards().then((cards) => { - const totalWorkflows = cards.length; + cy.intercept('GET', '/rest/workflows', (req) => { + req.on('response', (res) => { + const totalWorkflows = res.body.count ?? 0; - WorkflowPage.actions.visit(); - // Open settings dialog - WorkflowPage.actions.saveWorkflowOnButtonClick(); - WorkflowPage.getters.workflowMenu().should('be.visible'); - WorkflowPage.getters.workflowMenu().click(); - WorkflowPage.getters.workflowMenuItemSettings().should('be.visible'); - WorkflowPage.getters.workflowMenuItemSettings().click(); - // Change all settings - // totalWorkflows + 1 (current workflow) + 1 (no workflow option) - WorkflowPage.getters.workflowSettingsErrorWorkflowSelect().click(); - getVisibleSelect() - .find('li') - .should('have.length', totalWorkflows + 2); - getVisibleSelect().find('li').last().click({ force: true }); - WorkflowPage.getters.workflowSettingsTimezoneSelect().click(); - getVisibleSelect().find('li').should('exist'); - getVisibleSelect().find('li').eq(1).click({ force: true }); - WorkflowPage.getters.workflowSettingsSaveFiledExecutionsSelect().click(); - getVisibleSelect().find('li').should('have.length', 3); - getVisibleSelect().find('li').last().click({ force: true }); - WorkflowPage.getters.workflowSettingsSaveSuccessExecutionsSelect().click(); - getVisibleSelect().find('li').should('have.length', 3); - getVisibleSelect().find('li').last().click({ force: true }); - WorkflowPage.getters.workflowSettingsSaveManualExecutionsSelect().click(); - getVisibleSelect().find('li').should('have.length', 3); - getVisibleSelect().find('li').last().click({ force: true }); - WorkflowPage.getters.workflowSettingsSaveExecutionProgressSelect().click(); - getVisibleSelect().find('li').should('have.length', 3); - getVisibleSelect().find('li').last().click({ force: true }); - WorkflowPage.getters.workflowSettingsTimeoutWorkflowSwitch().click(); - WorkflowPage.getters.workflowSettingsTimeoutForm().find('input').first().type('1'); - // Save settings - WorkflowPage.getters.workflowSettingsSaveButton().click(); - WorkflowPage.getters.workflowSettingsModal().should('not.exist'); - WorkflowPage.getters.successToast().should('exist'); - }); + WorkflowPage.actions.visit(); + // Open settings dialog + WorkflowPage.actions.saveWorkflowOnButtonClick(); + WorkflowPage.getters.workflowMenu().should('be.visible'); + WorkflowPage.getters.workflowMenu().click(); + WorkflowPage.getters.workflowMenuItemSettings().should('be.visible'); + WorkflowPage.getters.workflowMenuItemSettings().click(); + // Change all settings + // totalWorkflows + 1 (current workflow) + 1 (no workflow option) + WorkflowPage.getters.workflowSettingsErrorWorkflowSelect().click(); + getVisibleSelect() + .find('li') + .should('have.length', totalWorkflows + 2); + getVisibleSelect().find('li').last().click({ force: true }); + WorkflowPage.getters.workflowSettingsTimezoneSelect().click(); + getVisibleSelect().find('li').should('exist'); + getVisibleSelect().find('li').eq(1).click({ force: true }); + WorkflowPage.getters.workflowSettingsSaveFiledExecutionsSelect().click(); + getVisibleSelect().find('li').should('have.length', 3); + getVisibleSelect().find('li').last().click({ force: true }); + WorkflowPage.getters.workflowSettingsSaveSuccessExecutionsSelect().click(); + getVisibleSelect().find('li').should('have.length', 3); + getVisibleSelect().find('li').last().click({ force: true }); + WorkflowPage.getters.workflowSettingsSaveManualExecutionsSelect().click(); + getVisibleSelect().find('li').should('have.length', 3); + getVisibleSelect().find('li').last().click({ force: true }); + WorkflowPage.getters.workflowSettingsSaveExecutionProgressSelect().click(); + getVisibleSelect().find('li').should('have.length', 3); + getVisibleSelect().find('li').last().click({ force: true }); + WorkflowPage.getters.workflowSettingsTimeoutWorkflowSwitch().click(); + WorkflowPage.getters.workflowSettingsTimeoutForm().find('input').first().type('1'); + // Save settings + WorkflowPage.getters.workflowSettingsSaveButton().click(); + WorkflowPage.getters.workflowSettingsModal().should('not.exist'); + WorkflowPage.getters.successToast().should('exist'); + }); + }).as('loadWorkflows'); }); it('should not be able to delete unsaved workflow', () => { diff --git a/cypress/pages/workflow.ts b/cypress/pages/workflow.ts index e5546f17b9..fa8867ce4e 100644 --- a/cypress/pages/workflow.ts +++ b/cypress/pages/workflow.ts @@ -298,10 +298,13 @@ export class WorkflowPage extends BasePage { this.getters.workflowNameInput().should('be.enabled'); this.getters.workflowNameInput().clear().type(name).type('{enter}'); }, - activateWorkflow: () => { - cy.intercept('PATCH', '/rest/workflows/*').as('activateWorkflow'); + clickWorkflowActivator: () => { this.getters.activatorSwitch().find('input').first().should('be.enabled'); this.getters.activatorSwitch().click(); + }, + activateWorkflow: () => { + cy.intercept('PATCH', '/rest/workflows/*').as('activateWorkflow'); + this.actions.clickWorkflowActivator(); cy.wait('@activateWorkflow'); cy.get('body').type('{esc}'); }, diff --git a/packages/editor-ui/src/stores/workflows.store.ts b/packages/editor-ui/src/stores/workflows.store.ts index 7d7826537f..c9b98b8a99 100644 --- a/packages/editor-ui/src/stores/workflows.store.ts +++ b/packages/editor-ui/src/stores/workflows.store.ts @@ -175,7 +175,9 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => { const nodesIssuesExist = computed(() => { for (const node of workflow.value.nodes) { - if (node.issues === undefined || Object.keys(node.issues).length === 0) { + const isNodeDisabled = node.disabled === true; + const noNodeIssues = node.issues === undefined || Object.keys(node.issues).length === 0; + if (isNodeDisabled || noNodeIssues) { continue; }