Skip to content

Commit

Permalink
feat(core): Improve debugging of sub-workflows (n8n-io#11602)
Browse files Browse the repository at this point in the history
  • Loading branch information
mutdmour authored Nov 14, 2024
1 parent f4ca4b7 commit fd3254d
Show file tree
Hide file tree
Showing 36 changed files with 1,844 additions and 266 deletions.
29 changes: 29 additions & 0 deletions cypress/composables/executions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Getters
*/

export const getExecutionsSidebar = () => cy.getByTestId('executions-sidebar');

export const getWorkflowExecutionPreviewIframe = () => cy.getByTestId('workflow-preview-iframe');

export const getExecutionPreviewBody = () =>
getWorkflowExecutionPreviewIframe()
.its('0.contentDocument.body')
.then((el) => cy.wrap(el));

export const getExecutionPreviewBodyNodes = () =>
getExecutionPreviewBody().findChildByTestId('canvas-node');

export const getExecutionPreviewBodyNodesByName = (name: string) =>
getExecutionPreviewBody().findChildByTestId('canvas-node').filter(`[data-name="${name}"]`).eq(0);

export function getExecutionPreviewOutputPanelRelatedExecutionLink() {
return getExecutionPreviewBody().findChildByTestId('related-execution-link');
}

/**
* Actions
*/

export const openExecutionPreviewNode = (name: string) =>
getExecutionPreviewBodyNodesByName(name).dblclick();
33 changes: 33 additions & 0 deletions cypress/composables/ndv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,38 @@ export function getOutputTableRow(row: number) {
return getOutputTableRows().eq(row);
}

export function getOutputTableHeaders() {
return getOutputPanelDataContainer().find('table thead th');
}

export function getOutputTableHeaderByText(text: string) {
return getOutputTableHeaders().contains(text);
}

export function getOutputTbodyCell(row: number, col: number) {
return getOutputTableRows().eq(row).find('td').eq(col);
}

export function getOutputRunSelector() {
return getOutputPanel().findChildByTestId('run-selector');
}

export function getOutputRunSelectorInput() {
return getOutputRunSelector().find('input');
}

export function getOutputPanelTable() {
return getOutputPanelDataContainer().get('table');
}

export function getOutputPanelItemsCount() {
return getOutputPanel().getByTestId('ndv-items-count');
}

export function getOutputPanelRelatedExecutionLink() {
return getOutputPanel().getByTestId('related-execution-link');
}

/**
* Actions
*/
Expand Down Expand Up @@ -90,3 +118,8 @@ export function setParameterSelectByContent(name: string, content: string) {
getParameterInputByName(name).realClick();
getVisibleSelect().find('.option-headline').contains(content).click();
}

export function changeOutputRunSelector(runName: string) {
getOutputRunSelector().click();
getVisibleSelect().find('.el-select-dropdown__item').contains(runName).click();
}
24 changes: 24 additions & 0 deletions cypress/composables/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ export function getCanvasNodes() {
);
}

export function getSaveButton() {
return cy.getByTestId('workflow-save-button');
}

export function getZoomToFitButton() {
return cy.getByTestId('zoom-to-fit');
}

