From dd652c0b0d0fa820b3339b747cc175dda648290b Mon Sep 17 00:00:00 2001 From: Michael Auerswald Date: Tue, 7 Feb 2023 12:41:44 +0100 Subject: [PATCH] ci: Add E2E test for scheduled trigger (#5391) * scheduler e2e test and switch to main mode * adjust e2e options * rolling back config changes --- cypress/e2e/15-scheduler-node.cy.ts | 75 +++++++++++++++++++++++++++++ packages/cli/src/config/index.ts | 1 + 2 files changed, 76 insertions(+) create mode 100644 cypress/e2e/15-scheduler-node.cy.ts diff --git a/cypress/e2e/15-scheduler-node.cy.ts b/cypress/e2e/15-scheduler-node.cy.ts new file mode 100644 index 0000000000..65dae8f4d7 --- /dev/null +++ b/cypress/e2e/15-scheduler-node.cy.ts @@ -0,0 +1,75 @@ +import { WorkflowPage, WorkflowsPage, NDV } from '../pages'; + +const workflowsPage = new WorkflowsPage(); +const workflowPage = new WorkflowPage(); +const ndv = new NDV(); + +describe('Schedule Trigger node', async () => { + beforeEach(() => { + cy.resetAll(); + cy.skipSetup(); + }); + + it('should execute and return the execution timestamp', () => { + cy.visit(workflowsPage.url); + + workflowsPage.actions.createWorkflowFromCard(); + workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger'); + workflowPage.actions.openNode('Schedule Trigger'); + ndv.actions.execute(); + ndv.getters.outputPanel().contains('timestamp'); + ndv.getters.backToCanvas().click(); + }); + + it('should execute once per second when activated', () => { + cy.visit(workflowsPage.url); + + workflowsPage.actions.createWorkflowFromCard(); + workflowPage.actions.renameWorkflow('Schedule Trigger Workflow'); + workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger'); + workflowPage.actions.openNode('Schedule Trigger'); + + cy.getByTestId('parameter-input-field').click(); + cy.getByTestId('parameter-input-field') + .find('.el-select-dropdown') + .find('.option-headline') + .contains('Seconds') + .click(); + cy.getByTestId('parameter-input-secondsInterval').clear().type('1'); + + ndv.getters.backToCanvas().click(); + workflowPage.actions.saveWorkflowOnButtonClick(); + workflowPage.actions.activateWorkflow(); + workflowPage.getters.activatorSwitch().should('have.class', 'is-checked'); + + cy.request("GET", '/rest/workflows').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) => { + 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'); + }); + }); + }); + }); +}); diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts index a797125c17..b2ed5a245e 100644 --- a/packages/cli/src/config/index.ts +++ b/packages/cli/src/config/index.ts @@ -11,6 +11,7 @@ if (inE2ETests) { process.env = { E2E_TESTS: 'true', N8N_USER_FOLDER: mkdtempSync(join(tmpdir(), 'n8n-e2e-')), + EXECUTIONS_PROCESS: 'main', N8N_DIAGNOSTICS_ENABLED: 'false', N8N_PUBLIC_API_DISABLED: 'true', EXTERNAL_FRONTEND_HOOKS_URLS: '',