test: Set up e2e tests for Code node (#4730)

* 🧪 Set up Code node tests

*  Address comments
This commit is contained in:
Iván Ovejero 2022-11-28 16:54:13 +01:00 committed by GitHub
parent efbf7366fb
commit 8f6fd009b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,34 @@
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
const WorkflowPage = new WorkflowPageClass();
describe('Code node', () => {
beforeEach(() => {
cy.task('db:reset');
cy.skipSetup();
});
it('should execute the placeholder in all-items mode successfully', () => {
WorkflowPage.actions.visit();
WorkflowPage.actions.addInitialNodeToCanvas('Manual Trigger');
WorkflowPage.actions.addNodeToCanvas('Code');
WorkflowPage.actions.openNodeNdv('Code');
WorkflowPage.actions.executeNodeFromNdv();
WorkflowPage.getters.successToast().contains('Node executed successfully');
});
it('should execute the placeholder in each-item mode successfully', () => {
WorkflowPage.actions.visit();
WorkflowPage.actions.addInitialNodeToCanvas('Manual Trigger');
WorkflowPage.actions.addNodeToCanvas('Code');
WorkflowPage.actions.openNodeNdv('Code');
WorkflowPage.getters.ndvParameterInput('mode').click();
WorkflowPage.actions.selectOptionInParameterDropdown('mode', 'Run Once for Each Item');
WorkflowPage.actions.executeNodeFromNdv();
WorkflowPage.getters.successToast().contains('Node executed successfully');
});
});

View file

@ -25,6 +25,9 @@ export class WorkflowPage extends BasePage {
ndvParameterInput: (parameterName: string) =>
cy.getByTestId(`parameter-input-${parameterName}`),
ndvOutputPanel: () => cy.getByTestId('output-panel'),
ndvRunDataPaneHeader: () => cy.getByTestId('run-data-pane-header'),
successToast: () => cy.get('.el-notification__title'),
activatorSwitch: () => cy.getByTestId('workflow-activate-switch'),
workflowMenu: () => cy.getByTestId('workflow-menu'),
firstStepButton: () => cy.getByTestId('canvas-add-button'),
@ -53,6 +56,13 @@ export class WorkflowPage extends BasePage {
typeIntoParameterInput: (parameterName: string, content: string) => {
this.getters.ndvParameterInput(parameterName).type(content);
},
selectOptionInParameterDropdown: (parameterName: string, content: string) => {
this.getters
.ndvParameterInput(parameterName)
.find('.option-headline')
.contains(content)
.click();
},
executeNodeFromNdv: () => {
cy.contains('Execute node').click();
},

View file

@ -37,7 +37,7 @@
<div :class="$style.header">
<slot name="header"></slot>
<div v-show="!hasRunError" @click.stop :class="$style.displayModes">
<div v-show="!hasRunError" @click.stop :class="$style.displayModes" data-test-id="run-data-pane-header">
<n8n-radio-buttons
v-show="hasNodeRun && ((jsonData && jsonData.length > 0) || (binaryData && binaryData.length > 0)) && !editMode.enabled"
:value="displayMode"