Skip to content

Commit

Permalink
Fix reliability issues in Cypress tests for search related keyboard s…
Browse files Browse the repository at this point in the history
…hortcuts (#345)
  • Loading branch information
felixhabib committed Mar 7, 2024
1 parent 94c75f8 commit d5c2985
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,14 @@ export const loadPlayroom = (initialCode) => {
};

const typeInSearchField = (text) =>
/*
force true is required because cypress incorrectly and intermittently
reports that search field is covered by another element
*/
cy.get('.CodeMirror-search-field').type(text, { force: true });
cy.get('.CodeMirror-search-field').type(text);

/**
* @param {string} term
*/
export const findInCode = (term) => {
// Wait necessary to ensure code pane is focussed
cy.wait(200); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
cy.wait(500); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
typeCode(`{${cmdPlus('f')}}`);

typeInSearchField(`${term}{enter}`);
Expand All @@ -212,7 +208,7 @@ export const findInCode = (term) => {
*/
export const replaceInCode = (term, replaceWith) => {
// Wait necessary to ensure code pane is focussed
cy.wait(200); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
cy.wait(500); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
typeCode(`{${cmdPlus('alt+f')}}`);
typeInSearchField(`${term}{enter}`);
if (replaceWith) {
Expand All @@ -225,7 +221,7 @@ export const replaceInCode = (term, replaceWith) => {
*/
export const jumpToLine = (line) => {
// Wait necessary to ensure code pane is focussed
cy.wait(200); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
cy.wait(500); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
typeCode(`{${cmdPlus('g')}}`);
typeCode(`${line}{enter}`);
};
Expand Down

0 comments on commit d5c2985

Please sign in to comment.