Skip to content

Commit

Permalink
#1974 Errors appear when editing Cypress files (#1975)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlyn authored May 21, 2024
1 parent 08d1c3b commit c28ebd8
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 128 deletions.
6 changes: 3 additions & 3 deletions canvas_modules/harness/cypress/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
extends: [
"eslint-config-canvas",
"plugin:cypress/recommended"
"plugin:cypress/recommended",
"eslint-config-canvas/react"
],
parserOptions: {
"sourceType": "module"
},
rules: {
"no-unused-expressions": "off",
"consistent-return": "off",
"no-unnecessary-waiting": "off"
"cypress/no-unnecessary-waiting": "off"
}
};
2 changes: 1 addition & 1 deletion canvas_modules/harness/cypress/e2e/canvas/decorators.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from "react";
import * as testUtils from "../../utils/eventlog-utils";
import { Play } from "@carbon/react/icons";
import React from "react";

describe("Test adding a decorator to a node", function() {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("Test dragged node snaps to grid", function() {
// Make the same change with Snap To Grid set to "During"
// and verify the node is at a different position.
cy.setCanvasConfig({ "selectedSnapToGridType": "During" });
cy.wait(10)
cy.wait(10);
cy.verifyNodeTransform("Binding (entry) node", 87.5, 105);
cy.moveNodeToPosition("Binding (entry) node", 321, 281);
cy.verifyNodeTransform("Binding (entry) node", 315, 285);
Expand Down
34 changes: 18 additions & 16 deletions canvas_modules/harness/cypress/e2e/canvas/undo-redo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,22 +773,24 @@ function verifySamplingRatioParameterValueInConsole(parameterName, value) {
});
}

function verifyErrorMessageForSamplingRatioParameterInConsole(messageType, parameterName, message) {
cy.document().then((doc) => {
const lastEventLog = testUtils.getLastLogOfType(doc, "applyPropertyChanges()");
expect(lastEventLog.data.messages.length).not.equal(0);
for (var idx = 0; idx < lastEventLog.data.messages.length; idx++) {
if (lastEventLog.data.messages[idx].text === message &&
lastEventLog.data.messages[idx].type === messageType &&
lastEventLog.data.messages[idx].id_ref === parameterName) {
expect(lastEventLog.data.messages[idx].text).to.equal(message);
expect(lastEventLog.data.messages[idx].type).to.equal(messageType);
expect(lastEventLog.data.messages[idx].id_ref).to.equal(parameterName);
break;
}
}
});
}
// This function is commented out because the calling code is temporarily commented out,
// waiting to be fixed.
// function verifyErrorMessageForSamplingRatioParameterInConsole(messageType, parameterName, message) {
// cy.document().then((doc) => {
// const lastEventLog = testUtils.getLastLogOfType(doc, "applyPropertyChanges()");
// expect(lastEventLog.data.messages.length).not.equal(0);
// for (var idx = 0; idx < lastEventLog.data.messages.length; idx++) {
// if (lastEventLog.data.messages[idx].text === message &&
// lastEventLog.data.messages[idx].type === messageType &&
// lastEventLog.data.messages[idx].id_ref === parameterName) {
// expect(lastEventLog.data.messages[idx].text).to.equal(message);
// expect(lastEventLog.data.messages[idx].type).to.equal(messageType);
// expect(lastEventLog.data.messages[idx].id_ref).to.equal(parameterName);
// break;
// }
// }
// });
// }

function verifyNoErrorMessageInConsole() {
cy.document().then((doc) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe("Test of Python and R expression controls", function() {
cy.verifyTypeOfWordInExpressionEditor("# syntax testing", "comment", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor("1", "number", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor("text\"", "string", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor('\n', "string", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor("\n", "string", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor("=", "operator", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor("function", "keyword", "conditionExpr");
cy.verifyTypeOfWordInExpressionEditor("Inf", "keyword", "conditionExpr");
Expand Down
64 changes: 35 additions & 29 deletions canvas_modules/harness/cypress/support/canvas/comments-cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ Cypress.Commands.add("ctrlOrCmdClickComment", (commentText) => {
// Get the os name to decide whether to click ctrl or cmd
cy.useCtrlOrCmdKey()
.then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.getCommentWithText(commentText)
cy.get("body").type(selectedKey, { release: false });
cy.get("body").getCommentWithText(commentText)
.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
Expand All @@ -97,7 +96,8 @@ Cypress.Commands.add("ctrlOrCmdClickCommentInSupernode", (commentText, supernode
cy.useCtrlOrCmdKey()
.then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.type(selectedKey, { release: false });
cy.get("body")
.getCommentWithTextInSupernode(commentText, supernodeName)
.click();

Expand Down Expand Up @@ -131,11 +131,12 @@ Cypress.Commands.add("isCommentSelected", (commentText) => {
});

Cypress.Commands.add("editTextInComment", (originalCommentText, newCommentText, saveComment = true) => {
cy.getCommentWithText(originalCommentText)
.dblclick({force: true})
.get("textarea")
.clear()
.type(newCommentText);
cy.getCommentWithText(originalCommentText).as("comment");
cy.get("@comment").dblclick({ force: true });
cy.get("@comment").get("textarea")
.as("textarea");
cy.get("@textarea").clear();
cy.get("@textarea").type(newCommentText);

// Click somewhere on canvas to save comment
if (saveComment) {
Expand All @@ -144,33 +145,36 @@ Cypress.Commands.add("editTextInComment", (originalCommentText, newCommentText,
});

Cypress.Commands.add("editTextInCommentInSubFlow", (originalCommentText, newCommentText) => {
cy.getCommentWithTextInSubFlow(originalCommentText)
.dblclick()
.get("textarea")
.clear()
.type(newCommentText);
cy.getCommentWithTextInSubFlow(originalCommentText).as("comment");
cy.get("@comment").dblclick();
cy.get("@comment").get("textarea")
.as("textarea");
cy.get("@textarea").clear();
cy.get("@textarea").type(newCommentText);

// Click somewhere on canvas to save comment
cy.get(`#canvas-div-${document.instanceId}`).click();
});

Cypress.Commands.add("editTextInCommentInSubFlowNested", (originalCommentText, newCommentText) => {
cy.getCommentWithTextInSubFlowNested(originalCommentText)
.dblclick()
.get("textarea")
.clear()
.type(newCommentText);
cy.getCommentWithTextInSubFlowNested(originalCommentText).as("comment");
cy.get("@comment").dblclick();
cy.get("@comment").get("textarea")
.as("textarea");
cy.get("@textarea").clear();
cy.get("@textarea").type(newCommentText);

// Click somewhere on canvas to save comment
cy.get("#canvas-div-0").click();
});

Cypress.Commands.add("editTextInCommentInSupernode", (originalCommentText, newCommentText, supernodeName) => {
cy.getCommentWithTextInSupernode(originalCommentText, supernodeName)
.dblclick()
.get("textarea")
.clear()
.type(newCommentText);
cy.getCommentWithTextInSupernode(originalCommentText, supernodeName).as("comment");
cy.get("@comment").dblclick();
cy.get("@comment").get("textarea")
.as("textarea");
cy.get("@textarea").clear();
cy.get("@textarea").type(newCommentText);

// Click somewhere on canvas to save comment
cy.get("#canvas-div-0").click();
Expand All @@ -192,7 +196,8 @@ Cypress.Commands.add("moveCommentToPosition", (commentText, canvasX, canvasY) =>
cy.get(srcSelector)
.trigger("mousedown", "topLeft", { which: 1, view: win });
cy.get("#canvas-div-0")
.trigger("mousemove", canvasX + transform.x, canvasY + transform.y, { view: win })
.trigger("mousemove", canvasX + transform.x, canvasY + transform.y, { view: win });
cy.get("#canvas-div-0")
.trigger("mouseup", { which: 1, view: win });
});
});
Expand Down Expand Up @@ -225,7 +230,8 @@ Cypress.Commands.add("dragAndDrop", (srcSelector, srcXPos, srcYPos, trgSelector,
cy.get(srcSelector)
.trigger("mousedown", srcXPos, srcYPos, { which: 1, view: win });
cy.get(trgSelector)
.trigger("mousemove", trgXPos, trgYPos, { view: win })
.trigger("mousemove", trgXPos, trgYPos, { view: win });
cy.get(trgSelector)
.trigger("mouseup", trgXPos, trgYPos, { which: 1, view: win });
});
});
Expand Down Expand Up @@ -288,9 +294,9 @@ Cypress.Commands.add("deleteCommentUsingKeyboard", (commentText) => {
// Delete comment by pressing 'Delete' key on keyboard
cy.useDeleteKey()
.then((deleteKey) => {
cy.getCommentWithText(commentText)
.click()
.type(deleteKey);
cy.getCommentWithText(commentText).as("comment");
cy.get("@comment").click();
cy.get("@comment").type(deleteKey);
});
});

Expand Down
62 changes: 29 additions & 33 deletions canvas_modules/harness/cypress/support/canvas/link-cmds.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ Cypress.Commands.add("clickEditIconForLinkDecLabel", (linkLabel) => {
Cypress.Commands.add("enterLabelForLinkDec", (linkLabel, decId, newLabel) => {
cy.getLinkWithLabel(linkLabel)
.find("[data-id='link_dec_group_0_" + decId + "'] > foreignObject > textarea")
.clear()
.type(newLabel);
.as("textarea");
cy.get("@textarea").clear();
cy.get("@textarea").type(newLabel);
// Click canvas to complete text entry
cy.get("#canvas-div-0").click(1, 1);
});

Cypress.Commands.add("enterLabelForLinkDecHitReturn", (linkLabel, decId, newLabel) => {
cy.getLinkWithLabel(linkLabel)
.find("[data-id='link_dec_group_0_" + decId + "'] > foreignObject > textarea")
.clear()
.type(newLabel)
.type("{enter}");
.as("textarea");
cy.get("@textarea").clear();
cy.get("@textarea").type(newLabel);
cy.get("@textarea").type("{enter}");
});

Cypress.Commands.add("checkLinkDoesntExist", (linkId) => {
Expand Down Expand Up @@ -114,9 +116,9 @@ Cypress.Commands.add("moveLinkHandleToPos", (linkId, element, xPos, yPos) => {
cy.window().then((win) => {
cy.get(getLinkSelector(linkId, element))
.trigger("mousedown", { view: win });
cy.get(".d3-svg-canvas-div > .svg-area")
.trigger("mousemove", xPos, yPos)
.trigger("mouseup", xPos, yPos, { view: win });
cy.get(".d3-svg-canvas-div > .svg-area").as("canvasDiv");
cy.get("@canvasDiv").trigger("mousemove", xPos, yPos);
cy.get("@canvasDiv").trigger("mouseup", xPos, yPos, { view: win });
});
});

Expand All @@ -140,9 +142,8 @@ Cypress.Commands.add("moveLinkHandleToNodeByLinkId", (linkId, element, nodeName)
.then((trgSelector) => {
cy.get(getLinkSelector(linkId, element))
.trigger("mousedown", { view: win });
cy.get(trgSelector)
.trigger("mousemove", { force: true, view: win })
.trigger("mouseup", { force: true, view: win });
cy.get(trgSelector).trigger("mousemove", { force: true, view: win });
cy.get(trgSelector).trigger("mouseup", { force: true, view: win });
});
});
});
Expand All @@ -167,9 +168,8 @@ Cypress.Commands.add("moveLinkHandleToPortByLinkId", (linkId, element, nodeName,
.then((trgSelector) => {
cy.get(getLinkSelector(linkId, element))
.trigger("mousedown", { view: win });
cy.get(trgSelector)
.trigger("mousemove", { force: true, view: win })
.trigger("mouseup", { force: true, view: win });
cy.get(trgSelector).trigger("mousemove", { force: true, view: win });
cy.get(trgSelector).trigger("mouseup", { force: true, view: win });
});
});
});
Expand All @@ -189,9 +189,8 @@ Cypress.Commands.add("linkNodeOutputPortToNodeInputPort", (srcNodeName, srcPortI
cy.window().then((win) => {
cy.get(srcSelector)
.trigger("mousedown", { which: 1, view: win });
cy.get(trgSelector)
.trigger("mousemove", { view: win })
.trigger("mouseup", { which: 1, view: win, force: true });
cy.get(trgSelector).trigger("mousemove", { view: win });
cy.get(trgSelector).trigger("mouseup", { which: 1, view: win, force: true });
});
});
});
Expand All @@ -206,9 +205,8 @@ Cypress.Commands.add("linkNodeOutputPortToNodeInputPortInSupernode",
cy.window().then((win) => {
cy.get(srcSelector)
.trigger("mousedown", { which: 1, view: win });
cy.get(trgSelector)
.trigger("mousemove", { view: win })
.trigger("mouseup", { which: 1, view: win, force: true });
cy.get(trgSelector).trigger("mousemove", { view: win });
cy.get(trgSelector).trigger("mouseup", { which: 1, view: win, force: true });
});
});
});
Expand All @@ -225,9 +223,8 @@ Cypress.Commands.add("linkNodeOutputPortToNode", (srcNodeName, srcPortId, trgNod
cy.window().then((win) => {
cy.get(srcSelector)
.trigger("mousedown", { which: 1, view: win });
cy.get(trgSelector)
.trigger("mousemove", { view: win })
.trigger("mouseup", { which: 1, view: win, force: true });
cy.get(trgSelector).trigger("mousemove", { view: win });
cy.get(trgSelector).trigger("mouseup", { which: 1, view: win, force: true });
});
});
});
Expand All @@ -242,9 +239,9 @@ Cypress.Commands.add("linkNodeOutputPortToPointOnCanvas", (srcNodeName, srcPortI
cy.window().then((win) => {
cy.get(srcSelector)
.trigger("mousedown", { which: 1, view: win });
cy.get(".d3-svg-canvas-div > .svg-area")
.trigger("mousemove", { view: win })
.trigger("mouseup", xPos, yPos, { which: 1, view: win, force: true });
cy.get(".d3-svg-canvas-div > .svg-area").as("svgArea");
cy.get("@svgArea").trigger("mousemove", { view: win });
cy.get("@svgArea").trigger("mouseup", xPos, yPos, { which: 1, view: win, force: true });
});
});
});
Expand Down Expand Up @@ -371,11 +368,11 @@ Cypress.Commands.add("deleteLinkAt", (linkX, linkY) => {
});

Cypress.Commands.add("hoverOverLinkName", (linkName) => {
cy.getLinkWithLabel(linkName)
.children()
cy.getLinkWithLabel(linkName).children()
.eq(1)
.trigger("mouseenter", { force: true })
.trigger("mouseover", { force: true });
.as("firstLink");
cy.get("@firstLink").trigger("mouseenter", { force: true });
cy.get("@firstLink").trigger("mouseover", { force: true });
});

Cypress.Commands.add("getLinkUsingLinkId", (linkId) => {
Expand Down Expand Up @@ -411,9 +408,8 @@ Cypress.Commands.add("clickLink", (linkId) => {
Cypress.Commands.add("ctrlOrCmdClickLink", (linkId) => {
// Get the os name to decide whether to click ctrl or cmd
cy.useCtrlOrCmdKey().then((selectedKey) => {
cy.get("body")
.type(selectedKey, { release: false })
.getLinkUsingLinkId(linkId)
cy.get("body").type(selectedKey, { release: false });
cy.get("body").getLinkUsingLinkId(linkId)
.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
Expand Down
Loading

0 comments on commit c28ebd8

Please sign in to comment.