-
Notifications
You must be signed in to change notification settings - Fork 16
DEVPROD-1904 Fix flaky test caused by racing assertions and Introduce realClick for clipboard events #438
Conversation
Passing run #4101 ↗︎
Details:
Review all test suite changes for PR #438 ↗︎ |
package.json
Outdated
@@ -117,6 +117,7 @@ | |||
"babel-loader": "8.2.5", | |||
"babel-plugin-import-graphql": "2.8.1", | |||
"cypress": "12.7.0", | |||
"cypress-real-events": "^1.11.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can avoid the caret by setting npm config set save-exact true
}); | ||
cy.toggleDetailsPanel(true); | ||
// Need to fire a real click here because the copy to clipboard | ||
cy.dataCy("jira-button").realClick(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to create a clipboard interaction helper command that calls realClick and asserts the value. I can tell the logic should be consolidated because of the repeated comment that explains special usage
@@ -1,3 +1,4 @@ | |||
import "cypress-real-events"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required and initializes the package for the entire test suite.
}); | ||
// This wait is necessary to ensure the clipboard has time to be read | ||
// eslint-disable-next-line cypress/no-unnecessary-waiting | ||
cy.wait(50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me!!
@@ -1,3 +1,4 @@ | |||
import "cypress-real-events"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required and initializes the package for the entire test suite.
DEVPROD-1904
Description
The test flake here seems to have been caused by an assertion that would sometimes race with the click because it wasn't checking if the element existed.
There were also some silent uncaught exceptions that were caused by clicking on a copy to clipboard button because the cypress click event isn't a real click and the browser prevents copying to the clipboard without a real user interaction.
It also looks like the actual copy assertions themselves weren't being resolved during the test and would leak into the next test run causing unpredictable behavior. I moved the the copy assertion to a util function and added a wait to ensure it gets run before the test completes