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

DEVPROD-1904 Fix flaky test caused by racing assertions and Introduce realClick for clipboard events #438

Merged
merged 8 commits into from
Nov 17, 2023

Conversation

khelif96
Copy link
Collaborator

@khelif96 khelif96 commented Nov 16, 2023

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

@khelif96 khelif96 requested a review from a team November 16, 2023 16:30
Copy link

cypress bot commented Nov 16, 2023

Passing run #4101 ↗︎

0 124 0 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Use util function for copy assertions
Project: Parsley Commit: 46acdb0887
Status: Passed Duration: 03:43 💡
Started: Nov 17, 2023 2:11 PM Ended: Nov 17, 2023 2:14 PM

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",
Copy link
Collaborator

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

@SupaJoon SupaJoon self-requested a review November 17, 2023 15:08
});
cy.toggleDetailsPanel(true);
// Need to fire a real click here because the copy to clipboard
cy.dataCy("jira-button").realClick();
Copy link
Collaborator

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";
Copy link
Collaborator Author

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);
Copy link
Collaborator

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";
Copy link
Collaborator Author

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.

@khelif96 khelif96 merged commit 9c1dacc into evergreen-ci:main Nov 17, 2023
2 checks passed
@khelif96 khelif96 deleted the DEVPROD-1904 branch November 17, 2023 22:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants