Skip to content

Commit

Permalink
fix: Searching by files using digits (#29464)
Browse files Browse the repository at this point in the history
* fix: Searching by files using digits (Fixes #29034)

When trying to search for a file using digits cypress wasn't able
to find it. Now it is able to do more complex searches with digits.

* Update cli/CHANGELOG.md

* Update changelog to new version/reword

---------

Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
  • Loading branch information
3 people committed May 8, 2024
1 parent f3bdb9f commit 972c555
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 18 deletions.
10 changes: 10 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
## 13.9.1

_Released 5/21/2024 (PENDING)_

**Bugfixes:**

- Fixed an issue where Cypress was unable to search in the Specs list for files or folders containing numbers. Fixes [#29034](https://github.com/cypress-io/cypress/issues/29034).


## 13.9.0

_Released 5/7/2024_
Expand All @@ -9,6 +18,7 @@ _Released 5/7/2024_

**Bugfixes:**


- Fixed a bug where promises rejected with `undefined` were failing inside `cy.origin()`. Addresses [#23937](https://github.com/cypress-io/cypress/issues/23937).
- We now pass the same default Chromium flags to Electron as we do to Chrome. As a result of this change, the application under test's `navigator.webdriver` property will now correctly be `true` when testing in Electron. Fixes [#27939](https://github.com/cypress-io/cypress/issues/27939).
- Fixed network issues in requests using fetch for users where Cypress is run behind a proxy that performs HTTPS decryption (common among corporate proxies). Fixes [#29171](https://github.com/cypress-io/cypress/issues/29171).
Expand Down
2 changes: 1 addition & 1 deletion packages/app/cypress/e2e/reporter_header.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Reporter Header', () => {
cy.get('body').type('f')

cy.get('[data-selected-spec="true"]').should('contain', 'dom-content').should('have.length', '1')
cy.get('[data-selected-spec="false"]').should('have.length', '30')
cy.get('[data-selected-spec="false"]').should('have.length', '32')
})

// TODO: Reenable as part of https://github.com/cypress-io/cypress/issues/23902
Expand Down
26 changes: 20 additions & 6 deletions packages/app/cypress/e2e/specs_list_e2e.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,21 @@ describe('App: Spec List (E2E)', () => {

it('displays only matching spec', function () {
cy.get('button')
.contains('26 matches')
.contains('28 matches')
.should('not.contain.text', 'of')

clearSearchAndType('content')
cy.findAllByTestId('spec-item')
.should('have.length', 3)
.and('contain', 'dom-content.spec.js')

cy.get('button').contains('3 of 26 matches')
cy.get('button').contains('3 of 28 matches')

cy.findByLabelText('Search specs').clear().type('asdf')
cy.findAllByTestId('spec-item')
.should('have.length', 0)

cy.get('button').contains('0 of 26 matches')
cy.get('button').contains('0 of 28 matches')
})

it('only shows matching folders', () => {
Expand All @@ -188,6 +188,20 @@ describe('App: Spec List (E2E)', () => {
.and('contain', 'app.spec.js')
})

it('search by digits inside long strings', function () {
clearSearchAndType('4276')

cy.findByTestId('spec-item')
.should('have.length', 1)
.and('contain', 'dummyTest4276_test.spec.js')

clearSearchAndType('7890')

cy.findByTestId('spec-item')
.should('have.length', 1)
.and('contain', 'dummy7890Test_test.spec.js')
})

it('ignores non-number characters', function () {
clearSearchAndType('123spec')

Expand Down Expand Up @@ -218,7 +232,7 @@ describe('App: Spec List (E2E)', () => {
cy.findByLabelText('Search specs')
.should('have.value', '')

cy.get('button').contains('26 matches')
cy.get('button').contains('28 matches')
})

it('clears the filter if the user presses ESC key', function () {
Expand All @@ -227,7 +241,7 @@ describe('App: Spec List (E2E)', () => {

cy.get('@searchField').should('have.value', '')

cy.get('button').contains('26 matches')
cy.get('button').contains('28 matches')
})

it('shows empty message if no results', function () {
Expand All @@ -243,7 +257,7 @@ describe('App: Spec List (E2E)', () => {
cy.findByText('Clear search').click()
cy.focused().should('have.id', 'spec-filter')

cy.get('button').contains('26 matches')
cy.get('button').contains('28 matches')
})

it('normalizes directory path separators for Windows', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ describe('specChange subscription', () => {
getPathForPlatform('cypress/e2e/z007.spec.js'),
getPathForPlatform('cypress/e2e/z008.spec.js'),
getPathForPlatform('cypress/e2e/z009.spec.js'),
getPathForPlatform('cypress/e2e/dummyTest4276_test.spec.js'),
getPathForPlatform('cypress/e2e/dummy7890Test_test.spec.js'),
],
})

Expand Down Expand Up @@ -132,6 +134,8 @@ describe('specChange subscription', () => {
getPathForPlatform('cypress/e2e/z007.spec.js'),
getPathForPlatform('cypress/e2e/z008.spec.js'),
getPathForPlatform('cypress/e2e/z009.spec.js'),
getPathForPlatform('cypress/e2e/dummyTest4276_test.spec.js'),
getPathForPlatform('cypress/e2e/dummy7890Test_test.spec.js'),
],
})

Expand Down Expand Up @@ -193,7 +197,7 @@ e2e: {

cy.get('body').type('f')
cy.get('[data-cy="spec-file-item"]')
.should('have.length', 26)
.should('have.length', 28)
.should('contain', 'blank-contents.spec.js')
.should('contain', 'dom-container.spec.js')
.should('contain', 'dom-content.spec.js')
Expand All @@ -204,7 +208,7 @@ e2e: {
}, { path: getPathForPlatform('cypress/e2e/new-file.spec.js') })

cy.get('[data-cy="spec-file-item"]')
.should('have.length', 27)
.should('have.length', 29)
.should('contain', 'blank-contents.spec.js')
.should('contain', 'dom-container.spec.js')
.should('contain', 'dom-content.spec.js')
Expand All @@ -219,7 +223,7 @@ e2e: {

cy.get('body').type('f')
cy.get('[data-cy="spec-file-item"]')
.should('have.length', 26)
.should('have.length', 28)
.should('contain', 'blank-contents.spec.js')
.should('contain', 'dom-container.spec.js')
.should('contain', 'dom-content.spec.js')
Expand All @@ -230,7 +234,7 @@ e2e: {
}, { path: getPathForPlatform('cypress/e2e/dom-list.spec.js') })

cy.get('[data-cy="spec-file-item"]')
.should('have.length', 25)
.should('have.length', 27)
.should('contain', 'blank-contents.spec.js')
.should('contain', 'dom-container.spec.js')
.should('contain', 'dom-content.spec.js')
Expand Down Expand Up @@ -271,6 +275,8 @@ e2e: {
getPathForPlatform('cypress/e2e/z007.spec.js'),
getPathForPlatform('cypress/e2e/z008.spec.js'),
getPathForPlatform('cypress/e2e/z009.spec.js'),
getPathForPlatform('cypress/e2e/dummyTest4276_test.spec.js'),
getPathForPlatform('cypress/e2e/dummy7890Test_test.spec.js'),
],
})

Expand All @@ -293,7 +299,7 @@ e2e: {

cy.get('body').type('f')
cy.get('[data-cy="spec-file-item"]')
.should('have.length', 26)
.should('have.length', 28)
.should('contain', 'blank-contents.spec.js')
.should('contain', 'dom-container.spec.js')
.should('contain', 'dom-content.spec.js')
Expand Down Expand Up @@ -336,14 +342,14 @@ e2e: {
cy.get('[data-cy="spec-pattern"]').contains('cypress/e2e/**/*.spec.{js,ts}')

cy.get('[data-cy="file-match-indicator"]')
.should('contain', '26 matches')
.should('contain', '28 matches')

cy.withCtx(async (ctx, o) => {
await ctx.actions.file.writeFileInProject(o.path, '')
}, { path: getPathForPlatform('cypress/e2e/new-file.spec.js') })

cy.get('[data-cy="file-match-indicator"]')
.should('contain', '27 matches')
.should('contain', '29 matches')
})

it('responds to specChange event for a removed file', () => {
Expand All @@ -353,14 +359,14 @@ e2e: {
cy.get('[data-cy="spec-pattern"]').contains('cypress/e2e/**/*.spec.{js,ts}')

cy.get('[data-cy="file-match-indicator"]')
.should('contain', '26 matches')
.should('contain', '28 matches')

cy.withCtx(async (ctx, o) => {
await ctx.actions.file.removeFileInProject(o.path)
}, { path: getPathForPlatform('cypress/e2e/dom-list.spec.js') })

cy.get('[data-cy="file-match-indicator"]')
.should('contain', '25 matches')
.should('contain', '27 matches')
})

it('handles removing the last file', () => {
Expand Down Expand Up @@ -398,6 +404,8 @@ e2e: {
getPathForPlatform('cypress/e2e/z007.spec.js'),
getPathForPlatform('cypress/e2e/z008.spec.js'),
getPathForPlatform('cypress/e2e/z009.spec.js'),
getPathForPlatform('cypress/e2e/dummyTest4276_test.spec.js'),
getPathForPlatform('cypress/e2e/dummy7890Test_test.spec.js'),
],
})

Expand All @@ -419,7 +427,7 @@ e2e: {
cy.get('[data-cy="spec-pattern"]').contains('cypress/e2e/**/*.spec.{js,ts}')

cy.get('[data-cy="file-match-indicator"]')
.should('contain', '26 matches')
.should('contain', '28 matches')

cy.withCtx(async (ctx) => {
await ctx.actions.file.writeFileInProject('cypress.config.js',
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/specs/spec-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function fuzzySortSpecs <T extends FuzzyFoundSpec> (specs: T[], searchVal
const normalizedSearchValue = normalizeSpecValue(searchValue)

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Blank Contents', () => {
it('renders the blank page', () => {
cy.get('[data-cy="cypress-logo"]')
})

it('renders the visit failure page', () => {
cy.visit('http://localhost:999')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('Blank Contents', () => {
it('renders the blank page', () => {
cy.get('[data-cy="cypress-logo"]')
})

it('renders the visit failure page', () => {
cy.visit('http://localhost:999')
})
})

5 comments on commit 972c555

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 972c555 May 8, 2024

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.9.1/linux-x64/develop-972c55514d43e34bcf8c060497c64d5cf0677166/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 972c555 May 8, 2024

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.9.1/linux-arm64/develop-972c55514d43e34bcf8c060497c64d5cf0677166/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 972c555 May 8, 2024

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.9.1/darwin-arm64/develop-972c55514d43e34bcf8c060497c64d5cf0677166/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 972c555 May 8, 2024

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.9.1/win32-x64/develop-972c55514d43e34bcf8c060497c64d5cf0677166/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 972c555 May 8, 2024

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.9.1/darwin-x64/develop-972c55514d43e34bcf8c060497c64d5cf0677166/cypress.tgz

Please sign in to comment.