Skip to content

fix(mcp): count cypress/e2e and snapshot paths as test files#2120

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
glorydavid03023:fix/mcp-test-file-cy-snapshot
Jul 1, 2026
Merged

fix(mcp): count cypress/e2e and snapshot paths as test files#2120
JSONbored merged 2 commits into
JSONbored:mainfrom
glorydavid03023:fix/mcp-test-file-cy-snapshot

Conversation

@glorydavid03023

Copy link
Copy Markdown
Contributor

Summary

The MCP client copy of isTestFile in packages/gittensory-mcp/lib/local-branch.js is a hand-copied duplicate of the canonical isTestPath in src/signals/test-evidence.ts, but it dropped the last two branches:

  • /(^|\/)[^/]+\.(cy|e2e)\.(ts|tsx|js|jsx)$/i — Cypress / Playwright e2e tests
  • /(^|\/)__snapshots__\//i — Jest/Vitest snapshot files

The server-side analysis (src/signals/local-branch.ts) delegates to isTestPath (and a test asserts it stays "in sync"), so the client and server classify the same diff and must agree. Because isCodeFile = codeExt && !isTestFile, a changed Button.cy.ts or src/__snapshots__/x.snap.ts was misclassified as source — dropped from collectLocalDiff().testFiles, counted in codeFiles, inflating the source-line/token estimate and under-reporting test evidence in the emitted local packet.

isTestFile("components/Button.cy.ts")          // => false (should be true)
isTestFile("src/__snapshots__/Button.snap.ts") // => false (should be true)
isCodeFile("components/Button.cy.ts")          // => true  (should be false)

Fix: add the two missing branches so the client mirrors isTestPath, and export isTestFile/isCodeFile so the regression is unit-testable. Pure helper — no schema or API change.

No issue because issue creation is restricted on this repo for outside accounts; this is a small, self-evident consistency fix.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage (see note below)
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack (see note below)
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • The change is confined to the MCP package helper (plain JS, outside Codecov's src/**/*.ts include, so no patch-coverage obligation). A regression test was added in test/unit/local-branch.test.ts (via the existing dynamic-import harness) asserting the Cypress/e2e/snapshot paths now classify as tests (and no longer as code) while plain source is unchanged; it passes, and the full local-branch.test.ts (56 tests) passes. build:mcp (node --check) and typecheck are clean. I did not run the full test:coverage / UI / workers steps (unrelated to this MCP-only diff), and could not run test:mcp-pack locally because this machine runs Node 24 while the repo pins Node 22 (.nvmrc); scripts/check-mcp-package.mjs throws ERR_INVALID_ARG_TYPE on Node 24 identically on unmodified main. CI runs the full matrix on the pinned Node.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A: no auth/cookie/CORS/session changes.
  • API/OpenAPI/MCP behavior is updated and tested where needed. (Behavior fix in the MCP local classifier; covered by the added regression test. No request/response schema changed.)
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A: no UI change.
  • Visible UI changes include a UI Evidence section below. — N/A: no visible UI change.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. (No docs/changelog change; MCP changelog is a release-prep artifact.)

Notes

  • Regression test asserts components/Button.cy.ts, e2e/login.e2e.tsx, and src/__snapshots__/Button.snap.ts are test files (and not code files), the existing test forms still classify as tests, and plain src/app.ts stays source.
  • No UI Evidence section: there is no visible UI, frontend, docs, or extension change.

The MCP client copy of isTestFile is a hand-copied duplicate of the canonical
isTestPath in src/signals/test-evidence.ts, but it dropped the last two
branches: `*.cy.*` / `*.e2e.*` (Cypress/Playwright e2e) and `__snapshots__/`
(Jest/Vitest snapshots). The server-side analysis delegates to isTestPath, so
the client and server classify the same diff and must agree.

Because isCodeFile is `codeExt && !isTestFile`, a changed `Button.cy.ts` or
`__snapshots__/x.snap.ts` was misclassified as source: dropped from
collectLocalDiff().testFiles, counted in codeFiles, inflating the
source-line/token estimate and under-reporting test evidence in the local
packet. Add the two missing branches so the client mirrors isTestPath, export
isTestFile/isCodeFile, and add a regression test.

No issue because issue creation is restricted on this repo; this is a small,
self-evident consistency fix in a pure helper with no schema or API change.
@loopover-orb

loopover-orb Bot commented Jul 1, 2026

Copy link
Copy Markdown

Important

🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪

🔍 Gittensory is reviewing…

AI analysis is in progress. This comment will update when the review is complete.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing

@loopover-orb loopover-orb Bot added gittensor gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.75%. Comparing base (51c9482) to head (52b9762).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2120   +/-   ##
=======================================
  Coverage   95.74%   95.75%           
=======================================
  Files         223      223           
  Lines       24787    24812   +25     
  Branches     8989     9004   +15     
=======================================
+ Hits        23732    23758   +26     
+ Misses        433      432    -1     
  Partials      622      622           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added the lgtm label Jul 1, 2026
@JSONbored
JSONbored merged commit 043e5c6 into JSONbored:main Jul 1, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jul 1, 2026
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants