2023-01-27 01:18:15 -08:00
|
|
|
import {
|
|
|
|
CODE_NODE_NAME,
|
|
|
|
MANUAL_TRIGGER_NODE_NAME,
|
|
|
|
META_KEY,
|
|
|
|
SCHEDULE_TRIGGER_NODE_NAME,
|
|
|
|
} from '../constants';
|
2022-12-05 05:31:14 -08:00
|
|
|
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
|
|
|
|
|
|
|
const NEW_WORKFLOW_NAME = 'Something else';
|
2023-03-14 02:30:13 -07:00
|
|
|
const IMPORT_WORKFLOW_URL = 'https://gist.githubusercontent.com/OlegIvaniv/010bd3f45c8a94f8eb7012e663a8b671/raw/3afea1aec15573cc168d9af7e79395bd76082906/test-workflow.json';
|
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();
|
|
|
|
|
|
|
|
describe('Workflow Actions', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
before(() => {
|
2022-12-05 05:31:14 -08:00
|
|
|
cy.skipSetup();
|
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
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should paste nodes', () => {
|
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));
|
|
|
|
WorkflowPage.getters.canvasNodes().should('have.have.length', 2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-12-14 08:13:03 -08:00
|
|
|
it('should import workflow from url', () => {
|
|
|
|
WorkflowPage.getters.workflowMenu().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenu().click();
|
|
|
|
WorkflowPage.getters.workflowMenuItemImportFromURLItem().should('be.visible');
|
|
|
|
WorkflowPage.getters.workflowMenuItemImportFromURLItem().click();
|
|
|
|
cy.get('.el-message-box').should('be.visible');
|
|
|
|
cy.get('.el-message-box').find('input').type(IMPORT_WORKFLOW_URL);
|
|
|
|
cy.get('body').type('{enter}');
|
2023-03-16 02:19:12 -07:00
|
|
|
cy.waitForLoad(false)
|
2022-12-14 08:13:03 -08:00
|
|
|
WorkflowPage.actions.zoomToFit();
|
|
|
|
WorkflowPage.getters.canvasNodes().should('have.length', 2);
|
|
|
|
WorkflowPage.getters.nodeConnections().should('have.length', 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should import workflow from file', () => {
|
2022-12-15 07:39:59 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowImportInput()
|
|
|
|
.selectFile('cypress/fixtures/Test_workflow-actions_paste-data.json', { force: true });
|
2023-03-16 02:19:12 -07:00
|
|
|
cy.waitForLoad(false)
|
2022-12-14 08:13:03 -08:00
|
|
|
WorkflowPage.actions.zoomToFit();
|
|
|
|
WorkflowPage.getters.canvasNodes().should('have.length', 2);
|
|
|
|
WorkflowPage.getters.nodeConnections().should('have.length', 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should update workflow settings', () => {
|
2023-03-02 07:50:21 -08:00
|
|
|
WorkflowPage.actions.visit();
|
2022-12-14 08:13:03 -08:00
|
|
|
// 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
|
2023-05-26 08:15:06 -07:00
|
|
|
WorkflowPage.getters.workflowSettingsErrorWorkflowSelect().find('li').should('have.length', 7);
|
2022-12-15 07:39:59 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsErrorWorkflowSelect()
|
|
|
|
.find('li')
|
|
|
|
.last()
|
|
|
|
.click({ force: true });
|
2022-12-14 08:13:03 -08:00
|
|
|
WorkflowPage.getters.workflowSettingsTimezoneSelect().find('li').should('exist');
|
|
|
|
WorkflowPage.getters.workflowSettingsTimezoneSelect().find('li').eq(1).click({ force: true });
|
2022-12-15 07:39:59 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveFiledExecutionsSelect()
|
|
|
|
.find('li')
|
|
|
|
.should('have.length', 3);
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveFiledExecutionsSelect()
|
|
|
|
.find('li')
|
|
|
|
.last()
|
|
|
|
.click({ force: true });
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveSuccessExecutionsSelect()
|
|
|
|
.find('li')
|
|
|
|
.should('have.length', 3);
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveSuccessExecutionsSelect()
|
|
|
|
.find('li')
|
|
|
|
.last()
|
|
|
|
.click({ force: true });
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveManualExecutionsSelect()
|
|
|
|
.find('li')
|
|
|
|
.should('have.length', 3);
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveManualExecutionsSelect()
|
|
|
|
.find('li')
|
|
|
|
.last()
|
|
|
|
.click({ force: true });
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveExecutionProgressSelect()
|
|
|
|
.find('li')
|
|
|
|
.should('have.length', 3);
|
|
|
|
WorkflowPage.getters
|
|
|
|
.workflowSettingsSaveExecutionProgressSelect()
|
|
|
|
.find('li')
|
|
|
|
.last()
|
|
|
|
.click({ force: true });
|
2022-12-14 08:13:03 -08: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');
|
|
|
|
});
|
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}');
|
|
|
|
WorkflowPage.getters.duplicateWorkflowModal().find('.el-select__tags input').type('{enter}');
|
|
|
|
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
|
|
|
});
|
2022-12-05 05:31:14 -08:00
|
|
|
});
|