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: Modify doubleEscape to handle path with extra backslashes and launch edge without browser key #14723

Merged
merged 8 commits into from Feb 8, 2021

Conversation

SagarGaniga
Copy link
Contributor

@SagarGaniga SagarGaniga commented Jan 24, 2021

User facing changelog

  • Fixes the issue with --browser for edge browsers on windows, allows users to pass just path to edge.exe and launch the browser.
  • Fixes the issue with --browser to launch browsers when the path has extra backslashes on windows

Additional details

  • Why was this change necessary? To allow edge and chrome to launch on windows properly with --browser
  • What is affected by this change? Browser detection in windows with --browser arg

--browser was breaking on windows for every browser but it was fixed in v5.4.0. But it still has issues

  • launching edge browsers when just the path is given without browser key
  • launching edge and chrome when given path has multiple escaped \
    This PR adds code to handle edge paths and modifies doubleEscape function with the help of path.win32 module which is capable of handling windows specific path separators in windows/index.ts

This PR also adds some test cases to make sure these use cases are always tested.

How has the user experience changed?

Users can pass edge and chrome paths with more freedom around escaped chars.
Users can now

  • Launch edge like cypress run --browser "C:\\foo\\bar\\edge.exe"
  • Launch chrome like cypress run --browser "C:\\\\foo\\\\bar\\\\chrome.exe"

PR Tasks

  • Have tests been added/updated?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 24, 2021

Thanks for taking the time to open a PR!

@CLAassistant
Copy link

CLAassistant commented Jan 24, 2021

CLA assistant check
All committers have signed the CLA.

@SagarGaniga
Copy link
Contributor Author

Can someone please review this PR?
ci/circleci: server-e2e-tests-chrome is failing repeatedly and I am not understanding what is the exact issue with it, can someone please check those errors?

@jennifer-shehane
Copy link
Member

@SagarGaniga The server-e2e-tests-chrome failing are unrelated to this PR. A recent change in our stdout warnings is causing some flake in our internal snapshots. Our team is hoping to review this PR next sprint.

Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

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

Looks great! Just a few minor things

if (pathStr.indexOf('chrome.exe') > -1) {
return { path, browserKey: 'chrome' }
}

if (pathStr.indexOf('edge.exe') > -1) {
return { path, browserKey: 'edge' }
Copy link
Contributor

Choose a reason for hiding this comment

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

Ha, I guess this does technically work for msedge.exe too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, keeping that browserKey edge for msedge.exe too as we use edge everywhere else.

expect(res.browserKey).to.eq('chrome')
})

it('returns path and edge given just path', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could also use a test for msedge.exe - that is what #14716 is about

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated

Comment on lines 28 to 31
function doubleEscape (s: string) {
return win32.join(...s.split(win32.sep)).replace(/\\/g, '\\\\')
}

Copy link
Contributor

Choose a reason for hiding this comment

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

could you just import this from windows.ts?

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 you mean packages/launcher/lib/windows/index.ts

Exported that function, used it in the test case and added its own test cases

Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

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

Great stuff! Thanks for submitting this PR.

@flotwig
Copy link
Contributor

flotwig commented Feb 8, 2021

While testing this PR, I noticed that the errors for path detection here are kinda abysmal... no fault of this PR tho

this PR

image

image

image

image

develop

image

image

image

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