Skip to content

Commit 7c6c231

Browse files
authored
fix: force forward slash to backslash on Windows in spec search input (#23776)
1 parent 043ab9a commit 7c6c231

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/app/cypress/e2e/specs_list_e2e.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ describe('App: Spec List (E2E)', () => {
237237
cy.get('button').contains('23 Matches')
238238
})
239239

240+
it('normalizes directory path separators for Windows', function () {
241+
// On Windows, when a user types `e2e/accounts`, it should match `e2e\accounts`
242+
clearSearchAndType('e2e/accounts')
243+
cy.findAllByTestId('spec-item').should('have.length', 2)
244+
245+
cy.findByText('No specs matched your search:').should('not.be.visible')
246+
})
247+
240248
// TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23305
241249
it.skip('saves the filter when navigating to a spec and back', function () {
242250
const targetSpecFile = 'accounts_list.spec.js'

packages/app/src/specs/spec-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ function getHighlightIndexes <T extends FoundSpec> (node: SpecTreeNode<T>) {
125125
}
126126

127127
export function fuzzySortSpecs <T extends FuzzyFoundSpec> (specs: T[], searchValue: string) {
128+
const normalizedSearchValue = getPlatform() === 'win32' ? searchValue.replaceAll('/', '\\') : searchValue
129+
128130
const fuzzySortResult = fuzzySort
129-
.go(searchValue, specs, { keys: ['relative', 'baseName'], allowTypo: false, threshold: -3000 })
131+
.go(normalizedSearchValue, specs, { keys: ['relative', 'baseName'], allowTypo: false, threshold: -3000 })
130132
.map((result) => {
131133
const [relative, baseName] = result
132134

0 commit comments

Comments
 (0)