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: force forward slash to backslash on Windows in spec search input #23776

Merged
merged 5 commits into from Sep 12, 2022

Conversation

astone123
Copy link
Contributor

@astone123 astone123 commented Sep 12, 2022

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

  1. Open a project that has at least one spec in a directory that is not in the project root
  2. Search for the spec by its directory (for example, if your spec is src\specs\MySpec.cy.tsx, search for src/specs/)
  3. Verify that the directory names are highlighted in the specs list and your spec appears
  4. Repeat these steps for the inline spec list (the spec list that shows in the side bar when a test is running

Unix

  1. Follow the steps for Windows and verify that nothing has changed with the specs search

How has the user experience changed?

Windows users will see their / change to \ when they use the spec search

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@astone123 astone123 requested a review from a team September 12, 2022 13:16
@astone123 astone123 self-assigned this Sep 12, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 12, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Sep 12, 2022



Test summary

40019 0 3346 0Flakiness 2


Run details

Project cypress
Status Passed
Commit 31c97a8
Started Sep 12, 2022 5:29 PM
Ended Sep 12, 2022 5:48 PM
Duration 18:41 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

angular.cy.ts Flakiness
1 Working with angular-14 > should mount a passing test
e2e/origin/commands/log.cy.ts Flakiness
1 cy.origin log > logs in primary and secondary origins

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

Copy link
Contributor

@mike-plummer mike-plummer left a 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:

  1. 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') {
  ...
}
  1. 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

@mike-plummer mike-plummer requested a review from a team September 12, 2022 14:46
Copy link
Contributor

@ZachJW34 ZachJW34 left a 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

packages/app/src/specs/InlineSpecListHeader.vue Outdated Show resolved Hide resolved
@astone123
Copy link
Contributor Author

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

@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 () {
Copy link
Contributor Author

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

Copy link
Contributor

@ZachJW34 ZachJW34 left a comment

Choose a reason for hiding this comment

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

Perfect!

@astone123 astone123 merged commit 7c6c231 into develop Sep 12, 2022
@astone123 astone123 deleted the astone123/windows-spec-search branch September 12, 2022 19:07
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.

Updated specs list search in 10.6 is not working with forward slash
3 participants