cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Search cannot find paths with filenames

Open DanielYang-AT opened this issue 2 years ago • 2 comments

Current behavior

When searching in the Cypres UI for a file, if the full path is used, Cypress cannot find the file. When just the folder is searched, Cypress can find the files. Also, if just the filename is used as a search parameter, then Cypress can find the test file.

For example

cypress/e2e/spec.cy.js -> will not be found

cypress/e2e/ -> will not find any results

cypress/e2e -> will find the files in the e2e folder

spec.cy.js -> will find all tests with the same name

Desired behavior

Cypress should allow searching with the full path of a file and be able to find any test file if the filename+full relative path is passed as a search parameter.

Test code to reproduce

https://github.com/DanielYang-AT/cypress-test-tiny (this is a fork of the cypress-test-tiny with 0 changes)

  • Run Cypress Open
  • Select e2e testing
  • Open with chrome or electron
  • search for a spec by pasting in cypress/e2e/spec.cy.js
  • no results are found when the example spec should be shown.

Cypress Version

10.2.0

Other

Cypress 9.x.x and below were all able to find the files as expected. This was a change after the upgrade to 10.x.x

DanielYang-AT avatar Jun 22 '22 22:06 DanielYang-AT

+1 Cypress UI search is completely broken. It ALWAYS defaults to partial matching, so there's no way I can find tests via a perfect match and that makes it quite useless.

As an example: In my specs tree I've a folder "simulations" and a folder "lti", each containing various .cy files.

If I type "lti" in the UI search box, this will match both the "simulation" folder (it matches both the "l" and "ti" separately) and the "lti" folder (via a complete match). That's not what 99% of the human beings using a search box expect, at all....

dmolin avatar Jun 23 '22 09:06 dmolin

Thank you for the report and the reproduction @DanielYang-AT. I can confirm your findings. We have a separate issue logged for some known issues with search (https://github.com/cypress-io/cypress/issues/21879), but I will leave this issue open as it calls attention to some specific incorrect behaviors.

tbiethman avatar Jun 23 '22 15:06 tbiethman

Note for picking this up:

To fix this, we need to account for more than just baseName and directory here and start to match on the full relative path to the file.

This might have a couple of side effects to watch out for related to how we highlight matching segments of the results, so there could be some further adjustments needed.

marktnoonan avatar Aug 10 '22 22:08 marktnoonan

The code for this is done in cypress-io/cypress#23325, but has yet to be released. We'll update this issue and reference the changelog when it's released.

cypress-bot[bot] avatar Aug 16 '22 15:08 cypress-bot[bot]

Released in 10.6.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v10.6.0, please open a new issue.

tbiethman avatar Aug 16 '22 20:08 tbiethman