Skip to content

Commit

Permalink
Make wait in assertCodePaneLineCount an optional prop
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhabib committed May 10, 2024
1 parent 766098e commit 6dd7da1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/snippets.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Snippets', () => {
assertSnippetsListIsVisible();
assertCodePaneLineCount(8);
filterSnippets('{esc}');
assertCodePaneLineCount(1);
assertCodePaneLineCount(1, { wait: 500 });
typeCode(`${isMac() ? '{cmd}' : '{ctrl}'}k`);
assertSnippetsListIsVisible();
assertCodePaneLineCount(8);
Expand All @@ -89,7 +89,7 @@ describe('Snippets', () => {
// Close without persisting
filterSnippets('{esc}');
assertCodePaneContains('<div>Initial <span>code</span></div>');
assertCodePaneLineCount(1);
assertCodePaneLineCount(1, { wait: 500 });

// Re-open and persist
typeCode(`${isMac() ? '{cmd}' : '{ctrl}'}k`);
Expand Down
6 changes: 4 additions & 2 deletions cypress/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,15 @@ export const assertCodePaneContains = (text) => {
});
};

export const assertCodePaneLineCount = (lines) => {
export const assertCodePaneLineCount = (lines, { wait } = {}) => {
getCodeEditor().within(() =>
cy.get('.CodeMirror-line').should('have.length', lines)
);

// Wait after check to ensure original focus is restored
cy.wait(500); // eslint-disable-line @finsit/cypress/no-unnecessary-waiting
if (typeof wait === 'number') {
cy.wait(wait);
}
};

export const assertFramesMatch = (matches) =>
Expand Down

0 comments on commit 6dd7da1

Please sign in to comment.