Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Set up e2e tests for HTTP Request node #4718

Merged
merged 8 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cypress/e2e/4-http-request-node.cy.ts
Original file line number Diff line number Diff line change
@@ -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('<!doctype html>');
});
});
43 changes: 41 additions & 2 deletions cypress/pages/workflow.ts
Original file line number Diff line number Diff line change
@@ -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();
},
};
}
6 changes: 6 additions & 0 deletions cypress/pages/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
}
}
4 changes: 2 additions & 2 deletions packages/editor-ui/src/components/Node.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="node-wrapper" :style="nodePosition" :id="nodeId">
<div class="node-wrapper" :style="nodePosition" :id="nodeId" data-test-id="canvas-node-box">
<div class="select-background" v-show="isSelected"></div>
<div :class="{'node-default': true, 'touch-active': isTouchActive, 'is-touch-device': isTouchDevice}" :data-name="data.name" :ref="data.name">
<div :class="nodeClass" :style="nodeStyle" @click.left="onClick" v-touch:start="touchStart" v-touch:end="touchEnd">
Expand Down Expand Up @@ -80,7 +80,7 @@
</div>
<div class="node-description">
<div class="node-name ph-no-capture" :title="nodeTitle">
<p>
<p data-test-id="canvas-node-box-title">
{{ nodeTitle }}
</p>
<p v-if="data.disabled">
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/Node/NodeCreation.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div>
<div v-if="!createNodeActive" :class="[$style.nodeButtonsWrapper, showStickyButton ? $style.noEvents : '']" @mouseenter="onCreateMenuHoverIn">
<div :class="$style.nodeCreatorButton">
<div :class="$style.nodeCreatorButton" data-test-id="node-creator-plus-button">
<n8n-icon-button size="xlarge" icon="plus" type="tertiary" :class="$style.nodeCreatorPlus" @click="openNodeCreator" :title="$locale.baseText('nodeView.addNode')"/>
<div :class="[$style.addStickyButton, showStickyButton ? $style.visibleButton : '']" @click="addStickyNote">
<n8n-icon-button size="medium" type="tertiary" :icon="['far', 'note-sticky']" :title="$locale.baseText('nodeView.addSticky')"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
:value="value"
@input="onInput"
:class="$style.input"
data-test-id="node-creator-search-bar"
/>
</div>
<div :class="$style.suffix" v-if="value.length > 0" @click="clear">
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/components/NodeDetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
</template>
<template #output>
<OutputPanel
data-test-id="output-panel"
:canLinkRuns="canLinkRuns"
:runIndex="outputRun"
:linkedRuns="linked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:required="parameter.required"
:showTooltip="focused"
:showOptions="menuExpanded"
:data-test-id="parameter.name"
>
<template #options>
<parameter-options
Expand Down
4 changes: 3 additions & 1 deletion packages/editor-ui/src/components/ParameterInputWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
@blur="onBlur"
@drop="onDrop"
@textInput="onTextInput"
@valueChanged="onValueChanged" />
@valueChanged="onValueChanged"
:data-test-id="`parameter-input-${parameter.name}`"
/>
<input-hint v-if="expressionOutput" :class="$style.hint" :highlight="!!(expressionOutput && targetItem)" :hint="expressionOutput" />
<input-hint v-else-if="parameterHint" :class="$style.hint" :renderHTML="true" :hint="parameterHint" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/CanvasAddButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div :class="$style.container" :style="containerCssVars" ref="container">
<n8n-tooltip placement="top" :value="showTooltip" manual :disabled="isScrimActive" :popper-class="$style.tooltip" :open-delay="700">
<button :class="$style.button" @click="$emit('click')">
<button :class="$style.button" @click="$emit('click')" data-test-id="canvas-plus-button">
<font-awesome-icon icon="plus" size="lg" />
</button>
<template #content>
Expand Down