Skip to content

Add unit tests for shared quick-open and tabs utilities - #742

Open
IzonIcy wants to merge 1 commit into
athasdev:mainfrom
IzonIcy:add-utility-unit-tests
Open

Add unit tests for shared quick-open and tabs utilities#742
IzonIcy wants to merge 1 commit into
athasdev:mainfrom
IzonIcy:add-utility-unit-tests

Conversation

@IzonIcy

@IzonIcy IzonIcy commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

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.tsfuzzyScore scoring 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.tsshouldIgnoreFile against dependency/build directories, lockfiles, and OS metadata, plus filterQuickOpenRecentFiles workspace membership, index gating, external files before the file tree loads, and the no-root-folder case.
  • src/features/tabs/utils/path-shortener.tscalculateDisplayNames bare 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. getPathSegments now drops empty segments.

Testing

18 new tests across 3 files; full suite passes: 360 files, 1768 tests. Typecheck and lint pass. bun check reports only the pre-existing cargo fmt diffs that also appear on clean main.

I agree to the Contributor License and Feedback Agreement.

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.
Copilot AI lite review requested due to automatic review settings August 23, 2026 01:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants