2023-01-27 01:18:15 -08:00
|
|
|
import {
|
|
|
|
CODE_NODE_NAME,
|
|
|
|
MANUAL_TRIGGER_NODE_NAME,
|
|
|
|
META_KEY,
|
|
|
|
SCHEDULE_TRIGGER_NODE_NAME,
|
2023-09-19 03:16:35 -07:00
|
|
|
EDIT_FIELDS_SET_NODE_NAME,
|
2023-11-21 06:20:15 -08:00
|
|
|
INSTANCE_MEMBERS,
|
|
|
|
INSTANCE_OWNER,
|
2023-01-27 01:18:15 -08:00
|
|
|
} from '../constants';
|
2022-12-05 05:31:14 -08:00
|
|
|
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
2023-06-27 04:05:20 -07:00
|
|
|
import { WorkflowsPage as WorkflowsPageClass } from '../pages/workflows';
|
2023-09-13 00:00:35 -07:00
|
|
|
import { getVisibleSelect } from '../utils';
|
2023-09-19 03:16:35 -07:00
|
|
|
import { WorkflowExecutionsTab } from '../pages';
|
2022-12-05 05:31:14 -08:00
|
|
|
|
|
|
|
const NEW_WORKFLOW_NAME = 'Something else';
|
2022-12-20 01:33:20 -08:00
|
|
|
const DUPLICATE_WORKFLOW_NAME = 'Duplicated workflow';
|
2023-01-27 01:18:15 -08:00
|
|
|
const DUPLICATE_WORKFLOW_TAG = 'Duplicate';
|
2022-12-05 05:31:14 -08:00
|
|
|
|
|
|
|
const WorkflowPage = new WorkflowPageClass();
|
2023-06-27 04:05:20 -07:00
|
|
|
const WorkflowPages = new WorkflowsPageClass();
|
2023-09-13 00:00:35 -07:00
|
|
|
const executionsTab = new WorkflowExecutionsTab();
|
2022-12-05 05:31:14 -08:00
|
|
|
|
|
|
|
describe('Workflow Actions', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
beforeEach(() => {
|
2022-12-05 05:31:14 -08:00
|
|
|
WorkflowPage.actions.visit();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to save on button click', () => {
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
WorkflowPage.getters.isWorkflowSaved();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should save workflow on keyboard shortcut', () => {
|
|
|
|
WorkflowPage.actions.saveWorkflowUsingKeyboardShortcut();
|
|
|
|
WorkflowPage.getters.isWorkflowSaved();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be able to activate unsaved workflow', () => {
|
|
|
|
WorkflowPage.getters.activatorSwitch().find('input').first().should('be.disabled');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not be able to activate workflow without trigger node', () => {
|
|
|
|
// Manual trigger is not enough to activate the workflow
|
|
|
|
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
WorkflowPage.getters.activatorSwitch().find('input').first().should('be.disabled');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should be able to activate workflow', () => {
|
|
|
|
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
WorkflowPage.actions.activateWorkflow();
|
|
|
|
WorkflowPage.getters.isWorkflowActivated();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should save new workflow after renaming', () => {
|
|
|
|
WorkflowPage.actions.renameWorkflow(NEW_WORKFLOW_NAME);
|
|
|
|
WorkflowPage.getters.isWorkflowSaved();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should rename workflow', () => {
|
|
|
|
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
WorkflowPage.actions.renameWorkflow(NEW_WORKFLOW_NAME);
|
|
|
|
WorkflowPage.getters.isWorkflowSaved();
|
2022-12-15 07:39:59 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowNameInputContainer()
|
|
|
|
.invoke('attr', 'title')
|
|
|
|
.should('eq', NEW_WORKFLOW_NAME);
|
2022-12-05 05:31:14 -08:00
|
|
|
});
|
|
|
|
|
2023-06-27 04:05:20 -07:00
|
|
|
it('should not save workflow if canvas is loading', () => {
|
|
|
|
let interceptCalledCount = 0;
|
|
|
|
|
2023-07-28 00:51:07 -07:00
|
|
|
// There's no way in Cypress to check if intercept was not called
|
2023-06-27 04:05:20 -07:00
|
|
|
// so we'll count the number of times it was called
|
2023-07-28 00:51:07 -07:00
|
|
|
cy.intercept('PATCH', '/rest/workflows/*', () => {
|
|
|
|
interceptCalledCount++;
|
|
|
|
}).as('saveWorkflow');
|
2023-06-27 04:05:20 -07:00
|
|
|
|
|
|
|
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
cy.intercept(
|
|
|
|
{
|
|
|
|
url: '/rest/workflows/*',
|
|
|
|
method: 'GET',
|
|
|
|
middleware: true,
|
|
|
|
},
|
|
|
|
(req) => {
|
|
|
|
// Delay the response to give time for the save to be triggered
|
|
|
|
req.on('response', async (res) => {
|
2023-07-28 00:51:07 -07:00
|
|
|
await new Promise((resolve) => setTimeout(resolve, 2000));
|
2023-06-27 04:05:20 -07:00
|
|
|
res.send();
|
2023-07-28 00:51:07 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
2023-06-27 04:05:20 -07:00
|
|
|
cy.reload();
|
|
|
|
cy.get('.el-loading-mask').should('exist');
|
|
|
|
cy.get('body').type(META_KEY, { release: false }).type('s');
|
|
|
|
cy.get('body').type(META_KEY, { release: false }).type('s');
|
|
|
|
cy.get('body').type(META_KEY, { release: false }).type('s');
|
|
|
|
cy.wrap(null).then(() => expect(interceptCalledCount).to.eq(0));
|
2023-11-03 07:22:37 -07:00
|
|
|
cy.waitForLoad();
|
2023-06-27 04:05:20 -07:00
|
|
|
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
|
|
|
|
cy.get('body').type(META_KEY, { release: false }).type('s');
|
|
|
|
cy.wait('@saveWorkflow');
|
|
|
|
cy.wrap(null).then(() => expect(interceptCalledCount).to.eq(1));
|
2023-07-28 00:51:07 -07:00
|
|
|
});
|
2024-04-04 00:59:02 -07:00
|
|
|
|
|
|
|
it('should not save workflow twice when save is in progress', () => {
|
|
|
|
// This happens when users click save button from workflow name input
|
|
|
|
// In this case blur on the input saves the workflow and then click on the button saves it again
|
|
|
|
WorkflowPage.actions.visit();
|
2024-04-18 22:50:18 -07:00
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowNameInput()
|
|
|
|
.invoke('val')
|
|
|
|
.then((oldName) => {
|
|
|
|
WorkflowPage.getters.workflowNameInputContainer().click();
|
|
|
|
WorkflowPage.getters.workflowNameInput().type('{selectall}');
|
|
|
|
WorkflowPage.getters.workflowNameInput().type('Test');
|
|
|
|
WorkflowPage.getters.saveButton().click();
|
|
|
|
WorkflowPage.getters.workflowNameInput().should('have.value', 'Test');
|
|
|
|
cy.visit(WorkflowPages.url);
|
|
|
|
// There should be no workflow with the old name (duplicate save)
|
|
|
|
WorkflowPages.getters.workflowCards().contains(String(oldName)).should('not.exist');
|
|
|
|
});
|
2024-04-04 00:59:02 -07:00
|
|
|
});
|
|
|
|
|
2022-12-05 05:31:14 -08:00
|
|
|
it('should copy nodes', () => {
|
|
|
|
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
|
2022-12-14 01:33:44 -08:00
|
|
|
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
|
2022-12-07 09:16:38 -08:00
|
|
|
WorkflowPage.getters.canvasNodes().should('have.have.length', 2);
|
|
|
|
|
2022-12-15 07:39:59 -08:00
|
|
|
cy.get('#node-creator').should('not.exist');
|
2022-12-20 01:33:20 -08:00
|
|
|
cy.get('body').type(META_KEY, { delay: 500, release: false }).type('a');
|
2022-12-07 09:16:38 -08:00
|
|
|
cy.get('.jtk-drag-selected').should('have.length', 2);
|
2022-12-20 01:33:20 -08:00
|
|
|
cy.get('body').type(META_KEY, { delay: 500, release: false }).type('c');
|
2022-12-05 05:31:14 -08:00
|
|
|
WorkflowPage.getters.successToast().should('exist');
|
|
|
|
});
|
|
|
|
|
2024-01-26 06:09:50 -08:00
|
|
|
it('should paste nodes (both current and old node versions)', () => {
|
2022-12-15 07:39:59 -08:00
|
|
|
cy.fixture('Test_workflow-actions_paste-data.json').then((data) => {
|
2022-12-05 05:31:14 -08:00
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
2024-01-26 06:09:50 -08:00
|
|
|
WorkflowPage.actions.zoomToFit();
|
|
|
|
WorkflowPage.getters.canvasNodes().should('have.length', 5);
|
|
|
|
WorkflowPage.getters.nodeConnections().should('have.length', 5);
|
2022-12-05 05:31:14 -08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-12-14 08:13:03 -08:00
|
|
|
it('should update workflow settings', () => {
|
2023-06-27 04:05:20 -07:00
|
|
|
cy.visit(WorkflowPages.url);
|
|
|
|
WorkflowPages.getters.workflowCards().then((cards) => {
|
|
|
|
const totalWorkflows = cards.length;
|
|
|
|
|
|
|
|
WorkflowPage.actions.visit();
|
|
|
|
// Open settings dialog
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
WorkflowPage.getters.workflowMenu().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenu().click();
|
|
|
|
WorkflowPage.getters.workflowMenuItemSettings().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenuItemSettings().click();
|
|
|
|
// Change all settings
|
|
|
|
// totalWorkflows + 1 (current workflow) + 1 (no workflow option)
|
2023-07-28 00:51:07 -07:00
|
|
|
WorkflowPage.getters.workflowSettingsErrorWorkflowSelect().click();
|
|
|
|
getVisibleSelect()
|
2023-06-27 04:05:20 -07:00
|
|
|
.find('li')
|
2023-07-28 00:51:07 -07:00
|
|
|
.should('have.length', totalWorkflows + 2);
|
|
|
|
getVisibleSelect().find('li').last().click({ force: true });
|
|
|
|
WorkflowPage.getters.workflowSettingsTimezoneSelect().click();
|
|
|
|
getVisibleSelect().find('li').should('exist');
|
|
|
|
getVisibleSelect().find('li').eq(1).click({ force: true });
|
|
|
|
WorkflowPage.getters.workflowSettingsSaveFiledExecutionsSelect().click();
|
|
|
|
getVisibleSelect().find('li').should('have.length', 3);
|
|
|
|
getVisibleSelect().find('li').last().click({ force: true });
|
|
|
|
WorkflowPage.getters.workflowSettingsSaveSuccessExecutionsSelect().click();
|
|
|
|
getVisibleSelect().find('li').should('have.length', 3);
|
|
|
|
getVisibleSelect().find('li').last().click({ force: true });
|
|
|
|
WorkflowPage.getters.workflowSettingsSaveManualExecutionsSelect().click();
|
|
|
|
getVisibleSelect().find('li').should('have.length', 3);
|
|
|
|
getVisibleSelect().find('li').last().click({ force: true });
|
|
|
|
WorkflowPage.getters.workflowSettingsSaveExecutionProgressSelect().click();
|
|
|
|
getVisibleSelect().find('li').should('have.length', 3);
|
|
|
|
getVisibleSelect().find('li').last().click({ force: true });
|
2023-06-27 04:05:20 -07:00
|
|
|
WorkflowPage.getters.workflowSettingsTimeoutWorkflowSwitch().click();
|
|
|
|
WorkflowPage.getters.workflowSettingsTimeoutForm().find('input').first().type('1');
|
|
|
|
// Save settings
|
|
|
|
WorkflowPage.getters.workflowSettingsSaveButton().click();
|
|
|
|
WorkflowPage.getters.workflowSettingsModal().should('not.exist');
|
|
|
|
WorkflowPage.getters.successToast().should('exist');
|
2023-07-28 00:51:07 -07:00
|
|
|
});
|
2022-12-14 08:13:03 -08:00
|
|
|
});
|
2022-12-20 01:33:20 -08:00
|
|
|
|
|
|
|
it('should not be able to delete unsaved workflow', () => {
|
|
|
|
WorkflowPage.getters.workflowMenu().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenu().click();
|
2023-01-27 01:18:15 -08:00
|
|
|
WorkflowPage.getters.workflowMenuItemDelete().closest('li').should('have.class', 'is-disabled');
|
2022-12-20 01:33:20 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete workflow', () => {
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
WorkflowPage.getters.workflowMenu().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenu().click();
|
|
|
|
WorkflowPage.getters.workflowMenuItemDelete().click();
|
|
|
|
cy.get('div[role=dialog][aria-modal=true]').should('be.visible');
|
|
|
|
cy.get('button.btn--confirm').should('be.visible').click();
|
|
|
|
WorkflowPage.getters.successToast().should('exist');
|
|
|
|
cy.url().should('include', '/workflow/new');
|
|
|
|
});
|
|
|
|
|
2023-03-30 05:34:04 -07:00
|
|
|
describe('duplicate workflow', () => {
|
|
|
|
function duplicateWorkflow() {
|
|
|
|
WorkflowPage.getters.workflowMenu().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenu().click();
|
|
|
|
WorkflowPage.getters.workflowMenuItemDuplicate().click();
|
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().should('be.visible');
|
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().find('input').first().should('be.visible');
|
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().find('input').first().type('{selectall}');
|
|
|
|
WorkflowPage.getters
|
|
|
|
.duplicateWorkflowModal()
|
|
|
|
.find('input')
|
|
|
|
.first()
|
|
|
|
.type(DUPLICATE_WORKFLOW_NAME);
|
|
|
|
WorkflowPage.getters
|
|
|
|
.duplicateWorkflowModal()
|
|
|
|
.find('.el-select__tags input')
|
|
|
|
.type(DUPLICATE_WORKFLOW_TAG);
|
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().find('.el-select__tags input').type('{enter}');
|
2023-07-28 00:51:07 -07:00
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().find('.el-select__tags input').type('{esc}');
|
2023-03-30 05:34:04 -07:00
|
|
|
WorkflowPage.getters
|
|
|
|
.duplicateWorkflowModal()
|
|
|
|
.find('button')
|
|
|
|
.contains('Duplicate')
|
|
|
|
.should('be.visible');
|
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().find('button').contains('Duplicate').click();
|
|
|
|
WorkflowPage.getters.errorToast().should('not.exist');
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
// Stub window.open so new tab is not getting opened
|
|
|
|
cy.window().then((win) => {
|
|
|
|
cy.stub(win, 'open').as('open');
|
|
|
|
});
|
|
|
|
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
2023-01-27 01:18:15 -08:00
|
|
|
});
|
2022-12-20 01:33:20 -08:00
|
|
|
|
2023-03-30 05:34:04 -07:00
|
|
|
it('should duplicate unsaved workflow', () => {
|
|
|
|
duplicateWorkflow();
|
|
|
|
});
|
2023-05-26 08:15:06 -07:00
|
|
|
|
2023-03-30 05:34:04 -07:00
|
|
|
it('should duplicate saved workflow', () => {
|
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
duplicateWorkflow();
|
|
|
|
});
|
2022-12-20 01:33:20 -08:00
|
|
|
});
|
2023-09-13 00:00:35 -07:00
|
|
|
|
|
|
|
it('should keep endpoint click working when switching between execution and editor tab', () => {
|
|
|
|
cy.intercept('GET', '/rest/executions?filter=*').as('getExecutions');
|
|
|
|
|
|
|
|
WorkflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
2023-09-19 03:16:35 -07:00
|
|
|
WorkflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
|
2023-09-13 00:00:35 -07:00
|
|
|
WorkflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
|
2023-09-19 03:16:35 -07:00
|
|
|
WorkflowPage.getters.canvasNodePlusEndpointByName(EDIT_FIELDS_SET_NODE_NAME).click();
|
2023-09-13 00:00:35 -07:00
|
|
|
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
|
|
|
|
cy.get('body').type('{esc}');
|
|
|
|
|
|
|
|
executionsTab.actions.switchToExecutionsTab();
|
2024-04-18 22:50:18 -07:00
|
|
|
cy.wait(['@getExecutions']);
|
2023-09-13 00:00:35 -07:00
|
|
|
cy.wait(500);
|
|
|
|
executionsTab.actions.switchToEditorTab();
|
|
|
|
|
2023-09-19 03:16:35 -07:00
|
|
|
WorkflowPage.getters.canvasNodePlusEndpointByName(EDIT_FIELDS_SET_NODE_NAME).click();
|
2023-09-13 00:00:35 -07:00
|
|
|
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
|
|
|
|
});
|
2022-12-05 05:31:14 -08:00
|
|
|
});
|
2023-11-21 06:20:15 -08:00
|
|
|
|
|
|
|
describe('Menu entry Push To Git', () => {
|
|
|
|
it('should not show up in the menu for members', () => {
|
|
|
|
cy.signin(INSTANCE_MEMBERS[0]);
|
|
|
|
cy.visit(WorkflowPages.url);
|
|
|
|
WorkflowPage.actions.visit();
|
|
|
|
WorkflowPage.getters.workflowMenuItemGitPush().should('not.exist');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should show up for owners', () => {
|
|
|
|
cy.signin(INSTANCE_OWNER);
|
|
|
|
cy.visit(WorkflowPages.url);
|
|
|
|
WorkflowPage.actions.visit();
|
|
|
|
WorkflowPage.getters.workflowMenuItemGitPush().should('exist');
|
|
|
|
});
|
|
|
|
});
|