Skip to content

Commit

Permalink
test: Use nanoid instead of UUID in e2e tests for wf names (no-change…
Browse files Browse the repository at this point in the history
…log) (n8n-io#9717)
  • Loading branch information
tomi authored and adrian-martinez-onestic committed Jun 20, 2024
1 parent acc043a commit 1b213a6
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 76 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/1-workflows.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { v4 as uuid } from 'uuid';
import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
import { getUniqueWorkflowName } from '../utils/workflowUtils';

const WorkflowsPage = new WorkflowsPageClass();
const WorkflowPage = new WorkflowPageClass();
Expand All @@ -16,7 +16,7 @@ describe('Workflows', () => {
WorkflowsPage.getters.newWorkflowButtonCard().should('be.visible');
WorkflowsPage.getters.newWorkflowButtonCard().click();

cy.createFixtureWorkflow('Test_workflow_1.json', `Empty State Card Workflow ${uuid()}`);
cy.createFixtureWorkflow('Test_workflow_1.json', 'Empty State Card Workflow');

WorkflowPage.getters.workflowTags().should('contain.text', 'some-tag-1');
WorkflowPage.getters.workflowTags().should('contain.text', 'some-tag-2');
Expand All @@ -27,7 +27,7 @@ describe('Workflows', () => {
cy.visit(WorkflowsPage.url);
WorkflowsPage.getters.createWorkflowButton().click();

cy.createFixtureWorkflow('Test_workflow_2.json', `My New Workflow ${uuid()}`);
cy.createFixtureWorkflow('Test_workflow_2.json', getUniqueWorkflowName('My New Workflow'));

WorkflowPage.getters.workflowTags().should('contain.text', 'other-tag-1');
WorkflowPage.getters.workflowTags().should('contain.text', 'other-tag-2');
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/1338-ADO-ndv-missing-input-panel.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as uuid } from 'uuid';
import { NDV, WorkflowPage as WorkflowPageClass } from '../pages';
import { successToast } from '../pages/notifications';

Expand All @@ -11,7 +10,7 @@ describe('ADO-1338-ndv-missing-input-panel', () => {
});

it('should show the input and output panels when node is missing input and output data', () => {
cy.createFixtureWorkflow('Test_ado_1338.json', uuid());
cy.createFixtureWorkflow('Test_ado_1338.json');

// Execute the workflow
workflowPage.getters.zoomToFitButton().click();
Expand Down
28 changes: 14 additions & 14 deletions cypress/e2e/16-webhook-node.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuid } from 'uuid';
import { nanoid } from 'nanoid';
import { WorkflowPage, NDV, CredentialsModal } from '../pages';
import { cowBase64 } from '../support/binaryTestFiles';
import { BACKEND_BASE_URL, EDIT_FIELDS_SET_NODE_NAME } from '../constants';
Expand Down Expand Up @@ -81,28 +81,28 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request', () => {
simpleWebhookCall({ method: 'GET', webhookPath: uuid(), executeNow: true });
simpleWebhookCall({ method: 'GET', webhookPath: nanoid(), executeNow: true });
});

it('should listen for a POST request', () => {
simpleWebhookCall({ method: 'POST', webhookPath: uuid(), executeNow: true });
simpleWebhookCall({ method: 'POST', webhookPath: nanoid(), executeNow: true });
});

it('should listen for a DELETE request', () => {
simpleWebhookCall({ method: 'DELETE', webhookPath: uuid(), executeNow: true });
simpleWebhookCall({ method: 'DELETE', webhookPath: nanoid(), executeNow: true });
});
it('should listen for a HEAD request', () => {
simpleWebhookCall({ method: 'HEAD', webhookPath: uuid(), executeNow: true });
simpleWebhookCall({ method: 'HEAD', webhookPath: nanoid(), executeNow: true });
});
it('should listen for a PATCH request', () => {
simpleWebhookCall({ method: 'PATCH', webhookPath: uuid(), executeNow: true });
simpleWebhookCall({ method: 'PATCH', webhookPath: nanoid(), executeNow: true });
});
it('should listen for a PUT request', () => {
simpleWebhookCall({ method: 'PUT', webhookPath: uuid(), executeNow: true });
simpleWebhookCall({ method: 'PUT', webhookPath: nanoid(), executeNow: true });
});

it('should listen for a GET request and respond with Respond to Webhook node', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request and respond custom status code 201', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand All @@ -147,7 +147,7 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request and respond with last node', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand All @@ -172,7 +172,7 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request and respond with last node binary data', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand Down Expand Up @@ -213,7 +213,7 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request and respond with an empty body', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand All @@ -232,7 +232,7 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request with Basic Authentication', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('Webhook Trigger node', () => {
});

it('should listen for a GET request with Header Authentication', () => {
const webhookPath = uuid();
const webhookPath = nanoid();
simpleWebhookCall({
method: 'GET',
webhookPath,
Expand Down
31 changes: 9 additions & 22 deletions cypress/e2e/19-execution.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as uuid } from 'uuid';
import { NDV, WorkflowExecutionsTab, WorkflowPage as WorkflowPageClass } from '../pages';
import { SCHEDULE_TRIGGER_NODE_NAME, EDIT_FIELDS_SET_NODE_NAME } from '../constants';
import { errorToast, successToast } from '../pages/notifications';
Expand All @@ -13,7 +12,7 @@ describe('Execution', () => {
});

it('should test manual workflow', () => {
cy.createFixtureWorkflow('Manual_wait_set.json', `Manual wait set ${uuid()}`);
cy.createFixtureWorkflow('Manual_wait_set.json');

// Check workflow buttons
workflowPage.getters.executeWorkflowButton().should('be.visible');
Expand Down Expand Up @@ -73,7 +72,7 @@ describe('Execution', () => {
});

it('should test manual workflow stop', () => {
cy.createFixtureWorkflow('Manual_wait_set.json', `Manual wait set ${uuid()}`);
cy.createFixtureWorkflow('Manual_wait_set.json');

// Check workflow buttons
workflowPage.getters.executeWorkflowButton().should('be.visible');
Expand Down Expand Up @@ -132,7 +131,7 @@ describe('Execution', () => {
});

it('should test webhook workflow', () => {
cy.createFixtureWorkflow('Webhook_wait_set.json', `Webhook wait set ${uuid()}`);
cy.createFixtureWorkflow('Webhook_wait_set.json');

// Check workflow buttons
workflowPage.getters.executeWorkflowButton().should('be.visible');
Expand Down Expand Up @@ -205,7 +204,7 @@ describe('Execution', () => {
});

it('should test webhook workflow stop', () => {
cy.createFixtureWorkflow('Webhook_wait_set.json', `Webhook wait set ${uuid()}`);
cy.createFixtureWorkflow('Webhook_wait_set.json');

// Check workflow buttons
workflowPage.getters.executeWorkflowButton().should('be.visible');
Expand Down Expand Up @@ -293,7 +292,7 @@ describe('Execution', () => {

describe('connections should be colored differently for pinned data', () => {
beforeEach(() => {
cy.createFixtureWorkflow('Schedule_pinned.json', `Schedule pinned ${uuid()}`);
cy.createFixtureWorkflow('Schedule_pinned.json');
workflowPage.actions.deselectAll();
workflowPage.getters.zoomToFitButton().click();

Expand Down Expand Up @@ -492,10 +491,7 @@ describe('Execution', () => {
});

it('should send proper payload for node rerun', () => {
cy.createFixtureWorkflow(
'Multiple_trigger_node_rerun.json',
`Multiple trigger node rerun ${uuid()}`,
);
cy.createFixtureWorkflow('Multiple_trigger_node_rerun.json', 'Multiple trigger node rerun');

workflowPage.getters.zoomToFitButton().click();
workflowPage.getters.executeWorkflowButton().click();
Expand All @@ -520,10 +516,7 @@ describe('Execution', () => {
});

it('should send proper payload for manual node run', () => {
cy.createFixtureWorkflow(
'Check_manual_node_run_for_pinned_and_rundata.json',
`Check manual node run for pinned and rundata ${uuid()}`,
);
cy.createFixtureWorkflow('Check_manual_node_run_for_pinned_and_rundata.json');

workflowPage.getters.zoomToFitButton().click();

Expand Down Expand Up @@ -576,10 +569,7 @@ describe('Execution', () => {
});

it('should successfully execute partial executions with nodes attached to the second output', () => {
cy.createFixtureWorkflow(
'Test_Workflow_pairedItem_incomplete_manual_bug.json',
'My test workflow',
);
cy.createFixtureWorkflow('Test_Workflow_pairedItem_incomplete_manual_bug.json');

cy.intercept('POST', '/rest/workflows/**/run').as('workflowRun');

Expand All @@ -599,10 +589,7 @@ describe('Execution', () => {
});

it('should execute workflow partially up to the node that has issues', () => {
cy.createFixtureWorkflow(
'Test_workflow_partial_execution_with_missing_credentials.json',
'My test workflow',
);
cy.createFixtureWorkflow('Test_workflow_partial_execution_with_missing_credentials.json');

cy.intercept('POST', '/rest/workflows/**/run').as('workflowRun');

Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/2106-ADO-pinned-data-execution-preview.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as uuid } from 'uuid';
import { WorkflowExecutionsTab, WorkflowPage as WorkflowPageClass } from '../pages';
import { BACKEND_BASE_URL } from '../constants';

Expand All @@ -11,7 +10,7 @@ describe('ADO-2106 connections should be colored correctly for pinned data in ex
});

beforeEach(() => {
cy.createFixtureWorkflow('Webhook_set_pinned.json', `Webhook set pinned ${uuid()}`);
cy.createFixtureWorkflow('Webhook_set_pinned.json');
workflowPage.actions.deselectAll();
workflowPage.getters.zoomToFitButton().click();

Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/24-ndv-paired-item.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as uuid } from 'uuid';
import { WorkflowPage, NDV } from '../pages';

const workflowPage = new WorkflowPage();
Expand All @@ -7,7 +6,7 @@ const ndv = new NDV();
describe('NDV', () => {
beforeEach(() => {
workflowPage.actions.visit();
workflowPage.actions.renameWorkflow(uuid());
workflowPage.actions.renameWithUniqueName();
workflowPage.actions.saveWorkflowOnButtonClick();
});

Expand Down
17 changes: 8 additions & 9 deletions cypress/e2e/5-ndv.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as uuid } from 'uuid';
import { getVisibleSelect } from '../utils';
import { MANUAL_TRIGGER_NODE_DISPLAY_NAME } from '../constants';
import { NDV, WorkflowPage } from '../pages';
Expand All @@ -13,7 +12,7 @@ const ndv = new NDV();
describe('NDV', () => {
beforeEach(() => {
workflowPage.actions.visit();
workflowPage.actions.renameWorkflow(uuid());
workflowPage.actions.renameWithUniqueName();
workflowPage.actions.saveWorkflowOnButtonClick();
});

Expand Down Expand Up @@ -55,7 +54,7 @@ describe('NDV', () => {
});

it('should change input and go back to canvas', () => {
cy.createFixtureWorkflow('NDV-test-select-input.json', `NDV test select input ${uuid()}`);
cy.createFixtureWorkflow('NDV-test-select-input.json', 'NDV test select input');
workflowPage.actions.zoomToFit();
workflowPage.getters.canvasNodes().last().dblclick();
ndv.getters.inputSelect().click();
Expand Down Expand Up @@ -157,7 +156,7 @@ describe('NDV', () => {
'prop2',
];
function setupSchemaWorkflow() {
cy.createFixtureWorkflow('Test_workflow_schema_test.json', `NDV test schema view ${uuid()}`);
cy.createFixtureWorkflow('Test_workflow_schema_test.json');
workflowPage.actions.zoomToFit();
workflowPage.actions.openNode('Set');
ndv.actions.execute();
Expand Down Expand Up @@ -231,7 +230,7 @@ describe('NDV', () => {
it('should display large schema', () => {
cy.createFixtureWorkflow(
'Test_workflow_schema_test_pinned_data.json',
`NDV test schema view ${uuid()}`,
'NDV test schema view 2',
);
workflowPage.actions.zoomToFit();
workflowPage.actions.openNode('Set');
Expand Down Expand Up @@ -306,7 +305,7 @@ describe('NDV', () => {
it('should display parameter hints correctly', () => {
workflowPage.actions.visit();

cy.createFixtureWorkflow('Test_workflow_3.json', 'My test workflow');
cy.createFixtureWorkflow('Test_workflow_3.json', 'My test workflow 1');
workflowPage.actions.openNode('Set1');

ndv.actions.typeIntoParameterInput('value', '='); // switch to expressions
Expand Down Expand Up @@ -574,7 +573,7 @@ describe('NDV', () => {
});

it('should show node name and version in settings', () => {
cy.createFixtureWorkflow('Test_workflow_ndv_version.json', `NDV test version ${uuid()}`);
cy.createFixtureWorkflow('Test_workflow_ndv_version.json', 'NDV test version');

workflowPage.actions.openNode('Edit Fields (old)');
ndv.actions.openSettings();
Expand Down Expand Up @@ -711,7 +710,7 @@ describe('NDV', () => {
};
cy.createFixtureWorkflow(
'open_node_creator_for_connection.json',
`open_node_creator_for_connection ${uuid()}`,
'open_node_creator_for_connection',
);

Object.entries(hintMapper).forEach(([node, group]) => {
Expand Down Expand Up @@ -742,7 +741,7 @@ describe('NDV', () => {
it('should allow selecting item for expressions', () => {
workflowPage.actions.visit();

cy.createFixtureWorkflow('Test_workflow_3.json', 'My test workflow');
cy.createFixtureWorkflow('Test_workflow_3.json', 'My test workflow 2');
workflowPage.actions.openNode('Set');

ndv.actions.typeIntoParameterInput('value', '='); // switch to expressions
Expand Down
5 changes: 2 additions & 3 deletions cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"devDependencies": {
"@types/lodash": "^4.14.195",
"@types/uuid": "^8.3.2",
"eslint-plugin-cypress": "^3.3.0",
"n8n-workflow": "workspace:*"
},
Expand All @@ -26,7 +25,7 @@
"cypress-otp": "^1.0.3",
"cypress-real-events": "^1.12.0",
"lodash": "4.17.21",
"start-server-and-test": "^2.0.3",
"uuid": "8.3.2"
"nanoid": "3.3.6",
"start-server-and-test": "^2.0.3"
}
}
4 changes: 4 additions & 0 deletions cypress/pages/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { META_KEY } from '../constants';
import { getVisibleSelect } from '../utils';
import { getUniqueWorkflowName } from '../utils/workflowUtils';
import { BasePage } from './base';
import { NodeCreator } from './features/node-creator';

Expand Down Expand Up @@ -311,6 +312,9 @@ export class WorkflowPage extends BasePage {
cy.get('body').type(newName);
cy.get('body').type('{enter}');
},
renameWithUniqueName: () => {
this.actions.renameWorkflow(getUniqueWorkflowName());
},
addTags: (tags: string | string[]) => {
if (!Array.isArray(tags)) tags = [tags];

Expand Down
5 changes: 4 additions & 1 deletion cypress/scripts/run-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ switch (scenario) {
});
break;
case 'all':
const specSuiteFilter = process.argv[3];
const specParam = specSuiteFilter ? ` --spec **/*${specSuiteFilter}*` : '';

runTests({
startCommand: 'start',
url: 'http://localhost:5678/favicon.ico',
testCommand: 'cypress run --headless',
testCommand: `cypress run --headless ${specParam}`,
});
break;
default:
Expand Down
Loading

0 comments on commit 1b213a6

Please sign in to comment.