From d937e5abe8233988b209cd1eb7a94938a9e042fb Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Fri, 13 Dec 2024 16:48:56 +0100 Subject: [PATCH] chore: Update NDV e2e tests for Canvas V2 (#12214) --- cypress/e2e/5-ndv.cy.ts | 29 +++++++++++++++++++++++++++-- cypress/pages/workflow.ts | 10 ++++++++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/cypress/e2e/5-ndv.cy.ts b/cypress/e2e/5-ndv.cy.ts index 9da1338233..a10dbc94e6 100644 --- a/cypress/e2e/5-ndv.cy.ts +++ b/cypress/e2e/5-ndv.cy.ts @@ -111,6 +111,7 @@ describe('NDV', () => { cy.get('[class*=hasIssues]').should('have.length', 1); }); + // Correctly failing in V2 - node issues are only shows after execution it('should show all validation errors when opening pasted node', () => { cy.createFixtureWorkflow('Test_workflow_ndv_errors.json', 'Validation errors'); workflowPage.getters.canvasNodes().should('have.have.length', 1); @@ -213,9 +214,11 @@ describe('NDV', () => { .should('not.be.visible'); }); }); + it('should not display pagination for schema', () => { setupSchemaWorkflow(); ndv.getters.backToCanvas().click(); + workflowPage.actions.deselectAll(); workflowPage.getters.canvasNodeByName('Set').click(); workflowPage.actions.addNodeToCanvas( 'Customer Datastore (n8n training)', @@ -407,8 +410,18 @@ describe('NDV', () => { return cy.get(`[data-node-placement=${position}]`); } + // Correctly failing in V2 - due to floating navigation not updating the selected node it('should traverse floating nodes with mouse', () => { cy.createFixtureWorkflow('Floating_Nodes.json', 'Floating Nodes'); + + cy.ifCanvasVersion( + () => {}, + () => { + // Needed in V2 as all nodes remain selected when clicking on a selected node + workflowPage.actions.deselectAll(); + }, + ); + workflowPage.getters.canvasNodes().first().dblclick(); getFloatingNodeByPosition('inputMain').should('not.exist'); getFloatingNodeByPosition('outputMain').should('exist'); @@ -419,6 +432,7 @@ describe('NDV', () => { getFloatingNodeByPosition('inputMain').should('exist'); getFloatingNodeByPosition('outputMain').should('exist'); ndv.actions.close(); + // These two lines are broken in V2 workflowPage.getters.selectedNodes().should('have.length', 1); workflowPage.getters .selectedNodes() @@ -426,10 +440,8 @@ describe('NDV', () => { .should('contain', `Node ${i + 1}`); workflowPage.getters.selectedNodes().first().dblclick(); }); - getFloatingNodeByPosition('outputMain').click({ force: true }); ndv.getters.nodeNameContainer().should('contain', 'Chain'); - // Traverse 4 connected node backwards Array.from(Array(4).keys()).forEach((i) => { getFloatingNodeByPosition('inputMain').click({ force: true }); @@ -453,8 +465,17 @@ describe('NDV', () => { .should('contain', MANUAL_TRIGGER_NODE_DISPLAY_NAME); }); + // Correctly failing in V2 - due to floating navigation not updating the selected node it('should traverse floating nodes with keyboard', () => { cy.createFixtureWorkflow('Floating_Nodes.json', 'Floating Nodes'); + cy.ifCanvasVersion( + () => {}, + () => { + // Needed in V2 as all nodes remain selected when clicking on a selected node + workflowPage.actions.deselectAll(); + }, + ); + workflowPage.getters.canvasNodes().first().dblclick(); getFloatingNodeByPosition('inputMain').should('not.exist'); getFloatingNodeByPosition('outputMain').should('exist'); @@ -465,6 +486,7 @@ describe('NDV', () => { getFloatingNodeByPosition('inputMain').should('exist'); getFloatingNodeByPosition('outputMain').should('exist'); ndv.actions.close(); + // These two lines are broken in V2 workflowPage.getters.selectedNodes().should('have.length', 1); workflowPage.getters .selectedNodes() @@ -492,6 +514,7 @@ describe('NDV', () => { getFloatingNodeByPosition('inputSub').should('not.exist'); getFloatingNodeByPosition('outputSub').should('not.exist'); ndv.actions.close(); + // These two lines are broken in V2 workflowPage.getters.selectedNodes().should('have.length', 1); workflowPage.getters .selectedNodes() @@ -717,6 +740,7 @@ describe('NDV', () => { .should('have.value', 'Error fetching options from Notion'); }); + // Correctly failing in V2 - NodeCreator is not opened after clicking on the link it('Should open appropriate node creator after clicking on connection hint link', () => { const nodeCreator = new NodeCreator(); const hintMapper = { @@ -734,6 +758,7 @@ describe('NDV', () => { Object.entries(hintMapper).forEach(([node, group]) => { workflowPage.actions.openNode(node); + // This fails to open the NodeCreator cy.get('[data-action=openSelectiveNodeCreator]').contains('Insert one').click(); nodeCreator.getters.activeSubcategory().should('contain', group); cy.realPress('Escape'); diff --git a/cypress/pages/workflow.ts b/cypress/pages/workflow.ts index 86af76189d..1b63688da1 100644 --- a/cypress/pages/workflow.ts +++ b/cypress/pages/workflow.ts @@ -333,8 +333,14 @@ export class WorkflowPage extends BasePage { this.actions.contextMenuAction('select_all'); }, deselectAll: () => { - this.actions.openContextMenu(); - this.actions.contextMenuAction('deselect_all'); + cy.ifCanvasVersion( + () => { + this.actions.openContextMenu(); + this.actions.contextMenuAction('deselect_all'); + }, + // rightclick doesn't work with vueFlow canvas + () => this.getters.nodeViewBackground().click('topLeft'), + ); }, openExpressionEditorModal: () => { cy.contains('Expression').invoke('show').click();