Skip to content

fix(search): a __tests__/ folder at the repository root counts as a test - #500

Merged
bompus merged 1 commit into
fork/consolidatedfrom
fix/is-test-path-root-tests-dir
Oct 14, 2026
Merged

bompus merged 1 commit into
fork/consolidatedfrom
fix/is-test-path-root-tests-dir

Conversation

@bompus

@bompus bompus commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

A file in a __tests__/ folder at the top of a repository is now treated as a test, as one below src/ or any other folder already was.

Before, isTestPath matched /__tests__/ only with a directory above it, so __tests__/foo.ts was taken for production code while src/__tests__/foo.ts was not. Until upstream colbymchenry#2557 (merged in #499) this did not matter for the dominant-file and explore filters, which matched __tests__/ at the start of a path with their own pattern; colbymchenry#2557 moved them onto isTestFile and dropped that match. cubic flagged the gap on #499. The fix adds lower.startsWith('__tests__/') beside the existing tests/, spec/ and e2e/ start-of-path checks.

Verification, on head 2994ecc4d4d32f38053e82765552277da6a84023:

  • The new case in __tests__/is-test-file.test.ts fails without the change (isTestFile('__tests__/foo.ts') was false) and passes with it, including a negative case (my__tests__/foo.ts stays production).
  • tsc --noEmit and npm run check:agent-docs pass; the 25 test files that mention isTestFile, isTestPath, scorePathRelevance or __tests__/ pass (576 passed, 1 skipped).
  • The kernel has its own test-path function (is_test_path), unchanged here; this PR covers the TypeScript side only.

README rows checked: none mention test-path detection, so none changed. The changelog entry is under [Unreleased] and says to re-index projects with a top-level __tests__/ folder, because index-time synthesizers also read this function (unmeasured).


Summary by cubic

A file in a __tests__/ folder at the repository root now counts as a test, matching the behavior of such folders below src/ or any other directory.

Previously isTestPath matched /__tests__/ only when preceded by a directory, so __tests__/foo.ts was treated as production code. The fix adds lower.startsWith('__tests__/') beside the existing tests/, spec/, and e2e/ checks.

  • Adds a test case covering the new behavior and the negative case where my__tests__/foo.ts stays production.
  • Notes in the CHANGELOG that projects with a top-level __tests__/ folder should be re-indexed, since index-time synthesizers also read this function.

Written for commit 2994ecc. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Bug Fixes
    • Root-level __tests__/ files are now recognized as tests, matching nested test directories. They are excluded from production-code search and ranking and from main-routes file selection.
    • Re-index projects with a top-level __tests__/ folder for the updated classification to take effect.

isTestPath matched /__tests__/ only below another directory, so
__tests__/foo.ts was taken for production code while src/__tests__/foo.ts was
not. After upstream colbymchenry#2557 moved the dominant-file and explore filters onto
isTestFile, the old start-of-path match for __tests__/ was lost.
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2edd021c-5dbc-46ff-88f8-f055ca9fde13
📥 Commits

Reviewing files that changed from the base of the PR and between b61573c and 2994ecc.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • __tests__/is-test-file.test.ts
  • src/search/query-utils.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The test-path matcher now recognizes paths that begin with repository-root __tests__/. Regression tests cover root-level and nested test directories. The changelog notes the effects on search, explore ranking, main-routes-file selection, and re-indexing.

Changes: Root-level test path recognition

Layer / File(s) Summary
Test-path detection and validation
src/search/query-utils.ts, __tests__/is-test-file.test.ts, CHANGELOG.md
isTestPath now matches paths beginning with __tests__/. Tests check root-level and src/-level test paths, and reject my__tests__. The changelog describes the effects on search, explore ranking, and main-routes-file selection, and notes that affected projects need re-indexing.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 2994e

Root-level __tests__/ files are now classified as tests, affecting search, ranking, and route selection. Affected projects need re-indexing, as documented; no material unresolved merge risk remains.

### Architecture Summary

Architecture risk: 🔵 Low · up to 2994e

The change affects 3 systems.

Changed systems: src, CHANGELOG.md, __tests__

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.
  • observed — CHANGELOG.md (service) was modified; 1 changed file maps to changed impact.
  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in CHANGELOG.md: Adds a changelog entry stating that files in a repository-root __tests__/ folder are classified as tests rather than production code, affecting search and explore ranking and main-routes-file selection; it notes that affected projects must be re-indexed.
  • observed — Modified behavior in tests/is-test-file.test.ts: Added assertions that both detection functions recognize files under root-level and src/-level __tests__/ directories, but reject a directory named my__tests__.
  • observed — Modified behavior in src/search/query-utils.ts: isTestPath now also matches paths beginning with __tests__/; the existing e2e/ prefix match is unchanged.
Pre-merge checks: Passed 6
Passed Passed checks: 6 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: treating a repository-root tests/ folder as a test path.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Suppressions Explained Passed The pull request changes only CHANGELOG.md, tests/is-test-file.test.ts, and src/search/query-utils.ts. The added lines contain a changelog entry, test assertions, a test comment, and the tests…
User-Visible Changes Documented Passed PASS. The diff changes isTestPath classification, adds regression tests, and updates CHANGELOG.md. It does not add, remove, or rename a CLI command/flag, MCP tool or argument, supported language/f…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 LanguageTool
CHANGELOG.md

LanguageTool checks are incomplete because the per-file request limit of 5 was reached. Remaining text was skipped; findings from completed checks are retained.

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 3 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@bompus
bompus merged commit 8935444 into fork/consolidated Oct 14, 2026
2 checks passed
@bompus
bompus deleted the fix/is-test-path-root-tests-dir branch October 14, 2026 19:09
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.

1 participant