Skip to content

Commit

Permalink
Remove skips and add command to check for v2 of canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegIvaniv committed Oct 21, 2024
1 parent 607a7b0 commit f87587a
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 67 deletions.
20 changes: 10 additions & 10 deletions cypress/e2e/10-undo-redo.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('Undo/Redo', () => {
WorkflowPage.actions.visit();
});

// FIXME: Fix redo connections
it.skip('should undo/redo adding node in the middle', () => {
// FIXME: Canvas V2: Fix redo connections
it('should undo/redo adding node in the middle', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.actions.addNodeBetweenNodes(
Expand Down Expand Up @@ -116,8 +116,8 @@ describe('Undo/Redo', () => {
});


// FIXME: Fix undo/redo moving nodes
it.skip('should undo/redo moving nodes', () => {
// FIXME: Canvas V2: Fix moving of nodes via e2e tests
it('should undo/redo moving nodes', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.canvasNodeByName(CODE_NODE_NAME).then(($node) => {
Expand Down Expand Up @@ -156,8 +156,8 @@ describe('Undo/Redo', () => {
WorkflowPage.actions.hitRedo();
WorkflowPage.getters.nodeConnections().should('have.length', 0);
});
// FIXME: Fix disconnecting by moving
it.skip('should undo/redo deleting a connection by moving it away', () => {
// FIXME: Canvas V2: Fix disconnecting by moving
it('should undo/redo deleting a connection by moving it away', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
cy.drag('.rect-input-endpoint.jtk-endpoint-connected', [0, -100]);
Expand Down Expand Up @@ -205,8 +205,8 @@ describe('Undo/Redo', () => {
WorkflowPage.getters.disabledNodes().should('have.length', 2);
});

// FIXME: Fix undo renaming node
it.skip('should undo/redo renaming node using keyboard shortcut', () => {
// FIXME: Canvas V2: Fix undo renaming node
it('should undo/redo renaming node using keyboard shortcut', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.canvasNodes().last().click();
Expand Down Expand Up @@ -244,8 +244,8 @@ describe('Undo/Redo', () => {
});
});

// FIXME: Figure out why moving doesn't work from e2e
it.skip('should undo/redo multiple steps', () => {
// FIXME: Canvas V2: Figure out why moving doesn't work from e2e
it('should undo/redo multiple steps', () => {
WorkflowPage.actions.addNodeToCanvas(SCHEDULE_TRIGGER_NODE_NAME);
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
// WorkflowPage.actions.addNodeToCanvas(SET_NODE_NAME);
Expand Down
33 changes: 16 additions & 17 deletions cypress/e2e/12-canvas-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ describe('Canvas Actions', () => {
WorkflowPage.actions.visit();
});

// FIXME: Missing execute button if no nodes
it.skip('should render canvas', () => {
// FIXME: Canvas V2: Missing execute button if no nodes
it('should render canvas', () => {
WorkflowPage.getters.nodeView().should('be.visible');
WorkflowPage.getters.canvasPlusButton().should('be.visible');
WorkflowPage.getters.zoomToFitButton().should('be.visible');
Expand All @@ -26,8 +26,8 @@ describe('Canvas Actions', () => {
WorkflowPage.getters.executeWorkflowButton().should('be.visible');
});

// FIXME: Fix changing of connection
it.skip('should connect and disconnect a simple node', () => {
// FIXME: Canvas V2: Fix changing of connection
it('should connect and disconnect a simple node', () => {
WorkflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
WorkflowPage.getters.nodeViewBackground().click(600, 200, { force: true });
WorkflowPage.getters.nodeConnections().should('have.length', 1);
Expand Down Expand Up @@ -75,7 +75,6 @@ describe('Canvas Actions', () => {
it('should add a connected node using plus endpoint', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.getters.canvasNodePlusEndpointByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click()
// cy.get('.plus-endpoint').should('be.visible').click();
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
WorkflowPage.getters.nodeCreatorSearchBar().type(CODE_NODE_NAME);
WorkflowPage.getters.nodeCreatorSearchBar().type('{enter}');
Expand Down Expand Up @@ -115,7 +114,7 @@ describe('Canvas Actions', () => {
it('should add disconnected node if nothing is selected', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
// Deselect nodes
WorkflowPage.getters.nodeView().click(100, 100);
WorkflowPage.getters.nodeView().click({ force: true});
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
WorkflowPage.getters.canvasNodes().should('have.length', 2);
WorkflowPage.getters.nodeConnections().should('have.length', 0);
Expand Down Expand Up @@ -166,8 +165,8 @@ describe('Canvas Actions', () => {
WorkflowPage.getters.nodeConnections().should('have.length', 0);
});

// FIXME: Fix disconnecting of connection by dragging it
it.skip('should delete a connection by moving it away from endpoint', () => {
// FIXME: Canvas V2: Fix disconnecting of connection by dragging it
it('should delete a connection by moving it away from endpoint', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.getters.canvasNodeByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click();
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
Expand Down Expand Up @@ -235,8 +234,8 @@ describe('Canvas Actions', () => {
WorkflowPage.getters.selectedNodes().should('have.length', 0);
});

// FIXME: Selection via arrow keys is broken
it.skip('should select nodes using arrow keys', () => {
// FIXME: Canvas V2: Selection via arrow keys is broken
it('should select nodes using arrow keys', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.getters.canvasNodeByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click();
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
Expand All @@ -258,8 +257,8 @@ describe('Canvas Actions', () => {
)
});

// FIXME: Selection via shift and arrow keys is broken
it.skip('should select nodes using shift and arrow keys', () => {
// FIXME: Canvas V2: Selection via shift and arrow keys is broken
it('should select nodes using shift and arrow keys', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.getters.canvasNodeByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click();
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
Expand All @@ -268,20 +267,20 @@ describe('Canvas Actions', () => {
WorkflowPage.getters.selectedNodes().should('have.length', 2);
});

// FIXME: Fix select & deselect
it.skip('should not break lasso selection when dragging node action buttons', () => {
// FIXME: Canvas V2: Fix select & deselect
it('should not break lasso selection when dragging node action buttons', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.getters
.canvasNodes()
.last()
.findChildByTestId('execute-node-button')
.as('executeNodeButton');
cy.drag('@executeNodeButton', [200, 200], { realMouse: true });
cy.drag('@executeNodeButton', [200, 200]);
WorkflowPage.actions.testLassoSelection([100, 100], [200, 200]);
});

// FIXME: Fix select & deselect
it.skip('should not break lasso selection with multiple clicks on node action buttons', () => {
// FIXME: Canvas V2: Fix select & deselect
it('should not break lasso selection with multiple clicks on node action buttons', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.actions.testLassoSelection([100, 100], [200, 200]);
WorkflowPage.getters.canvasNodes().last().as('lastNode');
Expand Down
30 changes: 15 additions & 15 deletions cypress/e2e/12-canvas.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Canvas Node Manipulation and Navigation', () => {
WorkflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true);
WorkflowPage.getters
.nodeView()
.click((i + 1) * 200, (i + 1) * 200);
.click((i + 1) * 200, (i + 1) * 200, { force: true });
}
WorkflowPage.actions.zoomToFit();

Expand Down Expand Up @@ -216,8 +216,8 @@ describe('Canvas Node Manipulation and Navigation', () => {
WorkflowPage.getters.canvasNodes().should('have.length', 0);
});

// FIXME: Figure out how to test moving of the node
it.skip('should move node', () => {
// FIXME: Canvas V2: Figure out how to test moving of the node
it('should move node', () => {
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
WorkflowPage.getters.canvasNodeByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click();
WorkflowPage.actions.addNodeToCanvas(CODE_NODE_NAME);
Expand All @@ -229,15 +229,15 @@ describe('Canvas Node Manipulation and Navigation', () => {
.then(($node) => {
const { left, top } = $node.position();

cy.ifCanvasVersion(
() => cy.drag('[data-test-id="canvas-node"].jtk-drag-selected', [50, 150], {
clickToFinish: true,
}),
() => cy.drag('.vue-flow__node', [300, 300], {
// clickToFinish: true,
if (cy.isCanvasV2()) {
cy.drag('.vue-flow__node', [300, 300], {
realMouse: true,
}),
)
});
} else {
cy.drag('[data-test-id="canvas-node"].jtk-drag-selected', [50, 150], {
clickToFinish: true,
});
}

WorkflowPage.getters
.canvasNodes()
Expand Down Expand Up @@ -443,8 +443,8 @@ describe('Canvas Node Manipulation and Navigation', () => {
WorkflowPage.getters.canvasNodes().should('have.length', 2);
WorkflowPage.getters.nodeConnections().should('have.length', 1);
});
// FIXME: Credentials should show issue on the first open
it.skip('should remove unknown credentials on pasting workflow', () => {
// FIXME: Canvas V2: Credentials should show issue on the first open
it('should remove unknown credentials on pasting workflow', () => {
cy.fixture('workflow-with-unknown-credentials.json').then((data) => {
cy.get('body').paste(JSON.stringify(data));

Expand All @@ -456,8 +456,8 @@ describe('Canvas Node Manipulation and Navigation', () => {
});
});

// FIXME: Unknown nodes should still render connection endpoints
it.skip('should render connections correctly if unkown nodes are present', () => {
// FIXME: Canvas V2: Unknown nodes should still render connection endpoints
it('should render connections correctly if unkown nodes are present', () => {
const unknownNodeName = 'Unknown node';
cy.createFixtureWorkflow('workflow-with-unknown-nodes.json', 'Unknown nodes');

Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/19-execution.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ describe('Execution', () => {
workflowPage.getters.clearExecutionDataButton().should('not.exist');
});

// FIXME: Webhook should show waiting state but it doesn't
it.skip('should test webhook workflow stop', () => {
// FIXME: Canvas V2: Webhook should show waiting state but it doesn't
it('should test webhook workflow stop', () => {
cy.createFixtureWorkflow('Webhook_wait_set.json');

// Check workflow buttons
Expand Down Expand Up @@ -295,8 +295,8 @@ describe('Execution', () => {
});
});

// FIXME: Missing pinned states for `edge-label-wrapper`
describe.skip('connections should be colored differently for pinned data', () => {
// FIXME: Canvas V2: Missing pinned states for `edge-label-wrapper`
describe('connections should be colored differently for pinned data', () => {
beforeEach(() => {
cy.createFixtureWorkflow('Schedule_pinned.json');
workflowPage.actions.deselectAll();
Expand Down
23 changes: 7 additions & 16 deletions cypress/pages/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class WorkflowPage extends BasePage {
.should('have.length.greaterThan', 0)
.findChildByTestId('node-issues'),
getEndpointSelector: (type: 'input' | 'output' | 'plus', nodeName: string, index = 0) => {
if (window.localStorage.getItem('NodeView.version') === '2') {
if (cy.isCanvasV2()) {
if (type === 'input') {
return `[data-test-id="canvas-node-input-handle"][data-node-name="${nodeName}"][data-handle-index="${index}"]`;
}
Expand Down Expand Up @@ -154,14 +154,6 @@ export class WorkflowPage extends BasePage {
),
() => cy.get(`[data-test-id="edge-label-wrapper"][data-source-node-name="${sourceNodeName}"][data-target-node-name="${targetNodeName}"]`)
),
// getConnectionStateBetweenNodes: (sourceNodeName: string, targetNodeName: string) => cy.ifCanvasVersion(
// () => {
// return this.getters.getConnectionBetweenNodes(sourceNodeName, targetNodeName).its('class')
// },
// () => {
// return this.getters.getConnectionBetweenNodes(sourceNodeName, targetNodeName).its('class')
// }
// ),
getConnectionActionsBetweenNodes: (sourceNodeName: string, targetNodeName: string) =>
cy.ifCanvasVersion(
() => cy.get(
Expand All @@ -178,13 +170,13 @@ export class WorkflowPage extends BasePage {
colors: () => cy.getByTestId('color'),
contextMenuAction: (action: string) => cy.getByTestId(`context-menu-item-${action}`),
getNodeLeftPosition: (element: JQuery<HTMLElement>) => {
if (window.localStorage.getItem('NodeView.version') === '2') {
if (cy.isCanvasV2()) {
return parseFloat(element.parent().css('transform').split(',')[4]);
}
return parseFloat(element.css('left'));
},
getNodeTopPosition: (element: JQuery<HTMLElement>) => {
if (window.localStorage.getItem('NodeView.version') === '2') {
if (cy.isCanvasV2()) {
return parseFloat(element.parent().css('transform').split(',')[5]);
}
return parseFloat(element.css('top'));
Expand Down Expand Up @@ -261,10 +253,10 @@ export class WorkflowPage extends BasePage {
: this.getters.nodeViewBackground();

if (method === 'right-click') {
target.rightclick(nodeTypeName ? 'center' : 'topLeft');
target.rightclick(nodeTypeName ? 'center' : 'topLeft', { force: true });
} else {
target.realHover();
target.find('[data-test-id="overflow-node-button"]').click();
target.find('[data-test-id="overflow-node-button"]').click({ force: true });
}
},
openNode: (nodeTypeName: string) => {
Expand Down Expand Up @@ -394,7 +386,7 @@ export class WorkflowPage extends BasePage {
cy.window().then((win) => {
// Pinch-to-zoom simulates a 'wheel' event with ctrlKey: true (same as zooming by scrolling)
this.getters.nodeView().trigger('wheel', {
// force: true,
force: true,
bubbles: true,
ctrlKey: true,
pageX: win.innerWidth / 2,
Expand All @@ -406,8 +398,7 @@ export class WorkflowPage extends BasePage {
},
/** Certain keyboard shortcuts are not possible on Cypress via a simple `.type`, and some delays are needed to emulate these events */
hitComboShortcut: (modifier: string, key: string) => {
cy.get('body').type(modifier, { delay: 100, release: false, force: true })
cy.get('body').type(key, { force: true });
cy.get('body').wait(100).type(modifier, { delay: 100, release: false }).type(key);
},
hitUndo: () => {
this.actions.hitComboShortcut(`{${META_KEY}}`, 'z');
Expand Down
10 changes: 5 additions & 5 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ Cypress.Commands.add('getByTestId', (selector, ...args) => {
return cy.get(`[data-test-id="${selector}"]`, ...args);
});

Cypress.Commands.add('isCanvasV2', () => {
return Cypress.env('NODE_VIEW_VERSION') === 2;
})

Cypress.Commands.add('ifCanvasVersion', (getterV1, getterV2) => {
if (window.localStorage.getItem('NodeView.version') === '2') {
return getterV2();
}
return getterV1();
return cy.isCanvasV2() ? getterV2() : getterV1();
});

Cypress.Commands.add(
Expand Down Expand Up @@ -169,7 +170,6 @@ Cypress.Commands.add('drag', (selector, pos, options) => {
element.realMouseMove(newPosition.x, newPosition.y);
element.realMouseUp();
} else {
element.click({force: true});
element.trigger('mousedown', { force: true });
element.trigger('mousemove', {
which: 1,
Expand Down
1 change: 1 addition & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare global {
selector: string,
...args: Array<Partial<Loggable & Timeoutable & Withinable & Shadow> | undefined>
): Chainable<JQuery<HTMLElement>>;
isCanvasV2(): boolean;
ifCanvasVersion(
getterV1: () => Chainable<JQuery<HTMLElement>>,
getterV2: () => Chainable<JQuery<HTMLElement>>,
Expand Down

0 comments on commit f87587a

Please sign in to comment.