Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Jan 14, 2022
1 parent 442afa9 commit fc437bf
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 58 deletions.
10 changes: 5 additions & 5 deletions cypress/integration/editing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe("editing", function () {
beforeEach(() => {
cy.visit("");
});
// it.only(`should handle focus correctly while editing`, ()=> {
// it(`should handle focus correctly while editing`, ()=> {
// cy.selectRange(5297, 3);
// cy.deleteSelection();
// // cy.window()
Expand All @@ -24,10 +24,10 @@ describe("editing", function () {
cy.contains(".veCircularView text", "Part 0").click();
cy.contains(".veCircularView text", "Part 0")
.closest(".veVectorInteractionWrapper")
.type("t");
.type("t", { passThru: true });
cy.focused().type("ttaaa{enter}");
cy.contains("Selecting 5 bps from 11 to 15");
cy.focused().type("t");
cy.focused().type("t", { passThru: true });
cy.focused().type("ccccttaaa{enter}");
cy.contains("Selecting 9 bps from 11 to 19");
cy.focused().find(".veCircularView"); //the circular view should still be focused
Expand All @@ -36,10 +36,10 @@ describe("editing", function () {
cy.contains(".veRowView text", "Part 0")
.click()
.closest(".veVectorInteractionWrapper")
.type("t");
.type("t", { passThru: true });
cy.focused().type("ttaaa{enter}");
cy.contains("Selecting 5 bps from 11 to 15");
cy.focused().type("t");
cy.focused().type("t", { passThru: true });
cy.focused().type("ccccttaaa{enter}");
cy.contains("Selecting 9 bps from 11 to 19");
cy.focused().find(".veRowView"); //the row view should still be focused
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/findTool.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ describe("find tool", function () {
});
it(`clear search layers when closed and retain the previous search and be selected when re-opened`, () => {
cy.get(`[data-test="ve-find-tool-toggle"]`).click();
cy.focused().type("gattac"); //this should cause 1 region to be selected
cy.focused().type("gattac", { noPrevValue: true }); //this should cause 1 region to be selected
cy.get(".veSearchLayerContainer").should("exist");
cy.get(".veFindBar .bp3-icon-cross").click();
cy.get(".veSearchLayerContainer").should("not.exist");
cy.get(`[data-test="ve-find-tool-toggle"]`).click();
cy.get(".veSearchLayerContainer").should("exist"); //test that the search didn't get cleared
cy.focused().type("gattac"); //this should override the existing search because the existing search should already be highlighted
cy.focused().type("gattac", { noPrevValue: true }); //this should override the existing search because the existing search should already be highlighted
cy.get(".veSearchLayerContainer").should("exist"); //asserts that there is at least 1 valid search found
});

Expand Down
42 changes: 24 additions & 18 deletions cypress/integration/menuBar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,22 @@ describe("menuBar", function () {
cy.contains(".veStatusBarItem", "11 to 31");
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Select").click();
cy.get(`[label="From:"]`).should("have.value", "11").clear().type("10");
cy.get(`[label="To:"]`).should("have.value", "31").clear().type("20");
cy.get(`[label="From:"]`)
.should("have.value", "11")
.clear()
.type("10", { noPrevValue: true });
cy.get(`[label="To:"]`)
.should("have.value", "31")
.clear()
.type("20", { noPrevValue: true });
cy.get(".tg-min-width-dialog").contains("Select 11 BPs").click();
cy.contains(".veStatusBarItem", "10 to 20").should("be.visible");
});
it("should be able to select a range (10 - 20) via Edit > Select and have the range correctly selected", function () {
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Select").click();
cy.get(`[label="From:"]`).clear().type("10");
cy.get(`[label="To:"]`).clear().type("20");
cy.get(`[label="From:"]`).clear().type("10", { noPrevValue: true });
cy.get(`[label="To:"]`).clear().type("20", { noPrevValue: true });
cy.get(".tg-min-width-dialog").contains("Select 11 BPs").click();
cy.get(".veStatusBarItem").contains("10 to 20").should("be.visible");
});
Expand Down Expand Up @@ -281,13 +287,13 @@ describe("menuBar", function () {
`, () => {
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Go To").click();
cy.focused().clear().type("0");
cy.focused().clear().type("0", { noPrevValue: true });
cy.get(".bp3-dialog").contains("OK").should("be.enabled");
cy.focused().clear().type("5299");
cy.focused().clear().type("5299", { noPrevValue: true });
cy.get(".bp3-dialog").contains("OK").should("be.enabled");
cy.focused().clear().type("2000000");
cy.focused().clear().type("2000000", { noPrevValue: true });
cy.get(".bp3-dialog").contains("OK").should("be.disabled");
cy.focused().clear().type("20");
cy.focused().clear().type("20", { noPrevValue: true });
cy.get(".bp3-dialog").contains("OK").click();
cy.contains("Caret Between Bases 20 and 21");
cy.get(".tg-menu-bar").contains("Edit").click();
Expand All @@ -299,16 +305,16 @@ describe("menuBar", function () {
`, () => {
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Go To").click();
cy.focused().clear().type("10");
cy.focused().clear().type("10", { noPrevValue: true });
cy.get(".bp3-dialog").contains("OK").click();
cy.focused().type("a");
cy.focused().type("a", { passThru: true });
cy.contains(".sequenceInputBubble", "Press ENTER to insert");
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Select").click();
cy.get(`[label="From:"]`).clear().type("10");
cy.get(`[label="To:"]`).clear().type("20");
cy.get(`[label="From:"]`).clear().type("10", { noPrevValue: true });
cy.get(`[label="To:"]`).clear().type("20", { noPrevValue: true });
cy.get(`.dialog-buttons`).contains("Select 11 BPs").click();
cy.focused().type("a");
cy.focused().type("a", { passThru: true });

cy.contains(".sequenceInputBubble", "Press ENTER to replace");
});
Expand All @@ -321,14 +327,14 @@ describe("menuBar", function () {
`, function () {
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Select").click();
cy.get(`[label="From:"]`).clear().type("10");
cy.get(`[label="From:"]`).clear().type("10", { noPrevValue: true });

cy.get(`[label="To:"]`).clear();
cy.get(`.dialog-buttons`).contains("Select 0 BPs").should("be.disabled");
cy.get(`[label="To:"]`).clear().type("20000000");
cy.get(`[label="To:"]`).clear().type("20000000", { noPrevValue: true });
cy.get(`.dialog-buttons`).contains("Select 0 BPs").should("be.disabled");

cy.get(`[label="To:"]`).clear().type("20");
cy.get(`[label="To:"]`).clear().type("20", { noPrevValue: true });
cy.get(`.dialog-buttons`).contains("Select 11 BPs").click();
cy.get(".veStatusBar").contains(`10 to 20`);

Expand All @@ -345,8 +351,8 @@ describe("menuBar", function () {
// // cy.
// cy.get('.tg-menu-bar').contains("Edit").click()
// cy.get('.tg-menu-bar-popover').contains("Select").click()
// cy.get(`[label="From:"]`).clear().type("10")
// cy.get(`[label="To:"]`).clear().type("20")
// cy.get(`[label="From:"]`).clear().type("10", { noPrevValue: true })
// cy.get(`[label="To:"]`).clear().type("20", { noPrevValue: true })
// cy.get(`.dialog-buttons`).contains("OK").click()
// cy.get(".veStatusBar").contains(`10 to 20`)
// });
Expand Down
8 changes: 5 additions & 3 deletions cypress/integration/proteinEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ describe("proteinEditor", function () {
cy.get(".veRowViewSelectionLayer.notCaret").trigger("contextmenu");
cy.contains(".bp3-menu-item", "Replace").click();

cy.get(".sequenceInputBubble input").type(".*-masdzz,");
cy.get(".sequenceInputBubble input").type(".*-masdzz,", {
assertVal: ".*-masdzz"
});
cy.contains("Press ENTER to replace 1 AAs between 1386 and 2");
cy.get(".sequenceInputBubble input").type("{enter}");
cy.contains("Selecting 9 AAs from 1 to 9");
Expand Down Expand Up @@ -116,8 +118,8 @@ describe("proteinEditor", function () {
it("should be able to select a range (10 - 20) via Edit > Select and have the range correctly selected", function () {
cy.get(".tg-menu-bar").contains("Edit").click();
cy.get(".tg-menu-bar-popover").contains("Select").click();
cy.get(`[label="From:"]`).clear().type("10");
cy.get(`[label="To:"]`).clear().type("20");
cy.get(`[label="From:"]`).clear().type("10", { noPrevValue: true });
cy.get(`[label="To:"]`).clear().type("20", { noPrevValue: true });
cy.get(".tg-min-width-dialog").contains("Select 11 AAs").click();
cy.get(".veStatusBarItem")
.contains("Selecting 11 AAs from 10 to 20")
Expand Down
65 changes: 35 additions & 30 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,34 +274,39 @@ Cypress.Commands.add("closeToasts", () => {
});
});

Cypress.Commands.overwrite("type", (originalFn, subject, text, options) => {
if (text === "{selectall}{del}") {
return originalFn(subject, text, options); // explicit return required
} else {
cy.wrap(subject, { log: false })
.invoke("val")
.then((prevValue) => {
if (
(options && options.parseSpecialCharSequences === false) ||
text.includes("{") //if special chars are getting used just try it out
) {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0, { log: false }).then(
{ timeout: (options && options.timeout) || 40000 },
() => originalFn(subject, text, options)
);
} else {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0, { log: false }).then(
{ timeout: (options && options.timeout) || 40000 },
() => originalFn(subject, text, options)
);
// Adds guarding that asserts that the value is typed.
cy.wrap(subject, { log: false }).should(
"have.value",
`${prevValue}${text}`
);
}
});
Cypress.Commands.overwrite(
"type",
(originalFn, subject, text, options = {}) => {
if (text === "{selectall}{del}") {
return originalFn(subject, text, options); //pass thru .clear() calls
} else {
cy.wrap(subject, { log: false })
.invoke("val")
.then((prevValue) => {
if (
options.passThru ||
options.parseSpecialCharSequences === false ||
(text.includes && text.includes("{")) //if special chars are getting used just pass them thru
) {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0, { log: false }).then(
{ timeout: options.timeout || 40000 },
() => originalFn(subject, text, options)
);
} else {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(0, { log: false }).then(
{ timeout: options.timeout || 40000 },
() => originalFn(subject, text, options)
);
// Adds guarding that asserts that the value is typed.
cy.wrap(subject, { log: false }).should(
"have.value",
options.assertVal ||
`${options.noPrevValue ? "" : prevValue}${text}`
);
}
});
}
}
});
);

0 comments on commit fc437bf

Please sign in to comment.