Add unit tests for shared quick-open and tabs utilities - #742
Open
IzonIcy wants to merge 1 commit into
Open
Conversation
The fuzzy scorer and file filtering used by quick open, global search, AI mentions, and the file explorer had no direct tests, nor did the tab display name calculation that disambiguates buffers sharing a filename. Adds focused unit tests for fuzzyScore scoring tiers, density rejection, file ignoring rules, recent-file workspace filtering, and display name disambiguation including virtual buffers. Writing the path shortener tests surfaced a small bug: absolute paths produced an empty first segment after splitting on "/", so fallback display names rendered with a double slash like "..//workspace/x.ts". Empty segments are now dropped when collecting path segments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add unit tests for shared quick-open and tabs utilities
What
Adds the first direct unit tests for three widely used but untested utilities:
src/features/quick-open/utils/fuzzy-search.ts—fuzzyScorescoring tiers (exact 1000 / prefix 800 / substring 600), case insensitivity, short-query substring-only rule, subsequence scoring with consecutive-match rewards, and the density guard that rejects sparse matches.src/features/quick-open/utils/file-filtering.ts—shouldIgnoreFileagainst dependency/build directories, lockfiles, and OS metadata, plusfilterQuickOpenRecentFilesworkspace membership, index gating, external files before the file tree loads, and the no-root-folder case.src/features/tabs/utils/path-shortener.ts—calculateDisplayNamesbare filenames for unique paths, minimal parent-directory disambiguation for duplicate names, walking further up as needed, full-path fallback, and virtual buffer passthrough.These helpers back quick open, global search, AI file mentions, the file explorer, and the tab bar.
Bug found while writing tests
Absolute paths produce an empty first segment when split on
/(e.g."/workspace/dup/index.ts"yields["", "workspace", "dup", "index.ts"]). The fallback display path joined those segments directly, rendering double slashes like..//workspace/dup/index.ts.getPathSegmentsnow drops empty segments.Testing
18 new tests across 3 files; full suite passes: 360 files, 1768 tests. Typecheck and lint pass.
bun checkreports only the pre-existingcargo fmtdiffs that also appear on cleanmain.I agree to the Contributor License and Feedback Agreement.