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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/app/cypress/e2e/specs_list_e2e.cy.ts
Expand Up @@ -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

// On Windows, when a user types `e2e/accounts`, it should match `e2e\accounts`
clearSearchAndType('e2e/accounts')
cy.findAllByTestId('spec-item').should('have.length', 2)

cy.findByText('No specs matched your search:').should('not.be.visible')
})

// TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23305
it.skip('saves the filter when navigating to a spec and back', function () {
const targetSpecFile = 'accounts_list.spec.js'
Expand Down
4 changes: 3 additions & 1 deletion packages/app/src/specs/spec-utils.ts
Expand Up @@ -125,8 +125,10 @@ function getHighlightIndexes <T extends FoundSpec> (node: SpecTreeNode<T>) {
}

export function fuzzySortSpecs <T extends FuzzyFoundSpec> (specs: T[], searchValue: string) {
const normalizedSearchValue = getPlatform() === 'win32' ? searchValue.replaceAll('/', '\\') : searchValue

const fuzzySortResult = fuzzySort
.go(searchValue, specs, { keys: ['relative', 'baseName'], allowTypo: false, threshold: -3000 })
.go(normalizedSearchValue, specs, { keys: ['relative', 'baseName'], allowTypo: false, threshold: -3000 })
.map((result) => {
const [relative, baseName] = result

Expand Down