Skip to content

Commit

Permalink
#1624 Enable skipped tests to run in Cypress (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlyn authored Nov 11, 2023
1 parent 844562f commit af04fcf
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -695,12 +695,12 @@ export default class SVGCanvasUtilsDragObjects {
clearTimeout(this.startNodeInsertingInLink);
clearTimeout(this.startNodeAttachingToDetachedLinks);

// If the pointer hasn't moved and enableDragWithoutSelect we interpret
// If the pointer hasn't moved and enableDragWithoutSelect is enabled we interpret
// that as a select on the object.
if (draggingObjectData.dragOffsetX === 0 &&
draggingObjectData.dragOffsetY === 0 &&
this.ren.config.enableDragWithoutSelect) {
this.selectObjectSourceEvent(d3Event, d);
this.ren.selectObjectSourceEvent(d3Event, d);

} else {
if (draggingObjectData.dragRunningX !== 0 ||
Expand Down
4 changes: 0 additions & 4 deletions canvas_modules/harness/cypress/e2e/canvas/context-menu.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ describe("Test of context menu", function() {
});

it("Test context menu position is moved correctly with bottom panl open", function() {
// This test is being skipped because the canvas area needs to be fixed. At the moment
// it stretches underneath the bottom panel to the bottom of the common canvas div.
// It needs to be fixed so that, when the bottom panel is open, the canvas area only
// extends down to where the bottom panel begins."
cy.setCanvasConfig({ "selectedShowBottomPanel": true });

// Test the context menu postion is moved correctly
Expand Down
20 changes: 15 additions & 5 deletions canvas_modules/harness/cypress/e2e/canvas/drag.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,22 @@ describe("Test to see if selection works with dragWithoutSelect set to true", fu
cy.openCanvasDefinition("allTypesCanvas.json");
});

// The test below is being skipped because it fails on the build machine
// but not on a local MacBook Pro. The basic cause is that these two lines
// cy.ctrlOrCmdClickNode("Binding (entry) node");
// cy.ctrlOrCmdClickComment("The 4 different node types");
// are failing to select the nodes in quesiton. However, after many
// attempts trying to diagnose the problem I cannot find the root cause.
// I suspect it is probably happening because this is testing with
// selectedDragWithoutSelect === true which causes the selections to be
// handled in different way to selects where that option is false. That
// is, the selects have to be handled in the zoom handler (zoomEnd method).
// but I have no idea why that would be OK on the Mac but not on the build
// machine.
it.skip("Test dragging single and multiple selected nodes, " +
"test dragging a node and comment which is not selected", function() {
// Select one node
cy.getNodeWithLabel("Execution node").click();
cy.clickNode("Execution node");

// Verify only one node is selected
cy.verifyNodeIsSelected("Execution node");
Expand All @@ -183,11 +195,9 @@ describe("Test to see if selection works with dragWithoutSelect set to true", fu
cy.verifyNodeTransform("Execution node", 300, 349.5);

// Select 2 nodes and 1 comment
// TODO: Following code works on localhost but fails on travis - Skipping this test
// When selectedDragWithoutSelect: true, cy.ctrlOrCmdClickNode() and cy.ctrlOrCmdClickComment() are not working
cy.clickToolbarUndo();
cy.ctrlOrCmdClickNode("Binding (entry) node");
cy.ctrlOrCmdClickComment("The 4 different node types");
cy.ctrlOrCmdClickNode("Binding (entry) node"); // TDOD - fix these lines see comment above.
cy.ctrlOrCmdClickComment("The 4 different node types"); // TDOD - fix these lines see comment above.

// Verify 2 nodes and 1 comment is selected
cy.verifyNodeIsSelected("Execution node");
Expand Down
14 changes: 6 additions & 8 deletions canvas_modules/harness/cypress/e2e/canvas/supernode.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("Test supernode expanded to correct size", function() {
cy.openCanvasDefinition("supernodeCanvas.json");
});

it.skip("Test expanding supernode, rename supernode, create a nested supernode, " +
it("Test expanding supernode, rename supernode, create a nested supernode, " +
"expand and delete nested supernode, undo delete, verify number of nodes and links in all pipelines", function() {
// Expand supernode using context menu
cy.rightClickNode("Supernode");
Expand All @@ -102,7 +102,6 @@ describe("Test supernode expanded to correct size", function() {
cy.get("#harness-action-bar-sidepanel-api > a").click();

// Select multiple nodes in supernode
// TODO: cy.ctrlOrCmdClickNodeInSupernode() works on localhost but fails on travis - Skipping this test
cy.getNodeWithLabelInSupernode("Partition", "First Supernode").click();
cy.ctrlOrCmdClickNodeInSupernode("Distribution", "First Supernode");
cy.verifyNumberOfSelectedObjects(2);
Expand Down Expand Up @@ -151,7 +150,7 @@ describe("Test create supernode within a supernode with a new node from palette"
cy.openCanvasDefinition("supernodeCanvas.json");
});

it.skip("Add a node from palette to canvas, Cut node on canvas and paste it inside expanded supernode, " +
it("Add a node from palette to canvas, Cut node on canvas and paste it inside expanded supernode, " +
"Add a port to port link between nodes in supernode, Create a nested supernode, " +
"Delete supernode should remove nested subpipelines", function() {
// Double click Derive node on canvas
Expand Down Expand Up @@ -188,7 +187,6 @@ describe("Test create supernode within a supernode with a new node from palette"
cy.get("#harness-action-bar-sidepanel-api > a").click();

// Select multiple nodes in supernode
// TODO: cy.ctrlOrCmdClickNodeInSupernode() works on localhost but fails on travis - Skipping this test
cy.getNodeWithLabelInSupernode("Distribution", "First Supernode").click();
cy.ctrlOrCmdClickNodeInSupernode("Derive", "First Supernode");
cy.verifyNumberOfSelectedObjects(2);
Expand All @@ -213,8 +211,8 @@ describe("Test create supernode within a supernode with a new node from palette"
cy.verifyNumberOfLinksInPipeline(24);
cy.verifyNumberOfNodesInSupernode("First Supernode", 8);
cy.verifyNumberOfLinksInSupernode("First Supernode", 7);
cy.verifyNumberOfNodesInSupernodeNested("Second Supernode", "First Supernode", 4);
cy.verifyNumberOfLinksInSupernodeNested("Second Supernode", "First Supernode", 3);
cy.verifyNumberOfNodesInSupernodeNested("Second Supernode", "First Supernode", 5);
cy.verifyNumberOfLinksInSupernodeNested("Second Supernode", "First Supernode", 4);

// Delete supernode should remove nested subpipelines
cy.deleteNodeUsingKeyboard("First Supernode");
Expand All @@ -233,8 +231,8 @@ describe("Test create supernode within a supernode with a new node from palette"
cy.verifyNumberOfLinksInPipeline(24);
cy.verifyNumberOfNodesInSupernode("First Supernode", 8);
cy.verifyNumberOfLinksInSupernode("First Supernode", 7);
cy.verifyNumberOfNodesInSupernodeNested("Second Supernode", "First Supernode", 4);
cy.verifyNumberOfLinksInSupernodeNested("Second Supernode", "First Supernode", 3);
cy.verifyNumberOfNodesInSupernodeNested("Second Supernode", "First Supernode", 5);
cy.verifyNumberOfLinksInSupernodeNested("Second Supernode", "First Supernode", 4);
});
});

Expand Down
15 changes: 8 additions & 7 deletions canvas_modules/harness/cypress/e2e/canvas/toolbar.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,21 @@ describe("Test for toolbar resize", function() {
cy.openCanvasDefinition("commentColorCanvas.json");
});

it.skip("Test number of items in toolbar for different window sizes", function() {
// TODO: For given viewport size, number of items in toolbar doesn't match with chimp tests
// Skipping this test - travis shows different numbers for cy.verifyNumberOfItemsInToolbar()
it("Test number of items in toolbar for different window sizes", function() {
cy.viewport(400, 600);
cy.verifyNumberOfItemsInToolbar(8);

cy.viewport(500, 600);
cy.verifyNumberOfItemsInToolbar(8); // 10 items in chimp test
cy.verifyNumberOfItemsInToolbar(10);

cy.viewport(540, 600);
cy.verifyNumberOfItemsInToolbar(9); // 11 items in chimp test
cy.verifyNumberOfItemsInToolbar(11);

cy.viewport(580, 600);
cy.verifyNumberOfItemsInToolbar(9); // 12 items in chimp test
cy.verifyNumberOfItemsInToolbar(12);

cy.viewport(620, 600);
cy.verifyNumberOfItemsInToolbar(13);
cy.verifyNumberOfItemsInToolbar(12);

cy.viewport(660, 600);
});
Expand Down
58 changes: 26 additions & 32 deletions canvas_modules/harness/cypress/support/canvas/node-cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,46 +147,40 @@ function findGrpForLabel(grpArray, nodeLabel) {
return null;
}

function isGrpNotForLabel(grpArray, nodeLabel) {
for (let idx = 0; idx < grpArray.length; idx++) {
expect(grpArray[idx].__data__.label).to.not.equal(nodeLabel);
}
}

// posX and posY parameters is optional
// posX and posY parameters are optional
Cypress.Commands.add("clickNode", (nodeName, posX, posY) => {
cy.getNodeWithLabel(nodeName).click(posX, posY);
});


// posX and posY parameters is optional
Cypress.Commands.add("ctrlOrCmdClickNode", (nodeName, posX, posY) => {
// Get the os name to decide whether to click ctrl or cmd
cy.useCtrlOrCmdKey().then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.getNodeWithLabel(nodeName)
.click(posX, posY);
// Cancel the command/ctrl key press -- the documentation doesn't say
// this needs to be done but if it isn't the command key stays pressed down
// causing problems with subsequent selections.
cy.get("body")
.type(selectedKey, { release: true });
});
Cypress.Commands.add("ctrlOrCmdClickNode", (nodeName) => {
cy.useCtrlOrCmdKey()
.then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.getNodeWithLabel(nodeName)
.click();

// Cancel the command/ctrl key press -- the documentation doesn't say
// this needs to be done but if it isn't the command key stays pressed down
// causing problems with subsequent selections.
cy.get("body")
.type(selectedKey, { release: true });
});
});

Cypress.Commands.add("ctrlOrCmdClickNodeInSupernode", (nodeName, supernodeName) => {
// Get the os name to decide whether to click ctrl or cmd
cy.useCtrlOrCmdKey().then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.getNodeWithLabelInSupernode(nodeName, supernodeName)
.click();

// Cancel the command/ctrl key press
cy.get("body")
.type(selectedKey, { release: true });
});
cy.useCtrlOrCmdKey()
.then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.getNodeWithLabelInSupernode(nodeName, supernodeName)
.click();

// Cancel the command/ctrl key press
cy.get("body")
.type(selectedKey, { release: true });
});
});

// position parameter is optional
Expand Down
49 changes: 33 additions & 16 deletions canvas_modules/harness/cypress/support/canvas/verification-cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,22 +974,26 @@ Cypress.Commands.add("verifyNumberOfPortsOnNode", (nodeName, portType, noOfPorts
});

Cypress.Commands.add("verifyNumberOfItemsInToolbar", (noOfItems) => {
cy.get("#toolbar-items")
.find("li")
.its("length")
.then((totalItemsLength) => {
// Find hidden items length
cy.get("#actions-container")
.find("#overflow-action")
.eq(0)
.find(".toolbar-popover-list-hide")
.eq(0)
.find("li")
.its("length")
.then((hiddenItemsLength) => {
// Get number of visible items
const itemsVisible = totalItemsLength - hiddenItemsLength;
expect(itemsVisible).to.equal(noOfItems);
cy.get(".toolbar-left-bar .toolbar-item")
.then((leftBarItems) => {
cy.get(".toolbar-right-bar .toolbar-item")
.then((rightBarItems) => {
cy.get(".toolbar-overflow-item")
.then((toolbarOverflowItems) => {
const leftBarTopItemsCount = getCountToolbarItemsOnTopRow(leftBarItems);
const overflowTopItemsCount = getCountToolbarItemsOnTopRow(toolbarOverflowItems);
const rightBarTopItemsCount = getCountToolbarItemsOnTopRow(rightBarItems);

let visibleItemsCount = leftBarTopItemsCount + rightBarTopItemsCount;

// If there is one more overflow item than the left bar items
// then an overflow item is visible.
if (overflowTopItemsCount > leftBarTopItemsCount) {
visibleItemsCount++;
}

expect(visibleItemsCount).to.equal(noOfItems);
});
});
});
});
Expand Down Expand Up @@ -1375,6 +1379,19 @@ Cypress.Commands.add("verifyValueInCompareRange", (value, compareValue) => {
compareCloseTo(value, compareValue);
});

// Returns the count of toolbar items passed in that are on the top row of the
// toolbar. That is, where their offset top is 0.
function getCountToolbarItemsOnTopRow(items) {
let itemsVisible = 0;

for (let i = 0; i < items.length; i++) {
if (items[i].offsetTop === 0) {
itemsVisible++;
}
}
return itemsVisible;
}

function verifyPath(actualPath, expectedPath) {
const actualElements = actualPath.getAttribute("d").split(" ");
// console.log(actualPath.getAttribute("d"));
Expand Down

0 comments on commit af04fcf

Please sign in to comment.