mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
test(editor): Add e2e tests for executions preview (#5458)
* ✅ Added initial tests for executions preview * 🔥 Removing unneeded actions * 👌 Renaming test suite, moving mock executions logic to util function
This commit is contained in:
committed by
GitHub
parent
856238721a
commit
3b9eec77ec
40
cypress/e2e/20-workflow-executions.cy.ts
Normal file
40
cypress/e2e/20-workflow-executions.cy.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { WorkflowPage } from "../pages";
|
||||
import { WorkflowExecutionsTab } from "../pages/workflow-executions-tab";
|
||||
|
||||
const workflowPage = new WorkflowPage();
|
||||
const executionsTab = new WorkflowExecutionsTab();
|
||||
|
||||
// Test suite for executions tab
|
||||
describe('Current Workflow Executions', () => {
|
||||
before(() => {
|
||||
cy.resetAll();
|
||||
cy.skipSetup();
|
||||
workflowPage.actions.visit();
|
||||
cy.waitForLoad();
|
||||
cy.createFixtureWorkflow('Test_workflow_4_executions_view.json', `My test workflow`);
|
||||
createMockExecutions();
|
||||
});
|
||||
|
||||
it('should render executions tab correctly', () => {
|
||||
cy.waitForLoad();
|
||||
executionsTab.getters.executionListItems().should('have.length', 11);
|
||||
executionsTab.getters.successfulExecutionListItems().should('have.length', 9);
|
||||
executionsTab.getters.failedExecutionListItems().should('have.length', 2);
|
||||
executionsTab.getters.executionListItems().first().invoke('attr','class').should('match', /_active_/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
const createMockExecutions = () => {
|
||||
workflowPage.actions.turnOnManualExecutionSaving();
|
||||
executionsTab.actions.createManualExecutions(5);
|
||||
// Make some failed executions by enabling Code node with syntax error
|
||||
executionsTab.actions.toggleNodeEnabled('Error');
|
||||
executionsTab.actions.createManualExecutions(2);
|
||||
// Then add some more successful ones
|
||||
executionsTab.actions.toggleNodeEnabled('Error');
|
||||
executionsTab.actions.createManualExecutions(4);
|
||||
executionsTab.actions.switchToExecutionsTab();
|
||||
cy.waitForLoad();
|
||||
}
|
||||
69
cypress/fixtures/Test_workflow_4_executions_view.json
Normal file
69
cypress/fixtures/Test_workflow_4_executions_view.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"meta": {
|
||||
"instanceId": "6b85439d79c07750ea49eced4bc2a12b283cfcba0ab2917cd4f3fee36080e869"
|
||||
},
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.myNewField = 1;\n error\n}\n\nreturn $input.all();"
|
||||
},
|
||||
"id": "d0ab7e12-0e1b-4c08-8081-83107794f37d",
|
||||
"name": "Error",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
680,
|
||||
460
|
||||
],
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f5026145-66c1-463c-8ac8-46a1309a6632",
|
||||
"name": "On clicking 'execute'",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
460,
|
||||
460
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.myNewField = 1;\n}\n\nreturn $input.all();"
|
||||
},
|
||||
"id": "9926f884-348a-4af0-872e-dd7c8b3da811",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
900,
|
||||
460
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Error": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"On clicking 'execute'": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Error",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
40
cypress/pages/workflow-executions-tab.ts
Normal file
40
cypress/pages/workflow-executions-tab.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { BasePage } from "./base";
|
||||
import { WorkflowPage } from "./workflow";
|
||||
|
||||
const workflowPage = new WorkflowPage();
|
||||
|
||||
export class WorkflowExecutionsTab extends BasePage {
|
||||
getters = {
|
||||
executionsTabButton: () => cy.getByTestId('radio-button-executions'),
|
||||
executionsSidebar: () => cy.getByTestId('executions-sidebar'),
|
||||
autoRefreshCheckBox: () => cy.getByTestId('auto-refresh-checkbox'),
|
||||
executionsList: () => cy.getByTestId('current-executions-list'),
|
||||
executionListItems: () => this.getters.executionsList().find('div.execution-card'),
|
||||
successfulExecutionListItems: () => cy.get('[data-test-execution-status="success"]'),
|
||||
failedExecutionListItems: () => cy.get('[data-test-execution-status="error"]'),
|
||||
executionCard: (executionId: string) => cy.getByTestId(`execution-details-${executionId}`),
|
||||
executionPreviewDetails: () => cy.get('[data-test-id^="execution-preview-details-"]'),
|
||||
executionPreviewDetailsById: (executionId: string) => cy.getByTestId(`execution-preview-details-${executionId}`),
|
||||
executionPreviewTime: () => this.getters.executionPreviewDetails().find('[data-test-id="execution-time"]'),
|
||||
executionPreviewStatus: () => this.getters.executionPreviewDetails().find('[data-test-id="execution-preview-label"]'),
|
||||
executionPreviewId: () => this.getters.executionPreviewDetails().find('[data-test-id="execution-preview-id"]'),
|
||||
};
|
||||
actions = {
|
||||
toggleNodeEnabled: (nodeName: string) => {
|
||||
workflowPage.getters.canvasNodeByName(nodeName).click();
|
||||
cy.get('body').type('d', { force: true });
|
||||
},
|
||||
createManualExecutions: (count: number) => {
|
||||
for (let i=0; i<count; i++) {
|
||||
workflowPage.actions.executeWorkflow();
|
||||
cy.wait(300);
|
||||
}
|
||||
},
|
||||
switchToExecutionsTab: () => {
|
||||
this.getters.executionsTabButton().click();
|
||||
},
|
||||
switchToEditorTab: () => {
|
||||
workflowPage.getters.editorTabButton().click();
|
||||
}
|
||||
};
|
||||
};
|
||||
@@ -103,6 +103,7 @@ export class WorkflowPage extends BasePage {
|
||||
cy.get(
|
||||
`.connection-actions[data-source-node="${sourceNodeName}"][data-target-node="${targetNodeName}"]`,
|
||||
),
|
||||
editorTabButton: () => cy.getByTestId('radio-button-workflow'),
|
||||
};
|
||||
actions = {
|
||||
visit: () => {
|
||||
@@ -230,5 +231,15 @@ export class WorkflowPage extends BasePage {
|
||||
.first()
|
||||
.click({ force: true });
|
||||
},
|
||||
turnOnManualExecutionSaving: () => {
|
||||
this.getters.workflowMenu().click();
|
||||
this.getters.workflowMenuItemSettings().click();
|
||||
this.getters
|
||||
.workflowSettingsSaveManualExecutionsSelect()
|
||||
.find('li:contains("Yes")')
|
||||
.click({ force: true });
|
||||
this.getters.workflowSettingsSaveButton().click();
|
||||
this.getters.successToast().should('exist');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user