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: force forward slash to backslash on Windows in spec search input #23776
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
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.
Works well for me, both main and inline specs search work as described on Linux & Windows. There's a tiny gap where a windows filepath pasted into Cypress running on unix won't resolve, but that's outside the scope of the original defect. I do have two nitpicks:
- I would like to see a test for this. We have a few OS-specific tests floating around using a pattern like this:
if (os.platform() === 'win32') {
...
}
- In Windows when typing into the search field, if I enter a single forward slash
/
it is changed to a backslash (expected) and the cursor jumps to the end of the line (unexpected). Dynamically altering a model value often causes this sort of behavior, so I wonder if it would be better to move the path conversion logic into the search algo rather than trying to mutate it within the UI element
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.
Let's get a test for this new functionality
@mike-plummer yeah I'm going to change this to replace the separators on the server side instead of messing with the UI elements, good call. |
@@ -237,6 +237,14 @@ describe('App: Spec List (E2E)', () => { | |||
cy.get('button').contains('23 Matches') | |||
}) | |||
|
|||
it('normalizes directory path separators for Windows', function () { |
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 will fail on develop
for Windows right now because e2e/accounts
won't yield any results on Windows. With my changes it passes
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.
Perfect!
User facing changelog
When users on Windows use the spec list search, if their search term contains any instances of
/
, they will be replaced with\
to match the Windows path.Additional details
Users on Windows couldn't copy/paste paths from anywhere that used
/
for directories into the specs search because Windows uses\
for paths. This forces the text input to use\
on Windows so that search terms will match directories on Windows.Steps to test
Windows
src\specs\MySpec.cy.tsx
, search forsrc/specs/
)Unix
How has the user experience changed?
Windows users will see their
/
change to\
when they use the spec searchPR Tasks
cypress-documentation
?type definitions
?