/**
* Actions
*/
Expand Down Expand Up @@ -170,3 +178,19 @@ export function clickManualChatButton() {
export function openNode(nodeName: string) {
getNodeByName(nodeName).dblclick();
}

export function saveWorkflowOnButtonClick() {
cy.intercept('POST', '/rest/workflows').as('createWorkflow');
getSaveButton().should('contain', 'Save');
getSaveButton().click();
getSaveButton().should('contain', 'Saved');
cy.url().should('not.have.string', '/new');
}

export function pasteWorkflow(workflow: object) {
cy.get('body').paste(JSON.stringify(workflow));
}

export function clickZoomToFit() {
getZoomToFitButton().click();
}
71 changes: 42 additions & 29 deletions cypress/e2e/24-ndv-paired-item.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,31 @@ describe('NDV', () => {

ndv.getters.inputTableRow(1).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.inputTableRow(1).realHover();
ndv.actions.dragMainPanelToRight();
ndv.getters.inputTableRow(1).realMouseMove(10, 1);
ndv.getters.outputTableRow(4).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.inputTableRow(2).realHover();
ndv.getters.inputTableRow(2).realMouseMove(10, 1);
ndv.getters.outputTableRow(2).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.inputTableRow(3).realHover();
ndv.getters.inputTableRow(3).realMouseMove(10, 1);
ndv.getters.outputTableRow(6).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

// output to input
ndv.getters.outputTableRow(1).realHover();
ndv.actions.dragMainPanelToLeft();
ndv.getters.outputTableRow(1).realMouseMove(10, 1);
ndv.getters.inputTableRow(4).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.outputTableRow(4).realHover();
ndv.getters.outputTableRow(4).realMouseMove(10, 1);
ndv.getters.inputTableRow(1).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.outputTableRow(2).realHover();
ndv.getters.outputTableRow(2).realMouseMove(10, 1);
ndv.getters.inputTableRow(2).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.outputTableRow(6).realHover();
ndv.getters.outputTableRow(6).realMouseMove(10, 1);
ndv.getters.inputTableRow(3).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.outputTableRow(1).realHover();
ndv.getters.outputTableRow(1).realMouseMove(10, 1);
ndv.getters.inputTableRow(4).invoke('attr', 'data-test-id').should('equal', 'hovering-item');
});

Expand All @@ -75,31 +77,32 @@ describe('NDV', () => {
ndv.actions.switchInputMode('Table');
ndv.actions.switchOutputMode('Table');

ndv.getters.backToCanvas().realHover(); // reset to default hover
ndv.getters.backToCanvas().realMouseMove(10, 1); // reset to default hover
ndv.getters.outputHoveringItem().should('not.exist');
ndv.getters.parameterExpressionPreview('value').should('include.text', '1111');

ndv.actions.selectInputNode('Set1');
ndv.getters.backToCanvas().realHover(); // reset to default hover
ndv.getters.backToCanvas().realMouseMove(10, 1); // reset to default hover

ndv.getters.inputTableRow(1).should('have.text', '1000');

ndv.getters.inputTableRow(1).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.inputTableRow(1).realHover();
cy.wait(50);
ndv.actions.dragMainPanelToRight();
ndv.getters.inputTbodyCell(1, 0).realMouseMove(10, 1);
ndv.getters.outputHoveringItem().should('have.text', '1000');
ndv.getters.parameterExpressionPreview('value').should('include.text', '1000');

ndv.actions.selectInputNode('Sort');
ndv.actions.dragMainPanelToLeft();
ndv.actions.changeOutputRunSelector('1 of 2 (6 items)');
ndv.getters.backToCanvas().realHover(); // reset to default hover
ndv.getters.backToCanvas().realMouseMove(10, 1); // reset to default hover

ndv.getters.inputTableRow(1).should('have.text', '1111');

ndv.getters.inputTableRow(1).invoke('attr', 'data-test-id').should('equal', 'hovering-item');
ndv.getters.inputTableRow(1).realHover();
cy.wait(50);
ndv.actions.dragMainPanelToRight();
ndv.getters.inputTbodyCell(1, 0).realMouseMove(10, 1);
ndv.getters.outputHoveringItem().should('have.text', '1111');
ndv.getters.parameterExpressionPreview('value').should('include.text', '1111');
});
Expand Down Expand Up @@ -132,20 +135,22 @@ describe('NDV', () => {

ndv.getters.inputTableRow(1).should('have.text', '1111');
ndv.getters.inputTableRow(1).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.actions.dragMainPanelToLeft();
ndv.getters.outputTableRow(1).should('have.text', '1111');
ndv.getters.outputTableRow(1).realHover();
ndv.getters.outputTableRow(1).realMouseMove(10, 1);

ndv.getters.outputTableRow(3).should('have.text', '4444');
ndv.getters.outputTableRow(3).realHover();
ndv.getters.outputTableRow(3).realMouseMove(10, 1);

ndv.getters.inputTableRow(3).should('have.text', '4444');
ndv.getters.inputTableRow(3).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.actions.changeOutputRunSelector('2 of 2 (6 items)');
cy.wait(50);

ndv.getters.inputTableRow(1).should('have.text', '1000');
ndv.getters.inputTableRow(1).realHover();
ndv.actions.dragMainPanelToRight();
ndv.getters.inputTableRow(1).realMouseMove(10, 1);

ndv.getters.outputTableRow(1).should('have.text', '1000');
ndv.getters
Expand All @@ -155,7 +160,8 @@ describe('NDV', () => {
.should('equal', 'hovering-item');

ndv.getters.outputTableRow(3).should('have.text', '2000');
ndv.getters.outputTableRow(3).realHover();
ndv.actions.dragMainPanelToLeft();
ndv.getters.outputTableRow(3).realMouseMove(10, 1);

ndv.getters.inputTableRow(3).should('have.text', '2000');

Expand All @@ -175,14 +181,15 @@ describe('NDV', () => {

ndv.actions.switchOutputBranch('False Branch (2 items)');
ndv.getters.outputTableRow(1).should('have.text', '8888');
ndv.getters.outputTableRow(1).realHover();
ndv.actions.dragMainPanelToLeft();
ndv.getters.outputTableRow(1).realMouseMove(10, 1);

ndv.getters.inputTableRow(5).should('have.text', '8888');

ndv.getters.inputTableRow(5).invoke('attr', 'data-test-id').should('equal', 'hovering-item');

ndv.getters.outputTableRow(2).should('have.text', '9999');
ndv.getters.outputTableRow(2).realHover();
ndv.getters.outputTableRow(2).realMouseMove(10, 1);

ndv.getters.inputTableRow(6).should('have.text', '9999');

Expand All @@ -192,29 +199,35 @@ describe('NDV', () => {

workflowPage.actions.openNode('Set5');

ndv.actions.dragMainPanelToRight();
ndv.actions.switchInputBranch('True Branch');

ndv.actions.dragMainPanelToLeft();
ndv.actions.changeOutputRunSelector('1 of 2 (2 items)');
ndv.getters.outputTableRow(1).should('have.text', '8888');
ndv.getters.outputTableRow(1).realHover();
cy.wait(100);
ndv.getters.outputTableRow(1).realMouseMove(10, 1);
ndv.getters.inputHoveringItem().should('not.exist');

ndv.getters.inputTableRow(1).should('have.text', '1111');
ndv.getters.inputTableRow(1).realHover();
cy.wait(100);

ndv.actions.dragMainPanelToRight();
ndv.getters.inputTableRow(1).realMouseMove(10, 1);
ndv.getters.outputHoveringItem().should('not.exist');

ndv.actions.switchInputBranch('False Branch');
ndv.getters.inputTableRow(1).should('have.text', '8888');
ndv.getters.inputTableRow(1).realHover();
ndv.actions.dragMainPanelToRight();
ndv.getters.inputTableRow(1).realMouseMove(10, 1);

ndv.actions.dragMainPanelToLeft();
ndv.actions.changeOutputRunSelector('2 of 2 (4 items)');
ndv.getters.outputTableRow(1).should('have.text', '1111');
ndv.getters.outputTableRow(1).realHover();
ndv.getters.outputTableRow(1).realMouseMove(10, 1);

ndv.actions.changeOutputRunSelector('1 of 2 (2 items)');
ndv.getters.inputTableRow(1).should('have.text', '8888');
ndv.getters.inputTableRow(1).realHover();
ndv.actions.dragMainPanelToRight();
ndv.getters.inputTableRow(1).realMouseMove(10, 1);
ndv.getters.outputHoveringItem().should('have.text', '8888');
// todo there's a bug here need to fix ADO-534
// ndv.getters.outputHoveringItem().should('not.exist');
Expand Down
Loading

0 comments on commit fd3254d

Please sign in to comment.