diff --git a/cypress.config.js b/cypress.config.js
index 862adbdea1..7b0e2fbf10 100644
--- a/cypress.config.js
+++ b/cypress.config.js
@@ -11,10 +11,10 @@ module.exports = defineConfig({
experimentalSessionAndOrigin: true,
experimentalInteractiveRunEvents: true,
- setupNodeEvents(on) {
+ setupNodeEvents(on, config) {
on('task', {
- 'db:reset': () => fetch(BASE_URL + '/e2e/db/reset', { method: 'POST' }),
- 'db:setup-owner': (payload) =>
+ 'reset': () => fetch(BASE_URL + '/e2e/db/reset', { method: 'POST' }),
+ 'setup-owner': (payload) =>
fetch(BASE_URL + '/e2e/db/setup-owner', {
method: 'POST',
body: JSON.stringify(payload),
diff --git a/cypress/e2e/0-smoke.cy.ts b/cypress/e2e/0-smoke.cy.ts
index f686075d47..09d9842922 100644
--- a/cypress/e2e/0-smoke.cy.ts
+++ b/cypress/e2e/0-smoke.cy.ts
@@ -8,21 +8,21 @@ const lastName = randLastName();
describe('Authentication', () => {
beforeEach(() => {
- cy.task('db:reset');
+ cy.resetAll();
});
it('should setup owner', () => {
- cy.signup(email, firstName, lastName, password);
+ cy.setup({ email, firstName, lastName, password });
});
it('should sign user in', () => {
- cy.task('db:setup-owner', { email, password, firstName, lastName });
+ cy.setupOwner({ email, password, firstName, lastName });
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not logged in');
return false;
});
- cy.signin(email, password);
+ cy.signin({ email, password });
});
});
diff --git a/cypress/e2e/1-workflows.cy.ts b/cypress/e2e/1-workflows.cy.ts
index 4f4d08cdc8..b888cb422b 100644
--- a/cypress/e2e/1-workflows.cy.ts
+++ b/cypress/e2e/1-workflows.cy.ts
@@ -4,7 +4,7 @@ import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
import { v4 as uuid } from 'uuid';
-const username = DEFAULT_USER_EMAIL;
+const email = DEFAULT_USER_EMAIL;
const password = DEFAULT_USER_PASSWORD;
const firstName = randFirstName();
const lastName = randLastName();
@@ -12,16 +12,19 @@ const WorkflowsPage = new WorkflowsPageClass();
const WorkflowPage = new WorkflowPageClass();
describe('Workflows', () => {
- beforeEach(() => {
- cy.signup(username, firstName, lastName, password);
+ before(() => {
+ cy.resetAll();
+ cy.setup({ email, firstName, lastName, password });
+ });
+ beforeEach(() => {
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not logged in');
return false;
})
- cy.signin(username, password);
+ cy.signin({ email, password });
cy.visit(WorkflowsPage.url);
});
diff --git a/cypress/e2e/2-credentials.cy.ts b/cypress/e2e/2-credentials.cy.ts
index dad6f4e283..8e6a030904 100644
--- a/cypress/e2e/2-credentials.cy.ts
+++ b/cypress/e2e/2-credentials.cy.ts
@@ -2,7 +2,7 @@ import { DEFAULT_USER_EMAIL, DEFAULT_USER_PASSWORD } from "../constants";
import { randFirstName, randLastName } from "@ngneat/falso";
import { CredentialsPage, CredentialsModal } from '../pages';
-const username = DEFAULT_USER_EMAIL;
+const email = DEFAULT_USER_EMAIL;
const password = DEFAULT_USER_PASSWORD;
const firstName = randFirstName();
const lastName = randLastName();
@@ -11,20 +11,18 @@ const credentialsModal = new CredentialsModal();
describe('Credentials', () => {
before(() => {
- cy.task('db:reset');
- Cypress.session.clearAllSavedSessions();
+ cy.resetAll();
+ cy.setup({ email, firstName, lastName, password });
});
beforeEach(() => {
- cy.signup(username, firstName, lastName, password);
-
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not logged in');
return false;
})
- cy.signin(username, password);
+ cy.signin({ email, password });
cy.visit(credentialsPage.url);
});
diff --git a/cypress/e2e/3-default-owner.cy.ts b/cypress/e2e/3-default-owner.cy.ts
index 75d2414563..59500954f1 100644
--- a/cypress/e2e/3-default-owner.cy.ts
+++ b/cypress/e2e/3-default-owner.cy.ts
@@ -18,7 +18,7 @@ const settingsUsersPage = new SettingsUsersPage();
const messageBox = new MessageBox();
-const username = DEFAULT_USER_EMAIL;
+const email = DEFAULT_USER_EMAIL;
const password = DEFAULT_USER_PASSWORD;
const firstName = randFirstName();
const lastName = randLastName();
@@ -27,7 +27,7 @@ describe('Default owner', () => {
// todo test should redirect to setup if have not skipped
beforeEach(() => {
- cy.task('db:reset');
+ cy.resetAll();
});
it('should be able to use n8n without user management and setup UM', () => {
@@ -83,7 +83,7 @@ describe('Default owner', () => {
});
describe('should be able to setup instance and migrate workflows and credentials', () => {
- cy.signup(username, firstName, lastName, password);
+ cy.setup({ email, firstName, lastName, password });
messageBox.getters.content().should('contain.text', '1 existing workflow and 1 credential')
diff --git a/cypress/e2e/4-http-request-node.cy.ts b/cypress/e2e/4-http-request-node.cy.ts
index 51a50fab45..e0803a93a6 100644
--- a/cypress/e2e/4-http-request-node.cy.ts
+++ b/cypress/e2e/4-http-request-node.cy.ts
@@ -5,8 +5,8 @@ const WorkflowsPage = new WorkflowsPageClass();
const WorkflowPage = new WorkflowPageClass();
describe('HTTP Request node', () => {
- beforeEach(() => {
- cy.task('db:reset');
+ before(() => {
+ cy.resetAll();
cy.skipSetup();
});
diff --git a/cypress/e2e/4-node-creator.cy.ts b/cypress/e2e/4-node-creator.cy.ts
index 807b2b3471..9099aff2aa 100644
--- a/cypress/e2e/4-node-creator.cy.ts
+++ b/cypress/e2e/4-node-creator.cy.ts
@@ -1,15 +1,24 @@
import { NodeCreator } from '../pages/features/node-creator';
import { INodeTypeDescription } from '../../packages/workflow';
import CustomNodeFixture from '../fixtures/Custom_node.json';
+import {DEFAULT_USER_EMAIL, DEFAULT_USER_PASSWORD} from "../constants";
+import {randFirstName, randLastName} from "@ngneat/falso";
+const email = DEFAULT_USER_EMAIL;
+const password = DEFAULT_USER_PASSWORD;
+const firstName = randFirstName();
+const lastName = randLastName();
const nodeCreatorFeature = new NodeCreator();
describe('Node Creator', () => {
before(() => {
- cy.task('db:reset');
- })
+ cy.resetAll();
+ cy.setup({ email, firstName, lastName, password });
+ });
beforeEach(() => {
+ cy.signin({ email, password });
+
cy.intercept('GET', '/types/nodes.json', (req) => {
// Delete caching headers so that we can intercept the request
['etag', 'if-none-match', 'if-modified-since'].forEach(header => {delete req.headers[header]});
@@ -21,7 +30,8 @@ describe('Node Creator', () => {
nodes.push(CustomNodeFixture as INodeTypeDescription);
res.send(nodes)
})
- }).as('nodesIntercept')
+ }).as('nodesIntercept');
+
cy.visit(nodeCreatorFeature.url);
});
diff --git a/cypress/e2e/5-workflow-actions.cy.ts b/cypress/e2e/5-workflow-actions.cy.ts
index b56da9720c..20d6924801 100644
--- a/cypress/e2e/5-workflow-actions.cy.ts
+++ b/cypress/e2e/5-workflow-actions.cy.ts
@@ -6,22 +6,26 @@ const NEW_WORKFLOW_NAME = 'Something else';
const MANUAL_TRIGGER_NODE_NAME = 'Manual Trigger';
const SCHEDULE_TRIGGER_NODE_NAME = 'Schedule Trigger';
-const username = DEFAULT_USER_EMAIL;
+const email = DEFAULT_USER_EMAIL;
const password = DEFAULT_USER_PASSWORD;
const firstName = randFirstName();
const lastName = randLastName();
const WorkflowPage = new WorkflowPageClass();
describe('Workflow Actions', () => {
+ before(() => {
+ cy.resetAll();
+ cy.setup({ email, firstName, lastName, password });
+ });
+
beforeEach(() => {
- cy.signup(username, firstName, lastName, password);
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not logged in');
return false;
})
- cy.signin(username, password);
+ cy.signin({ email, password });
WorkflowPage.actions.visit();
});
diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts
index 81f3088806..7637577e0d 100644
--- a/cypress/support/commands.ts
+++ b/cypress/support/commands.ts
@@ -52,7 +52,7 @@ Cypress.Commands.add('findChildByTestId', { prevSubject: true }, (subject: Cypre
Cypress.Commands.add(
'signin',
- (email, password) => {
+ ({ email, password }) => {
const signinPage = new SigninPage();
const workflowsPage = new WorkflowsPage();
@@ -75,8 +75,7 @@ Cypress.Commands.add(
});
});
-// todo rename to setup
-Cypress.Commands.add('signup', (email, firstName, lastName, password) => {
+Cypress.Commands.add('setup', ({ email, firstName, lastName, password }) => {
const signupPage = new SignupPage();
cy.visit(signupPage.url);
@@ -120,3 +119,12 @@ Cypress.Commands.add('skipSetup', () => {
});
});
})
+
+Cypress.Commands.add('resetAll', () => {
+ cy.task('reset');
+ Cypress.session.clearAllSavedSessions();
+});
+
+Cypress.Commands.add('setupOwner', (payload) => {
+ cy.task('setup-owner', payload);
+});
diff --git a/cypress/support/index.ts b/cypress/support/index.ts
index 2567772d1e..afb2dee0c1 100644
--- a/cypress/support/index.ts
+++ b/cypress/support/index.ts
@@ -1,16 +1,29 @@
// Load type definitions that come with Cypress module
///
+interface SigninPayload {
+ email: string;
+ password: string;
+}
+
+interface SetupPayload {
+ email: string;
+ password: string;
+ firstName: string;
+ lastName: string;
+}
+
declare global {
namespace Cypress {
interface Chainable {
getByTestId(selector: string, ...args: (Partial | undefined)[]): Chainable>
findChildByTestId(childTestId: string): Chainable>
createFixtureWorkflow(fixtureKey: string, workflowName: string): void;
- signin(email: string, password: string): void;
- // todo: rename to setup
- signup(email: string, firstName: string, lastName: string, password: string): void;
+ signin(payload: SigninPayload): void;
+ setup(payload: SetupPayload): void;
+ setupOwner(payload: SetupPayload): void;
skipSetup(): void;
+ resetAll(): void;
}
}
}
diff --git a/package.json b/package.json
index 0c48a778e5..4b57d284ef 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
"test:e2e:ui": "cross-env E2E_TESTS=true start-server-and-test start http://localhost:5678/favicon.ico 'cypress open'",
"test:e2e:dev": "cross-env E2E_TESTS=true CYPRESS_BASE_URL=http://localhost:8080 start-server-and-test dev http://localhost:8080/favicon.ico 'cypress open'",
"test:e2e:smoke": "cross-env E2E_TESTS=true start-server-and-test start http://localhost:5678/favicon.ico 'cypress run --headless --spec \"cypress/e2e/0-smoke.cy.ts\"'",
- "test:e2e:all": "cross-env E2E_TESTS=true start-server-and-test start http://localhost:5678/favicon.ico 'cypress run'"
+ "test:e2e:all": "cross-env E2E_TESTS=true start-server-and-test start http://localhost:5678/favicon.ico 'cypress run --headless'"
},
"dependencies": {
"n8n": "*"