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

fix: Fix randomly failing scheduler node e2e tests (no-changelog) #6430

Merged
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
2 changes: 2 additions & 0 deletions cypress/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const BACKEND_BASE_URL = 'http://localhost:5678';

export const N8N_AUTH_COOKIE = 'n8n-auth';

export const DEFAULT_USER_EMAIL = '[email protected]';
Expand Down
63 changes: 27 additions & 36 deletions cypress/e2e/15-scheduler-node.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WorkflowPage, WorkflowsPage, NDV } from '../pages';
import { BACKEND_BASE_URL } from '../constants';

const workflowsPage = new WorkflowsPage();
const workflowPage = new WorkflowPage();
Expand Down Expand Up @@ -39,44 +40,34 @@ describe('Schedule Trigger node', async () => {
workflowPage.actions.activateWorkflow();
workflowPage.getters.activatorSwitch().should('have.class', 'is-checked');

cy.request('GET', '/rest/workflows')
.then((response) => {
cy.url().then((url) => {
const workflowId = url.split('/').pop();

cy.wait(1200);
cy.request('GET', `${BACKEND_BASE_URL}/rest/executions`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data).to.have.length(1);
const workflowId = response.body.data[0].id.toString();
expect(workflowId).to.not.be.empty;
return workflowId;
})
.then((workflowId) => {
expect(workflowId).to.not.be.undefined;
expect(response.body.data.results.length).to.be.greaterThan(0);
const matchingExecutions = response.body.data.results.filter(
(execution: any) => execution.workflowId === workflowId,
);
expect(matchingExecutions).to.have.length(1);

cy.wait(1200);
cy.request('GET', '/rest/executions')
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data.results.length).to.be.greaterThan(0);
const matchingExecutions = response.body.data.results.filter(
(execution: any) => execution.workflowId === workflowId,
);
expect(matchingExecutions).to.have.length(1);
return workflowId;
})
.then((workflowId) => {
cy.wait(1200);
cy.request('GET', '/rest/executions')
.then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data.results.length).to.be.greaterThan(0);
const matchingExecutions = response.body.data.results.filter(
(execution: any) => execution.workflowId === workflowId,
);
expect(matchingExecutions).to.have.length(2);
})
.then(() => {
workflowPage.actions.activateWorkflow();
workflowPage.getters.activatorSwitch().should('not.have.class', 'is-checked');
cy.visit(workflowsPage.url);
workflowsPage.actions.deleteWorkFlow('Schedule Trigger Workflow');
});
});
cy.request('GET', `${BACKEND_BASE_URL}/rest/executions`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.data.results.length).to.be.greaterThan(0);
const matchingExecutions = response.body.data.results.filter(
(execution: any) => execution.workflowId === workflowId,
);
expect(matchingExecutions).to.have.length(2);

workflowPage.actions.activateWorkflow();
workflowPage.getters.activatorSwitch().should('not.have.class', 'is-checked');
cy.visit(workflowsPage.url);
workflowsPage.actions.deleteWorkFlow('Schedule Trigger Workflow');
});
});
});
});
});
31 changes: 15 additions & 16 deletions cypress/e2e/16-webhook-node.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { WorkflowPage, NDV, CredentialsModal } from '../pages';
import { v4 as uuid } from 'uuid';
import { cowBase64 } from '../support/binaryTestFiles';
import { BACKEND_BASE_URL } from '../constants';

const workflowPage = new WorkflowPage();
const ndv = new NDV();
Expand Down Expand Up @@ -83,7 +84,7 @@ const simpleWebhookCall = (options: SimpleWebhookCallOptions) => {
ndv.actions.execute();
cy.wait(waitForWebhook);

cy.request(method, '/webhook-test/' + webhookPath).then((response) => {
cy.request(method, `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`).then((response) => {
expect(response.status).to.eq(200);
ndv.getters.outputPanel().contains('headers');
});
Expand All @@ -98,12 +99,10 @@ describe('Webhook Trigger node', async () => {
beforeEach(() => {
workflowPage.actions.visit();

cy.window().then(
(win) => {
// @ts-ignore
win.preventNodeViewBeforeUnload = true;
},
);
cy.window().then((win) => {
// @ts-ignore
win.preventNodeViewBeforeUnload = true;
});
});

it('should listen for a GET request', () => {
Expand Down Expand Up @@ -154,7 +153,7 @@ describe('Webhook Trigger node', async () => {
workflowPage.actions.executeWorkflow();
cy.wait(waitForWebhook);

cy.request('GET', '/webhook-test/' + webhookPath).then((response) => {
cy.request('GET', `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.MyValue).to.eq(1234);
});
Expand All @@ -172,7 +171,7 @@ describe('Webhook Trigger node', async () => {
ndv.actions.execute();
cy.wait(waitForWebhook);

cy.request('GET', '/webhook-test/' + webhookPath).then((response) => {
cy.request('GET', `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`).then((response) => {
expect(response.status).to.eq(201);
});
});
Expand Down Expand Up @@ -201,7 +200,7 @@ describe('Webhook Trigger node', async () => {
workflowPage.actions.executeWorkflow();
cy.wait(waitForWebhook);

cy.request('GET', '/webhook-test/' + webhookPath).then((response) => {
cy.request('GET', `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.MyValue).to.eq(1234);
});
Expand Down Expand Up @@ -246,7 +245,7 @@ describe('Webhook Trigger node', async () => {
workflowPage.actions.executeWorkflow();
cy.wait(waitForWebhook);

cy.request('GET', '/webhook-test/' + webhookPath).then((response) => {
cy.request('GET', `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`).then((response) => {
expect(response.status).to.eq(200);
expect(Object.keys(response.body).includes('data')).to.be.true;
});
Expand All @@ -263,7 +262,7 @@ describe('Webhook Trigger node', async () => {
});
ndv.actions.execute();
cy.wait(waitForWebhook);
cy.request('GET', '/webhook-test/' + webhookPath).then((response) => {
cy.request('GET', `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.MyValue).to.be.undefined;
});
Expand All @@ -287,7 +286,7 @@ describe('Webhook Trigger node', async () => {
cy.wait(waitForWebhook);
cy.request({
method: 'GET',
url: '/webhook-test/' + webhookPath,
url: `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`,
auth: {
user: 'username',
pass: 'password',
Expand All @@ -300,7 +299,7 @@ describe('Webhook Trigger node', async () => {
.then(() => {
cy.request({
method: 'GET',
url: '/webhook-test/' + webhookPath,
url: `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`,
auth: {
user: 'test',
pass: 'test',
Expand Down Expand Up @@ -330,7 +329,7 @@ describe('Webhook Trigger node', async () => {
cy.wait(waitForWebhook);
cy.request({
method: 'GET',
url: '/webhook-test/' + webhookPath,
url: `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`,
headers: {
test: 'wrong',
},
Expand All @@ -342,7 +341,7 @@ describe('Webhook Trigger node', async () => {
.then(() => {
cy.request({
method: 'GET',
url: '/webhook-test/' + webhookPath,
url: `${BACKEND_BASE_URL}/webhook-test/${webhookPath}`,
headers: {
test: 'test',
},
Expand Down