2023-02-07 03:41:44 -08:00
|
|
|
import { WorkflowPage, WorkflowsPage, NDV } from '../pages';
|
2023-06-15 04:40:23 -07:00
|
|
|
import { BACKEND_BASE_URL } from '../constants';
|
2023-07-28 00:51:07 -07:00
|
|
|
import { getVisibleSelect } from '../utils';
|
2024-06-10 06:49:50 -07:00
|
|
|
import type { ExecutionResponse } from '../types';
|
2023-02-07 03:41:44 -08:00
|
|
|
|
|
|
|
const workflowsPage = new WorkflowsPage();
|
|
|
|
const workflowPage = new WorkflowPage();
|
|
|
|
const ndv = new NDV();
|
|
|
|
|
2024-06-10 06:49:50 -07:00
|
|
|
describe('Schedule Trigger node', () => {
|
2023-05-26 08:15:06 -07:00
|
|
|
beforeEach(() => {
|
|
|
|
workflowPage.actions.visit();
|
|
|
|
});
|
|
|
|
|
2023-02-07 03:41:44 -08:00
|
|
|
it('should execute and return the execution timestamp', () => {
|
|
|
|
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', () => {
|
|
|
|
workflowPage.actions.renameWorkflow('Schedule Trigger Workflow');
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger');
|
|
|
|
workflowPage.actions.openNode('Schedule Trigger');
|
|
|
|
|
|
|
|
cy.getByTestId('parameter-input-field').click();
|
2023-07-28 00:51:07 -07:00
|
|
|
getVisibleSelect().find('.option-headline').contains('Seconds').click();
|
2023-02-07 03:41:44 -08:00
|
|
|
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');
|
|
|
|
|
2023-06-15 04:40:23 -07:00
|
|
|
cy.url().then((url) => {
|
|
|
|
const workflowId = url.split('/').pop();
|
|
|
|
|
|
|
|
cy.wait(1200);
|
2024-06-10 06:49:50 -07:00
|
|
|
cy.request<ExecutionResponse>('GET', `${BACKEND_BASE_URL}/rest/executions`).then(
|
|
|
|
(response) => {
|
2023-06-15 04:40:23 -07:00
|
|
|
expect(response.status).to.eq(200);
|
2024-06-10 06:49:50 -07:00
|
|
|
expect(workflowId).to.not.be.undefined;
|
2023-06-15 04:40:23 -07:00
|
|
|
expect(response.body.data.results.length).to.be.greaterThan(0);
|
|
|
|
const matchingExecutions = response.body.data.results.filter(
|
2024-06-10 06:49:50 -07:00
|
|
|
(execution) => execution.workflowId === workflowId,
|
2023-06-15 04:40:23 -07:00
|
|
|
);
|
2024-06-10 06:49:50 -07:00
|
|
|
expect(matchingExecutions).to.have.length(1);
|
|
|
|
|
|
|
|
cy.wait(1200);
|
|
|
|
cy.request<ExecutionResponse>('GET', `${BACKEND_BASE_URL}/rest/executions`).then(
|
|
|
|
(response1) => {
|
|
|
|
expect(response1.status).to.eq(200);
|
|
|
|
expect(response1.body.data.results.length).to.be.greaterThan(0);
|
|
|
|
const matchingExecutions1 = response1.body.data.results.filter(
|
|
|
|
(execution: any) => execution.workflowId === workflowId,
|
|
|
|
);
|
|
|
|
expect(matchingExecutions1).to.have.length(2);
|
2023-06-15 04:40:23 -07:00
|
|
|
|
2024-06-10 06:49:50 -07:00
|
|
|
workflowPage.actions.activateWorkflow();
|
|
|
|
workflowPage.getters.activatorSwitch().should('not.have.class', 'is-checked');
|
|
|
|
cy.visit(workflowsPage.url);
|
|
|
|
workflowsPage.actions.deleteWorkFlow('Schedule Trigger Workflow');
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
2023-06-15 04:40:23 -07:00
|
|
|
});
|
2023-02-07 03:41:44 -08:00
|
|
|
});
|
|
|
|
});
|