Skip to content

Commit

Permalink
Merge branch 'main' into resize-rightflyout
Browse files Browse the repository at this point in the history
  • Loading branch information
srikant-ch5 committed Nov 11, 2024
2 parents f31a076 + 32f2a74 commit eea68de
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
9 changes: 3 additions & 6 deletions canvas_modules/harness/cypress/e2e/canvas/zoom.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ describe("Test zoomToReveal function returns the appropriate zoom object for a n
cy.verifyCanvasTransform(undefined);
// Zooming the canvas.
cy.clickToolbarZoomOut();
// TODO -- write function to test these +/- 2 px.
// cy.verifyCanvasTransform("translate(45.81818181818181,32.22727272727275) scale(0.9090909090909091)");
cy.verifyCanvasTransform("translate(45.81818181818181,32.22727272727275) scale(0.9090909090909091)");
// Test get Zoom to reveal & ZoomTo
cy.selectEntryFromDropdown("Histogram");
cy.setXPercentOffset(70);
Expand Down Expand Up @@ -145,15 +144,13 @@ describe("Test zoomToReveal function returns the appropriate zoom object for a l
cy.verifyCanvasTransform(undefined);
// Zooming the canvas.
cy.clickToolbarZoomOut();
// TODO -- write function to test these +/- 2 px.
// cy.verifyCanvasTransform("translate(45.81818181818181,32.22727272727275) scale(0.9090909090909091)");
cy.verifyCanvasTransform("translate(45.81818181818181,32.22727272727275) scale(0.9090909090909091)");
// Test get Zoom to reveal & ZoomTo
cy.selectEntryFromDropdown("Binding (entry) node-Execution node");
cy.setXPercentOffset(70);
cy.setYPercentOffset(60);
cy.submitAPI();
// TODO -- write function to test these +/- 2 px.
// cy.verifyCanvasTransform("translate(498.32727272727266,290.85454545454536) scale(0.9090909090909091)");
cy.verifyCanvasTransform("translate(498.32727272727266,290.85454545454536) scale(0.9090909090909091)");
});
});

Expand Down
32 changes: 30 additions & 2 deletions canvas_modules/harness/cypress/support/canvas/verification-cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,22 @@ Cypress.Commands.add("verifyNotificationIconType", (type) => {
Cypress.Commands.add("verifyCanvasTransform", (movString) => {
cy.get("#canvas-div-0 .d3-canvas-group")
.invoke("attr", "transform")
.should("eq", movString);
.should((actualTransformString) => {
// Verify the movString passed is a string
if (typeof movString === "string") {
const expectedValues = parseTransformString(movString);
const actualValues = parseTransformString(actualTransformString);
// Compare each part of the transform with compareRange
compareCloseTo(actualValues.translateX, expectedValues.translateX);
compareCloseTo(actualValues.translateY, expectedValues.translateY);
compareCloseTo(actualValues.scale, expectedValues.scale);
} else if (typeof movString === "undefined") {
expect(actualTransformString).to.be.undefined;
} else {
throw new Error("Expected movString to be a string or undefined");
}
});

});

Cypress.Commands.add("verifyNotificationCounter", (count) => {
Expand Down Expand Up @@ -1437,7 +1452,7 @@ Cypress.Commands.add("verifyNotificationCenterDoesntExist", (hidden) => {
Cypress.Commands.add("verifyNotificationCenterContent", (id, content) => {
if (typeof content === "string" && content.length > 0) {
cy.get(".notification-panel-" + id).should("contain", content);
} else if (typeof content === "string" && content.length === 0) {
} else if (typeof content === "string" && content.length === 0) {
cy.get(".notification-panel-" + id).should("be.empty");
} else {
cy.get(".notification-panel-" + id).should("not.exist");
Expand Down Expand Up @@ -1491,6 +1506,19 @@ function verifyPath(actualPath, expectedPath) {
}
}

function parseTransformString(transformString) {
const translateMatch = transformString.match(/translate\(([^,]+),([^)]+)\)/);
const scaleMatch = transformString.match(/scale\(([^)]+)\)/);
if (!translateMatch || !scaleMatch) {
throw new Error("invalid string format");
}
return {
translateX: parseFloat(translateMatch[1]),
translateY: parseFloat(translateMatch[2]),
scale: parseFloat(scaleMatch[1])
};
}

function compareCloseTo(value, compareValue) {
expect(Number(value)).to.be.closeTo(Number(compareValue), Cypress.env("compareRange"));
}
Expand Down

0 comments on commit eea68de

Please sign in to comment.