Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix various Cypress race conditions in Privacy Center #5040

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Jun 28, 2024

Description Of Changes

Running Cypress locally has caused some level of developer frustration. Some tests require messing with environment variables to get them to behave like the CI tests, others fail randomly due to race conditions. These fixes help make everything more consistent, and thereby help give more confidence in the tests as we work.

Code Changes

  • Move the definition of the patchNoticesServed intercept for consent-i18n.cy.ts in to the beforeEach section to make sure it's ready prior to the test running at all. This was one that was randomly failing.
  • Force isOverlayEnabled to be false on a particular consent test that was previously requiring developers to set to false manually before running. No longer need to update .env to run tests!
  • Force isOverlayEnabled to be true on a test that would then fail when trying to update .env to make the previous test work. This one would also randomly fail without any .env adjustments due to the runner picking up env variable after the override sometimes.
  • Address some timezone issues that recently crept in.

Steps to Confirm

  • Privacy Center and Admin UI Cypress tests should continue to pass in the CI environment.
  • Running the Cypress tests locally should pass consistently (run it a couple times to be sure)

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Update CHANGELOG.md

Copy link

vercel bot commented Jun 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Jul 1, 2024 5:32pm

Copy link

cypress bot commented Jun 29, 2024

Passing run #8636 ↗︎

0 4 0 0 Flakiness 0

Details:

Merge 3639557 into 79ec541...
Project: fides Commit: fe48ea54f5 ℹ️
Status: Passed Duration: 00:33 💡
Started: Jul 1, 2024 5:43 PM Ended: Jul 1, 2024 5:44 PM

Review all test suite changes for PR #5040 ↗︎

Copy link
Contributor

@NevilleS NevilleS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good - just some clarifying questions

Comment on lines +41 to +44
env: {
// race condition sometimes picks up env variable *after* the override, so let's be double sure
FIDES_PRIVACY_CENTER__IS_OVERLAY_ENABLED: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? I can't really find any references for the it() function...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it has 3 parameters, the 2nd one is for options. env is one of the options allowed for setting an environment variable for this test only.
see https://docs.cypress.io/guides/guides/environment-variables#Option-5-Test-Configuration

Comment on lines 403 to 404
cy.window();
cy.window().then((win) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the double .window() intentional to make this less flakey?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a copy/pasta issue. I'll double check 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed! Good catch.

Comment on lines +1635 to +1640
// Consent reporting intercept
cy.intercept(
"PATCH",
`${API_URL}/consent-request/consent-request-id/notices-served`,
{ fixture: "consent/notices_served.json" }
).as("patchNoticesServed");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@gilluminate gilluminate merged commit a01735f into main Jul 1, 2024
13 checks passed
@gilluminate gilluminate deleted the gill/cypress-race-conditions branch July 1, 2024 17:48
Copy link

cypress bot commented Jul 1, 2024

Passing run #8637 ↗︎

0 4 0 0 Flakiness 0

Details:

fix various Cypress race conditions in Privacy Center (#5040)
Project: fides Commit: a01735f32d
Status: Passed Duration: 00:33 💡
Started: Jul 1, 2024 5:59 PM Ended: Jul 1, 2024 5:59 PM

Review all test suite changes for PR #5040 ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants