Skip to content

Commit

Permalink
Try forcing and retrying
Browse files Browse the repository at this point in the history
This reverts commit 893e393.
  • Loading branch information
felixhabib committed Mar 1, 2024
1 parent 893e393 commit 465b28e
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 142 deletions.
4 changes: 4 additions & 0 deletions cypress.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export default defineConfig({
defaultCommandTimeout: 10000,
video: false,
e2e: {},
retries: {
runMode: 2,
openMode: 0,
},
});
258 changes: 129 additions & 129 deletions cypress/e2e/keymaps.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,135 @@ describe('Keymaps', () => {
});
});

describe('find and replace', () => {
beforeEach(() => {
loadPlayroom(`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
`);
});

it('should find all occurrences of search term', () => {
findInCode('div');

assertCodePaneSearchMatchesCount(6);

cy.focused().type('{esc}');

assertCodePaneHasFocus();
});

it('should replace and skip occurrences of search term correctly', () => {
replaceInCode('div', 'span');

// replace occurrence
cy.get('.CodeMirror-dialog button').contains('Yes').click();

assertCodePaneContains(dedent`
<span>First line</div>
<div>Second line</div>
<div>Third line</div>
`);

// ignore occurrence
cy.get('.CodeMirror-dialog button').contains('No').click();

assertCodePaneContains(dedent`
<span>First line</div>
<div>Second line</div>
<div>Third line</div>
`);

// replace occurrence
cy.get('.CodeMirror-dialog button').contains('Yes').click();

assertCodePaneContains(dedent`
<span>First line</div>
<span>Second line</div>
<div>Third line</div>
`);

// replace all remaining occurrences
cy.get('.CodeMirror-dialog button').contains('All').click();

assertCodePaneContains(dedent`
<span>First line</span>
<span>Second line</span>
<span>Third line</span>
`);

assertCodePaneHasFocus();
});

it('should back out of replace correctly', () => {
replaceInCode('div');

cy.focused().type('{esc}');

assertCodePaneContains(dedent`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
`);

assertCodePaneHasFocus();
});
});

describe('jump to line', () => {
beforeEach(() => {
loadPlayroom(`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
<div>Forth line</div>
<div>Fifth line</div>
<div>Sixth line</div>
<div>Seventh line</div>
`);
});

it('should jump to line number correctly', () => {
const line = 6;
jumpToLine(line);

cy.get(`.CodeMirror-code > div:nth-child(${line})`).should(
'have.class',
'CodeMirror-activeline'
);

assertCodePaneHasFocus();

const nextLine = 2;
jumpToLine(nextLine);

cy.get(`.CodeMirror-code > div:nth-child(${nextLine})`).should(
'have.class',
'CodeMirror-activeline'
);

assertCodePaneHasFocus();
});

it('should jump to line and column number correctly', () => {
jumpToLine('6:10');
typeCode('a');

assertCodePaneContains(dedent`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
<div>Forth line</div>
<div>Fifth line</div>
<div>Sixtha line</div>
<div>Seventh line</div>
`);

assertCodePaneHasFocus();
});
});

describe('toggleComment', () => {
const blockStarter = `
<div>First line</div>
Expand Down Expand Up @@ -1796,133 +1925,4 @@ describe('Keymaps', () => {
});
});
});

describe('find and replace', () => {
beforeEach(() => {
loadPlayroom(`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
`);
});

it('should find all occurrences of search term', () => {
findInCode('div');

assertCodePaneSearchMatchesCount(6);

cy.focused().type('{esc}');

assertCodePaneHasFocus();
});

it('should replace and skip occurrences of search term correctly', () => {
replaceInCode('div', 'span');

// replace occurrence
cy.get('.CodeMirror-dialog button').contains('Yes').click();

assertCodePaneContains(dedent`
<span>First line</div>
<div>Second line</div>
<div>Third line</div>
`);

// ignore occurrence
cy.get('.CodeMirror-dialog button').contains('No').click();

assertCodePaneContains(dedent`
<span>First line</div>
<div>Second line</div>
<div>Third line</div>
`);

// replace occurrence
cy.get('.CodeMirror-dialog button').contains('Yes').click();

assertCodePaneContains(dedent`
<span>First line</div>
<span>Second line</div>
<div>Third line</div>
`);

// replace all remaining occurrences
cy.get('.CodeMirror-dialog button').contains('All').click();

assertCodePaneContains(dedent`
<span>First line</span>
<span>Second line</span>
<span>Third line</span>
`);

assertCodePaneHasFocus();
});

it('should back out of replace correctly', () => {
replaceInCode('div');

cy.focused().type('{esc}');

assertCodePaneContains(dedent`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
`);

assertCodePaneHasFocus();
});
});

describe('jump to line', () => {
beforeEach(() => {
loadPlayroom(`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
<div>Forth line</div>
<div>Fifth line</div>
<div>Sixth line</div>
<div>Seventh line</div>
`);
});

it('should jump to line number correctly', () => {
const line = 6;
jumpToLine(line);

cy.get(`.CodeMirror-code > div:nth-child(${line})`).should(
'have.class',
'CodeMirror-activeline'
);

assertCodePaneHasFocus();

const nextLine = 2;
jumpToLine(nextLine);

cy.get(`.CodeMirror-code > div:nth-child(${nextLine})`).should(
'have.class',
'CodeMirror-activeline'
);

assertCodePaneHasFocus();
});

it('should jump to line and column number correctly', () => {
jumpToLine('6:10');
typeCode('a');

assertCodePaneContains(dedent`
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
<div>Forth line</div>
<div>Fifth line</div>
<div>Sixtha line</div>
<div>Seventh line</div>
`);

assertCodePaneHasFocus();
});
});
});
20 changes: 7 additions & 13 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ export const assertCodePaneHasFocus = () => {
export const findInCode = (term) => {
cy.wait(200); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
typeCode(`{${cmdPlus('f')}}`);
cy.get('.CodeMirror-dialog')
.find('.CodeMirror-search-field')
.type(`${term}{enter}`);
cy.get('.CodeMirror-search-field').type(`${term}{enter}`, { force: true });
};

/**
Expand All @@ -211,13 +209,11 @@ export const findInCode = (term) => {
export const replaceInCode = (term, replaceWith) => {
cy.wait(200); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
typeCode(`{${cmdPlus('alt+f')}}`);
cy.get('.CodeMirror-dialog')
.find('.CodeMirror-search-field')
.type(`${term}{enter}`);
cy.get('.CodeMirror-search-field').type(`${term}{enter}`);
if (replaceWith) {
cy.get('.CodeMirror-dialog')
.find('.CodeMirror-search-field')
.type(`${replaceWith}{enter}`);
cy.get('.CodeMirror-search-field').type(`${replaceWith}{enter}`, {
force: true,
});
}
};

Expand All @@ -227,16 +223,14 @@ export const replaceInCode = (term, replaceWith) => {
export const jumpToLine = (line) => {
cy.wait(200); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
typeCode(`{${cmdPlus('g')}}`);
cy.get('.CodeMirror-dialog')
.find('.CodeMirror-search-field')
.type(`${line}{enter}`);
cy.get('.CodeMirror-search-field').type(`${line}{enter}`);
};

/**
* @param {number} lines
*/
export const assertCodePaneSearchMatchesCount = (lines) => {
getCodeEditor().within(() =>
cy.get('.cm-searching').should('have.length', lines)
cy.get('.cm-searching').should('have.length', lines, { force: true })
);
};

0 comments on commit 465b28e

Please sign in to comment.