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

feat: add option to ignore chrome preferences #29447

Merged
merged 19 commits into from
Jun 4, 2024

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Apr 30, 2024

Additional details

Adds an IGNORE_CHROME_PREFERENCES option to ignore Chrome preferences paths.

Steps to test

How has the user experience changed?

PR Tasks

Copy link

cypress bot commented Apr 30, 2024

2 flaky tests on run #55647 ↗︎

0 4670 951 0 Flakiness 2

Details:

Merge branch 'develop' into ignore-chrom-prefs
Project: cypress Commit: 74202f0612
Status: Passed Duration: 16:12 💡
Started: Jun 4, 2024 2:22 PM Ended: Jun 4, 2024 2:38 PM
Flakiness  cypress/e2e/commands/net_stubbing.cy.ts • 2 flaky tests • 5x-driver-webkit

View Output

Test Artifacts
... > with `resourceType` > can match a proxied image request by resourceType
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <a href="https://cloud.cypress.io/projects/ypt4pf/runs/55647/overview/61f105e7-b855-4438-b395-de221e5928ef?reviewViewBy=FLAKY&utm_source=github&utm_medium=flaky&utm_campaign=view%20test">
        ... > stops waiting when an xhr request is canceled
      </a>
    </td>
    <td>
      
    </td>
  </tr></table>

Review all test suite changes for PR #29447 ↗︎

@@ -501,13 +513,16 @@ export = {
launchOptions.preferences = _mergeChromePreferences(preferences, launchOptions.preferences as ChromePreferences)
}

const p = _disableRestorePagesPrompt(userDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason this was pulled out of the promise array below?

@@ -501,13 +513,16 @@ export = {
launchOptions.preferences = _mergeChromePreferences(preferences, launchOptions.preferences as ChromePreferences)
}

const p = _disableRestorePagesPrompt(userDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we keep this here, we'll want a more appropriately named variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was for debugging while running - I'll remove

Copy link
Contributor

Choose a reason for hiding this comment

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

addressed in c209969

* this effectively prevents Cypress from writing to the Chrome preferences files.
* See: _writeChromePreferences
*/
if (process.env.IGNORE_CHROME_PREFERENCES) {
Copy link
Contributor

@mschile mschile May 13, 2024

Choose a reason for hiding this comment

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

I wonder if this should be more specific, SKIP_RETRIEVING_CHROME_PREFERENCES or SKIP_READING_CHROME_PREFERENCE_PATHS

if (process.env.IGNORE_CHROME_PREFERENCES) {
debug('ignoring chrome preferences...')

return Bluebird.resolve(_.mapValues(CHROME_PREFERENCE_PATHS, () => ({})))
Copy link
Contributor

Choose a reason for hiding this comment

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

What if only one of the CHROME_PREFERENCE_PATHS is encrypted, would we want to read from the other paths?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so - this makes more sense as an all-or-nothing thing. I'm curious if we should prevent writing preferences as well with this env var, but that may cause more confusion (or should be a separate env var). As is, if you set this env, and then provide preferences via config, it will still attempt to write preferences.


return Bluebird.resolve(_.mapValues(CHROME_PREFERENCE_PATHS, () => ({})))
}

debug('reading chrome preferences... %o', { userDir, CHROME_PREFERENCE_PATHS })

return Bluebird.props(_.mapValues(CHROME_PREFERENCE_PATHS, (prefPath) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We are already catching the ENOENT error below and returning an empty object. Is there an error thrown when reading an encrypted path? If so, can we just add it to below and remove the need of the new environment variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be the write logic combined with the lockfile removal, on relaunch, that throws the error, not the read?

cli/CHANGELOG.md Outdated Show resolved Hide resolved
cacieprins
cacieprins previously approved these changes May 20, 2024
@jennifer-shehane
Copy link
Member Author

@cacieprins to make some updates here based on our convo - to ignore writing and reading chrome prefs

@cacieprins
Copy link
Contributor

Latest changes applied:

  • definitively skip writing as well as reading - before, it would only skip as secondary behavior to the flag, and only if chrome preferences were not set in cy config

Co-authored-by: Matt Schile <mschile@cypress.io>
@jennifer-shehane jennifer-shehane merged commit e790891 into develop Jun 4, 2024
115 of 117 checks passed
@jennifer-shehane jennifer-shehane deleted the ignore-chrom-prefs branch June 4, 2024 14:17
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 4, 2024

Released in 13.11.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v13.11.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 4, 2024
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.

Add an option to ignore preferences files load on browser relaunch
4 participants