-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: gate WebKit behind experimentalWebKitSupport in prod #23711
Conversation
Thanks for taking the time to open a PR!
|
@@ -86,7 +86,7 @@ export const AllCypressErrors = { | |||
}, | |||
CHROME_WEB_SECURITY_NOT_SUPPORTED: (browser: string) => { | |||
return errTemplate`\ | |||
Your project has set the configuration option: ${fmt.highlight(`chromeWebSecurity`)} to ${fmt.highlightTertiary(`false`)} | |||
Your project has set the configuration option: \`chromeWebSecurity\` to \`false\`. |
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.
launchpad
is not rendering ANSI escape sequences like desktop-gui
once did, so I changed this to a plain text representation
@@ -27,7 +27,7 @@ | |||
}" | |||
> | |||
<Tooltip | |||
v-if="!browser.isVersionSupported" | |||
v-if="browser.warning" |
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 also fixes an issue where the chromeWebSecurity
warning did not display.
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.
Did we add a regression test for this somewhere? Not sure I see it
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.
I think you'd add it in this file potentially: https://github.com/cypress-io/cypress/blob/develop/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts#L96
Just pick a system-tests project that has chromeWebSecurity: false
and it should show up.
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.
There are percy snapshots for the warning icon itself, does that cover the need for a test?
getAllBrowsersWith (nameOrPath?: string) { | ||
debug('getAllBrowsersWith %o', { nameOrPath }) | ||
if (nameOrPath) { | ||
return utils.ensureAndGetByNameOrPath(nameOrPath, true) |
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 code path was never used so I removed this function entirely.
@@ -258,17 +262,10 @@ const getBrowsers = async () => { | |||
version, | |||
path: '', | |||
majorVersion, | |||
info: 'Electron is the default browser that comes with Cypress. This is the default browser that runs in headless mode. Selecting this browser is useful when debugging. The version number indicates the underlying Chromium version that Electron uses.', |
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 the subject of #21769 - info display has been broken since 10.0.0. I've just removed it in lieu of adding the info
display back in.
export async function open (browser: Browser, url: string, options: BrowserLaunchOpts, automation: Automation): Promise<BrowserInstance> { | ||
if (!options.experimentalWebKitSupport) { | ||
throw new Error('WebKit was launched, but the experimental feature was not enabled. Please add `experimentalWebKitSupport: true` to your config file to launch WebKit.') |
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 reached if the user passes --testingType --browser webkit
and bypasses the GUI.
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
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.
Some various nits/questions but no obvious problems, testing it now.
@@ -500,14 +500,22 @@ export class ProjectConfigManager { | |||
} | |||
|
|||
fullConfig.browsers = fullConfig.browsers?.map((browser) => { | |||
if (browser.family === 'chromium' || fullConfig.chromeWebSecurity) { | |||
return browser | |||
if (browser.family === 'webkit' && !fullConfig.experimentalWebKitSupport) { |
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.
I see what you mean by confusing now, there's about 20 places we modify the config, and it's not clear if this is the right place to do it, or one of the other 19 🤔
@@ -380,6 +380,8 @@ export class ProjectLifecycleManager { | |||
} | |||
|
|||
private _setCurrentProject (projectRoot: string) { | |||
process.chdir(projectRoot) |
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.
I wonder why we needed to add this specifically during this PR? Or was it just a drive-by fix or sorts, not actually required for WK?
Edit: we need it for this reason:
Fixes the issue where playwright-webkit is resolved from the sourcedir, not the projectRoot, outside of development - e8c0d9a
Will leave this note to assist other reviews who might have the same question.
@@ -1,6 +1,5 @@ | |||
import _ from 'lodash' | |||
import { SourceMapConsumer } from 'source-map' | |||
import Promise from 'bluebird' |
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.
Bluebird is not not bad but it contributes to "the code base showing it's age". I hope we can just rip all of bluebird out in one fowl swoop sometime.
pun absolute intended
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.
😆 Yeah, this one in particular was needed to fix typings.
@@ -27,7 +27,7 @@ | |||
}" | |||
> | |||
<Tooltip | |||
v-if="!browser.isVersionSupported" | |||
v-if="browser.warning" |
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.
Did we add a regression test for this somewhere? Not sure I see it
@@ -27,7 +27,7 @@ | |||
}" | |||
> | |||
<Tooltip | |||
v-if="!browser.isVersionSupported" | |||
v-if="browser.warning" |
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.
I think you'd add it in this file potentially: https://github.com/cypress-io/cypress/blob/develop/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts#L96
Just pick a system-tests project that has chromeWebSecurity: false
and it should show up.
In run mode, I notice the stack trace is kinda ugly. I wonder if it's worth the effort to truncate the error message, or just do a Running: Alert.cy.tsx (1 of 42)
WebKit was launched, but the experimental feature was not enabled. Please add `experimentalWebKitSupport: true` to your config file to launch WebKit.
Error: WebKit was launched, but the experimental feature was not enabled. Please add `experimentalWebKitSupport: true` to your config file to launch WebKit.
at Object.open (/home/lachlan/code/work/dev/packages/server/lib/browsers/webkit.ts:47:15)
at Object.open (/home/lachlan/code/work/dev/packages/server/lib/browsers/index.ts:109:49)
at OpenProject.relaunchBrowser (/home/lachlan/code/work/dev/packages/server/lib/open_project.ts:150:20)
From previous event:
at wait (/home/lachlan/code/work/dev/packages/server/lib/modes/run.ts:387:35)
at waitForBrowserToConnect (/home/lachlan/code/work/dev/packages/server/lib/modes/run.ts:410:12)
at runSpec (/home/lachlan/code/work/dev/packages/server/lib/modes/run.ts:709:9)
at runEachSpec (/home/lachlan/code/work/dev/packages/server/lib/modes/run.ts:581:29)
error Command failed with exit code 1. Just thought I'd point this out, not obvious from the screenshots in your description. It works great in the open mode UI - nice message appears when you don't enable the flag. Linux error is a bit janky if you don't install the deps: I wonder if we want a proper error for this (nice formatting?) It works great, the actual browser window looks quite nice, too! |
No code blocker for me, curious if we need to add a test for the regression you fixed w.r.t the CDP warning that wasn't displaying? Can do separately if we are on a timeline, might be good to make an issue to track if that's the case. |
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.
Code seems fine, last nice to have would be this comment: #23711 (comment) 🙏 thoughts?
@lmiller1990 I fixed the error display: I also noticed another bug... we aren't catching GQL errors in prod... so if you don't pass I'll create tasks for the missing coverage once this merges. |
Looks good, let's ship it. The remaining CI fails are just Percy flake, so I think it's fine to squash merge? |
User facing changelog
experimentalWebKitSupport
config value totrue
to opt-in to this experiment.Additional details
config.browsers
is modifiable along with the rest of the config duringsetupNodeEvents
, these are the detection rules:playwright-webkit
is installed.experimentalWebKitSupport
is not set, disable the browser and error if it's launched in run mode. In Open mode, display it greyed out and with a warning.playwright-webkit
is resolved from the sourcedir, not the projectRoot, outside of development - e8c0d9aSteps to test
How has the user experience changed?
cypress run
...experimentalWebKitSupport
is false and--browser webkit
is passed:require
the user'splaywright-webkit
and use it to run tests.cypress open
...experimentalWebKitSupport
is enabled butplaywright-webkit
is not installed, and no--browser --testingType
is passed. Attempting to launch with the module missing results in a require error.experimentalWebKitSupport
is false butplaywright-webkit
IS installed:experimentalWebKitSupport
is false and--testingType --browser webkit
is passed to try and quicklaunch into WK:PR Tasks
cypress-documentation
?type definitions
? docs: document experimentalWebKitSupport cypress-documentation#4710