Skip to content

Conversation

@alexcrocha
Copy link
Contributor

@alexcrocha alexcrocha commented Oct 20, 2025

Motivation

Closes #3789

"Go to relevant file" currently fails when tests for an implementation file are split into multiple test files within a subdirectory (e.g., user.rb having tests like user/creation_test.rb). This makes it harder to discover and maintain these split tests. This PR extends the feature to find all associated tests within a matching subdirectory.

Instead of opening all found files at once, we present a list for the developer to select from. This gives developers control over which file to open rather than flooding their editor with tabs.

Example image image

Implementation

The implementation was changed to search using multiple glob patterns instead of just one. This involved refactoring the old relevant_filename_pattern method into relevant_filename_patterns to return an array of patterns.

This enables two key improvements:

1. Finding tests in matching subdirectories:

When triggering "Go to relevant file" on app/models/user.rb, the search now includes patterns that look inside a user/ subdirectory, finding files like:

  • test/models/user_test.rb (existing behavior)
  • test/models/user/create_user_test.rb (new)
  • test/models/user/test_update_user.rb (new)

2. Navigating back from nested tests:

The reverse navigation now also works for nested files. For example, from test/requests/go_to_relevant_file/go_to_relevant_file_a_test.rb, it will correctly find lib/requests/go_to_relevant_file.rb. This is done by checking if the parent directory's name is included in the test file's name.

Automated Tests

New tests have been added to cover these scenarios.

Manual Tests

  1. In a test project, create the following file structure:

    .
    ├── app
    │	└── models
    │		└── user.rb
    └── test
    	└── models
    		└── user
    			├── create_user_test.rb
    			└── update_user_test.rb
    
  2. Open app/models/user.rb.

  3. Click on the "Go to relevant file" button.

  4. Expected: A VS Code quick pick should appear with both create_user_test.rb and update_user_test.rb as options.

  5. Now open test/models/user/create_user_test.rb.

  6. Click on the "Go to relevant file" button.

  7. Expected: The editor should navigate directly to app/models/user.rb.

Copy link
Contributor Author


How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@alexcrocha alexcrocha force-pushed the 10-20-support_multiple_test_file_matches_in_go_to_relevant_file branch from 5698a0e to 2a0d13d Compare October 21, 2025 10:45
@alexcrocha alexcrocha added enhancement New feature or request server This pull request should be included in the server gem's release notes labels Oct 21, 2025
@alexcrocha alexcrocha marked this pull request as ready for review October 21, 2025 11:53
@alexcrocha alexcrocha requested a review from a team as a code owner October 21, 2025 11:53
@vinistock vinistock merged commit 1445d5d into main Oct 28, 2025
39 of 40 checks passed
@vinistock vinistock deleted the 10-20-support_multiple_test_file_matches_in_go_to_relevant_file branch October 28, 2025 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open all directly associated test files when using the go to tests functionality

2 participants