From 62d30f2b43558e16f8f0b2716f73f80cfee54d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 25 Nov 2022 13:09:44 +0100 Subject: [PATCH] test: Set up e2e tests for HTTP Request node (#4718) * :test_tube: Add test identifiers * :zap: Add getters * :test_tube: Add initial test * :zap: Refactor to use actions * :zap: Refactor per Oleg's advice * :bug: Fix overlapping input label IDs --- cypress/e2e/4-http-request-node.cy.ts | 23 ++++++++++ cypress/pages/workflow.ts | 43 ++++++++++++++++++- cypress/pages/workflows.ts | 6 +++ packages/editor-ui/src/components/Node.vue | 4 +- .../src/components/Node/NodeCreation.vue | 2 +- .../components/Node/NodeCreator/SearchBar.vue | 1 + .../src/components/NodeDetailsView.vue | 1 + .../src/components/ParameterInputExpanded.vue | 1 + .../src/components/ParameterInputWrapper.vue | 4 +- .../editor-ui/src/views/CanvasAddButton.vue | 2 +- 10 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 cypress/e2e/4-http-request-node.cy.ts diff --git a/cypress/e2e/4-http-request-node.cy.ts b/cypress/e2e/4-http-request-node.cy.ts new file mode 100644 index 0000000000..3ba914b1aa --- /dev/null +++ b/cypress/e2e/4-http-request-node.cy.ts @@ -0,0 +1,23 @@ +import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows'; +import { WorkflowPage as WorkflowPageClass } from '../pages/workflow'; + +const WorkflowsPage = new WorkflowsPageClass(); +const WorkflowPage = new WorkflowPageClass(); + +describe('HTTP Request node', () => { + beforeEach(() => { + cy.skipSetup(); + }); + + it('should make a request with a URL and receive a response', () => { + WorkflowsPage.actions.createWorkflowFromCard(); + WorkflowPage.actions.addInitialNodeToCanvas('Manual Trigger'); + WorkflowPage.actions.addNodeToCanvas('HTTP Request'); + WorkflowPage.actions.openNodeNdv('HTTP Request'); + WorkflowPage.actions.typeIntoParameterInput('url', 'https://google.com'); + + WorkflowPage.actions.executeNodeFromNdv(); + + WorkflowPage.getters.ndvOutputPanel().contains(''); + }); +}); diff --git a/cypress/pages/workflow.ts b/cypress/pages/workflow.ts index 538a4086aa..f6326f837e 100644 --- a/cypress/pages/workflow.ts +++ b/cypress/pages/workflow.ts @@ -1,11 +1,50 @@ -import { BasePage } from "./base"; +import { BasePage } from './base'; export class WorkflowPage extends BasePage { url = '/workflow/new'; getters = { - workflowNameInput: () => cy.getByTestId('workflow-name-input', { timeout: 5000 }).then($el => cy.wrap($el.find('input'))), + workflowNameInput: () => + cy + .getByTestId('workflow-name-input', { timeout: 5000 }) + .then(($el) => cy.wrap($el.find('input'))), workflowImportInput: () => cy.getByTestId('workflow-import-input'), workflowTags: () => cy.getByTestId('workflow-tags'), saveButton: () => cy.getByTestId('save-button'), + + nodeCreatorSearchBar: () => cy.getByTestId('node-creator-search-bar'), + nodeCreatorPlusButton: () => cy.getByTestId('node-creator-plus-button'), + canvasPlusButton: () => cy.getByTestId('canvas-plus-button'), + canvasNodeBox: (nodeDisplayName: string) => { + return cy + .getByTestId('canvas-node-box-title') + .contains(nodeDisplayName) + .parents('[data-test-id="canvas-node-box"]'); + }, + + ndvParameterInput: (parameterName: string) => + cy.getByTestId(`parameter-input-${parameterName}`), + ndvOutputPanel: () => cy.getByTestId('output-panel'), + }; + + actions = { + addInitialNodeToCanvas: (nodeDisplayName: string) => { + this.getters.canvasPlusButton().click(); + this.getters.nodeCreatorSearchBar().type(nodeDisplayName); + this.getters.nodeCreatorSearchBar().type('{enter}{esc}'); + }, + addNodeToCanvas: (nodeDisplayName: string) => { + this.getters.nodeCreatorPlusButton().click(); + this.getters.nodeCreatorSearchBar().type(nodeDisplayName); + this.getters.nodeCreatorSearchBar().type('{enter}{esc}'); + }, + openNodeNdv: (nodeTypeName: string) => { + this.getters.canvasNodeBox(nodeTypeName).dblclick(); + }, + typeIntoParameterInput: (parameterName: string, content: string) => { + this.getters.ndvParameterInput(parameterName).type(content); + }, + executeNodeFromNdv: () => { + cy.contains('Execute node').click(); + }, }; } diff --git a/cypress/pages/workflows.ts b/cypress/pages/workflows.ts index 7e1ce46007..783d45bd22 100644 --- a/cypress/pages/workflows.ts +++ b/cypress/pages/workflows.ts @@ -24,4 +24,10 @@ export class WorkflowsPage extends BasePage { // myWorkflows: () => cy.getByTestId('my-workflows'), // allWorkflows: () => cy.getByTestId('all-workflows'), }; + + actions = { + createWorkflowFromCard: () => { + this.getters.newWorkflowButtonCard().click(); + }, + } } diff --git a/packages/editor-ui/src/components/Node.vue b/packages/editor-ui/src/components/Node.vue index 845c5acca1..a8758ebf3c 100644 --- a/packages/editor-ui/src/components/Node.vue +++ b/packages/editor-ui/src/components/Node.vue @@ -1,5 +1,5 @@