From 165b08de9b444e8e5e3bf9ab1426a2e3dca89d66 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Thu, 28 Mar 2024 19:03:43 -0400 Subject: [PATCH 1/3] fix issue when clicking outside of import workflow by url modal --- .../editor-ui/src/components/MainHeader/WorkflowDetails.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue index 8658b685e30b9..dc17c4acb96de 100644 --- a/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue +++ b/packages/editor-ui/src/components/MainHeader/WorkflowDetails.vue @@ -582,6 +582,10 @@ export default defineComponent({ }, )) as MessageBoxInputData; + if (promptResponse === 'cancel') { + return; + } + nodeViewEventBus.emit('importWorkflowUrl', { url: promptResponse.value }); } catch (e) {} break; From 46516441c0a27ccb027297723bc4851165660c2b Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Wed, 3 Apr 2024 17:19:44 +0200 Subject: [PATCH 2/3] add e2e tests --- cypress/e2e/39-import-workflow.cy.ts | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 cypress/e2e/39-import-workflow.cy.ts diff --git a/cypress/e2e/39-import-workflow.cy.ts b/cypress/e2e/39-import-workflow.cy.ts new file mode 100644 index 0000000000000..75ba5441b93d3 --- /dev/null +++ b/cypress/e2e/39-import-workflow.cy.ts @@ -0,0 +1,56 @@ +import { WorkflowPage } from '../pages'; +import { MessageBox as MessageBoxClass } from '../pages/modals/message-box'; + +const workflowPage = new WorkflowPage(); +const messageBox = new MessageBoxClass(); + +before(() => { + cy.fixture('Onboarding_workflow.json').then((data) => { + cy.intercept('GET', '/rest/workflows/from-url*', { + body: { data }, + }).as('downloadWorkflowFromURL'); + }); +}); + +describe('Import workflow', () => { + it('should allow importing workflow via URL', () => { + workflowPage.actions.visit(true); + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromURLItem().click(); + + messageBox.getters.modal().should('be.visible'); + + messageBox.getters.content().type('https://fakepage.com/workflow.json'); + + messageBox.getters.confirm().click(); + + workflowPage.actions.zoomToFit(); + + workflowPage.getters.canvasNodes().should('have.length', 4); + + workflowPage.getters.errorToast().should('not.exist'); + + workflowPage.getters.successToast().should('not.exist'); + }); + + it('clicking outside import workflow by URL modal should not show error toast', () => { + workflowPage.actions.visit(true); + + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromURLItem().click(); + + cy.get('body').click(0, 0); + + workflowPage.getters.errorToast().should('not.exist'); + }); + + it('canceling workflow by URL modal should not show error toast', () => { + workflowPage.actions.visit(true); + + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromURLItem().click(); + messageBox.getters.cancel().click(); + + workflowPage.getters.errorToast().should('not.exist'); + }); +}); From 0a399bdff99180334ae6bce0ba6ff9ba92b9a168 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Thu, 4 Apr 2024 10:57:32 +0200 Subject: [PATCH 3/3] reorganize tests --- cypress/e2e/39-import-workflow.cy.ts | 68 ++++++++++++++++++---------- cypress/e2e/7-workflow-actions.cy.ts | 26 ----------- 2 files changed, 43 insertions(+), 51 deletions(-) diff --git a/cypress/e2e/39-import-workflow.cy.ts b/cypress/e2e/39-import-workflow.cy.ts index 75ba5441b93d3..831228fba35d9 100644 --- a/cypress/e2e/39-import-workflow.cy.ts +++ b/cypress/e2e/39-import-workflow.cy.ts @@ -13,44 +13,62 @@ before(() => { }); describe('Import workflow', () => { - it('should allow importing workflow via URL', () => { - workflowPage.actions.visit(true); - workflowPage.getters.workflowMenu().click(); - workflowPage.getters.workflowMenuItemImportFromURLItem().click(); + describe('From URL', () => { + it('should import workflow', () => { + workflowPage.actions.visit(true); + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromURLItem().click(); - messageBox.getters.modal().should('be.visible'); + messageBox.getters.modal().should('be.visible'); - messageBox.getters.content().type('https://fakepage.com/workflow.json'); + messageBox.getters.content().type('https://fakepage.com/workflow.json'); - messageBox.getters.confirm().click(); + messageBox.getters.confirm().click(); - workflowPage.actions.zoomToFit(); + workflowPage.actions.zoomToFit(); - workflowPage.getters.canvasNodes().should('have.length', 4); + workflowPage.getters.canvasNodes().should('have.length', 4); - workflowPage.getters.errorToast().should('not.exist'); + workflowPage.getters.errorToast().should('not.exist'); - workflowPage.getters.successToast().should('not.exist'); - }); + workflowPage.getters.successToast().should('not.exist'); + }); - it('clicking outside import workflow by URL modal should not show error toast', () => { - workflowPage.actions.visit(true); + it('clicking outside modal should not show error toast', () => { + workflowPage.actions.visit(true); - workflowPage.getters.workflowMenu().click(); - workflowPage.getters.workflowMenuItemImportFromURLItem().click(); + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromURLItem().click(); - cy.get('body').click(0, 0); + cy.get('body').click(0, 0); - workflowPage.getters.errorToast().should('not.exist'); - }); + workflowPage.getters.errorToast().should('not.exist'); + }); - it('canceling workflow by URL modal should not show error toast', () => { - workflowPage.actions.visit(true); + it('canceling modal should not show error toast', () => { + workflowPage.actions.visit(true); - workflowPage.getters.workflowMenu().click(); - workflowPage.getters.workflowMenuItemImportFromURLItem().click(); - messageBox.getters.cancel().click(); + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromURLItem().click(); + messageBox.getters.cancel().click(); + + workflowPage.getters.errorToast().should('not.exist'); + }); + }); - workflowPage.getters.errorToast().should('not.exist'); + describe('From File', () => { + it('should import workflow', () => { + workflowPage.actions.visit(true); + + workflowPage.getters.workflowMenu().click(); + workflowPage.getters.workflowMenuItemImportFromFile().click(); + workflowPage.getters + .workflowImportInput() + .selectFile('cypress/fixtures/Test_workflow-actions_paste-data.json', { force: true }); + cy.waitForLoad(false); + workflowPage.actions.zoomToFit(); + workflowPage.getters.canvasNodes().should('have.length', 5); + workflowPage.getters.nodeConnections().should('have.length', 5); + }); }); }); diff --git a/cypress/e2e/7-workflow-actions.cy.ts b/cypress/e2e/7-workflow-actions.cy.ts index 0f6705bf349ef..347fc71a4f03d 100644 --- a/cypress/e2e/7-workflow-actions.cy.ts +++ b/cypress/e2e/7-workflow-actions.cy.ts @@ -13,8 +13,6 @@ import { getVisibleSelect } from '../utils'; import { WorkflowExecutionsTab } from '../pages'; const NEW_WORKFLOW_NAME = 'Something else'; -const IMPORT_WORKFLOW_URL = - 'https://gist.githubusercontent.com/OlegIvaniv/010bd3f45c8a94f8eb7012e663a8b671/raw/3afea1aec15573cc168d9af7e79395bd76082906/test-workflow.json'; const DUPLICATE_WORKFLOW_NAME = 'Duplicated workflow'; const DUPLICATE_WORKFLOW_TAG = 'Duplicate'; @@ -129,30 +127,6 @@ describe('Workflow Actions', () => { }); }); - it('should import workflow from url', () => { - WorkflowPage.getters.workflowMenu().should('be.visible'); - WorkflowPage.getters.workflowMenu().click(); - WorkflowPage.getters.workflowMenuItemImportFromURLItem().should('be.visible'); - WorkflowPage.getters.workflowMenuItemImportFromURLItem().click(); - cy.get('.el-message-box').should('be.visible'); - cy.get('.el-message-box').find('input').type(IMPORT_WORKFLOW_URL); - cy.get('body').type('{enter}'); - cy.waitForLoad(false); - WorkflowPage.actions.zoomToFit(); - WorkflowPage.getters.canvasNodes().should('have.length', 2); - WorkflowPage.getters.nodeConnections().should('have.length', 1); - }); - - it('should import workflow from file', () => { - WorkflowPage.getters - .workflowImportInput() - .selectFile('cypress/fixtures/Test_workflow-actions_paste-data.json', { force: true }); - cy.waitForLoad(false); - WorkflowPage.actions.zoomToFit(); - WorkflowPage.getters.canvasNodes().should('have.length', 5); - WorkflowPage.getters.nodeConnections().should('have.length', 5); - }); - it('should update workflow settings', () => { cy.visit(WorkflowPages.url); WorkflowPages.getters.workflowCards().then((cards) => {