test(editor): Add more tests for workflow actions (no-changelog) (#4931)

*  Added test for importing workflow from URL
*  Added test for importing workflow from file
*  Added test ids for workflow settings elements
*  Added test for changing workflow settings
*  Adding back missing test id for delete node button
This commit is contained in:
Milorad FIlipović 2022-12-14 17:13:03 +01:00 committed by GitHub
parent d5b06ab3d6
commit 9956547504
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 4 deletions

View file

@ -3,6 +3,7 @@ import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
const NEW_WORKFLOW_NAME = 'Something else';
const TEST_WF_TAGS = ['Tag 1', 'Tag 2', 'Tag 3'];
const IMPORT_WORKFLOW_URL = 'https://www.jsonkeeper.com/b/FNB0#.json';
const WorkflowPage = new WorkflowPageClass();
@ -110,4 +111,57 @@ describe('Workflow Actions', () => {
});
});
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}');
cy.waitForLoad();
WorkflowPage.actions.zoomToFit();
WorkflowPage.getters.canvasNodes().should('have.length', 2);
WorkflowPage.getters.nodeConnections().should('have.length', 1);
});
it('should import workflow from file', () => {
WorkflowPage.getters.workflowImportInput().selectFile(
'cypress/fixtures/Test_workflow-actions_paste-data.json',
{ force: true }
);
cy.waitForLoad();
WorkflowPage.actions.zoomToFit();
WorkflowPage.getters.canvasNodes().should('have.length', 2);
WorkflowPage.getters.nodeConnections().should('have.length', 1);
});
it('should update workflow settings', () => {
// 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
WorkflowPage.getters.workflowSettingsErrorWorkflowSelect().find('li').should('have.length', 2);
WorkflowPage.getters.workflowSettingsErrorWorkflowSelect().find('li').last().click({ force: true });
WorkflowPage.getters.workflowSettingsTimezoneSelect().find('li').should('exist');
WorkflowPage.getters.workflowSettingsTimezoneSelect().find('li').eq(1).click({ force: true });
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 });
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');
});
});

View file

@ -40,6 +40,24 @@ export class WorkflowPage extends BasePage {
disabledNodes: () => cy.get('.node-box.disabled'),
nodeNameContainerNDV: () => cy.getByTestId('node-title-container'),
nodeRenameInput: () => cy.getByTestId('node-rename-input'),
// Workflow menu items
workflowMenuItemDuplicate: () => cy.getByTestId('workflow-menu-item-duplicate'),
workflowMenuItemDownload: () => cy.getByTestId('workflow-menu-item-download'),
workflowMenuItemImportFromURLItem: () => cy.getByTestId('workflow-menu-item-import-from-url'),
workflowMenuItemImportFromFile: () => cy.getByTestId('workflow-menu-item-import-from-file'),
workflowMenuItemSettings: () => cy.getByTestId('workflow-menu-item-settings'),
workflowMenuItemDelete: () => cy.getByTestId('workflow-menu-item-delete'),
// Workflow settings dialog elements
workflowSettingsModal: () => cy.getByTestId('workflow-settings-dialog'),
workflowSettingsErrorWorkflowSelect: () => cy.getByTestId('workflow-settings-error-workflow'),
workflowSettingsTimezoneSelect: () => cy.getByTestId('workflow-settings-timezone'),
workflowSettingsSaveFiledExecutionsSelect: () => cy.getByTestId('workflow-settings-save-failed-executions'),
workflowSettingsSaveSuccessExecutionsSelect: () => cy.getByTestId('workflow-settings-save-success-executions'),
workflowSettingsSaveManualExecutionsSelect: () => cy.getByTestId('workflow-settings-save-manual-executions'),
workflowSettingsSaveExecutionProgressSelect: () => cy.getByTestId('workflow-settings-save-execution-progress'),
workflowSettingsTimeoutWorkflowSwitch: () => cy.getByTestId('workflow-settings-timeout-workflow'),
workflowSettingsTimeoutForm: () => cy.getByTestId('workflow-settings-timeout-form'),
workflowSettingsSaveButton: () => cy.getByTestId('workflow-settings-save-button').find('button'),
};
actions = {
visit: () => {

View file

@ -24,6 +24,7 @@
[$style.hasCustomStyling]: item.customClass !== undefined,
[item.customClass]: item.customClass !== undefined,
}"
:data-test-id="`workflow-menu-item-${item.id}`"
>
<span v-if="item.icon" :class="$style.icon">
<n8n-icon :icon="item.icon" :size="iconSize" />

View file

@ -87,7 +87,7 @@
</div>
<div class="node-options no-select-on-click" v-if="!isReadOnly" v-show="!hideActions">
<div v-touch:tap="deleteNode" class="option" :title="$locale.baseText('node.deleteNode')">
<div v-touch:tap="deleteNode" class="option" :title="$locale.baseText('node.deleteNode')" data-test-id="delete-node-button">
<font-awesome-icon icon="trash" />
</div>
<div

View file

@ -12,7 +12,7 @@
:scrollable="true"
>
<template #content>
<div v-loading="isLoading" class="workflow-settings">
<div v-loading="isLoading" class="workflow-settings" data-test-id="workflow-settings-dialog">
<el-row>
<el-col :span="10" class="setting-name">
{{ $locale.baseText('workflowSettings.errorWorkflow') + ':' }}
@ -30,6 +30,7 @@
size="medium"
filterable
:limit-popper-width="true"
data-test-id="workflow-settings-error-workflow"
>
<n8n-option
v-for="item in workflows"
@ -108,6 +109,7 @@
size="medium"
filterable
:limit-popper-width="true"
data-test-id="workflow-settings-timezone"
>
<n8n-option
v-for="timezone of timezones"
@ -136,6 +138,7 @@
size="medium"
filterable
:limit-popper-width="true"
data-test-id="workflow-settings-save-failed-executions"
>
<n8n-option
v-for="option of saveDataErrorExecutionOptions"
@ -164,6 +167,7 @@
size="medium"
filterable
:limit-popper-width="true"
data-test-id="workflow-settings-save-success-executions"
>
<n8n-option
v-for="option of saveDataSuccessExecutionOptions"
@ -192,6 +196,7 @@
size="medium"
filterable
:limit-popper-width="true"
data-test-id="workflow-settings-save-manual-executions"
>
<n8n-option
v-for="option of saveManualOptions"
@ -220,6 +225,7 @@
size="medium"
filterable
:limit-popper-width="true"
data-test-id="workflow-settings-save-execution-progress"
>
<n8n-option
v-for="option of saveExecutionProgressOptions"
@ -248,11 +254,12 @@
:value="workflowSettings.executionTimeout > -1"
@change="toggleTimeout"
active-color="#13ce66"
data-test-id="workflow-settings-timeout-workflow"
></el-switch>
</div>
</el-col>
</el-row>
<div v-if="workflowSettings.executionTimeout > -1">
<div v-if="workflowSettings.executionTimeout > -1" data-test-id="workflow-settings-timeout-form">
<el-row>
<el-col :span="10" class="setting-name">
{{ $locale.baseText('workflowSettings.timeoutAfter') + ':' }}
@ -300,7 +307,7 @@
</div>
</template>
<template #footer>
<div class="action-buttons">
<div class="action-buttons" data-test-id="workflow-settings-save-button">
<n8n-button
:label="$locale.baseText('workflowSettings.save')"
size="large"