test(mcp): cover find-opportunities searchQuery, goal-spec, and token-fallback paths - #6106
Conversation
…-fallback paths runFindOpportunities was at 79.34% branch coverage (96/121) -- several real paths were never exercised by test/unit/find-opportunities.test.ts, which only ever called it with targets. Add cases for: the searchQuery path plus its post-search canAccessRepo re-filter, buildGoalSpecsByRepo's lane/languages arms, appliedLane/appliedMinRankScore inclusion vs omission, the validated.ok===false path through runFindOpportunities, and resolveDiscoveryGithubToken's installation-token fallback loop (skip-uninstalled, success, and the swallowed createInstallationToken failure). find-opportunities.ts is now 100% branch and statement covered. Test-only change; no src modified. Closes JSONbored#5847
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6106 +/- ##
==========================================
+ Coverage 95.24% 95.30% +0.06%
==========================================
Files 595 595
Lines 47035 47046 +11
Branches 15015 15015
==========================================
+ Hits 44797 44839 +42
+ Misses 1493 1476 -17
+ Partials 745 731 -14
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-15 09:48:48 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 4 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Closes #5847.
runFindOpportunities(src/mcp/find-opportunities.ts) was at 79.34% branch coverage (96/121) — the lowest of anysrc/mcp/**file — becausetest/unit/find-opportunities.test.tsonly ever called it withtargets. This adds the missing cases.Test-only change — no
src/**modified, socodecov/patchhas nothing to gate.New coverage
canAccessRepore-filter (stubs the/search/issuesendpoint the same way the existing tests stub per-repo fetches; asserts a returned repo is dropped by the re-filter).buildGoalSpecsByRepoboth arms — a lane-only spec (preferredLabels arm) and a languages-only spec (wantedPaths arm), plus the no-goalSpec early return.appliedLane/appliedMinRankScore— asserted present when a lane/min-rank-score is supplied, omitted when absent.validated.ok === falseexercised throughrunFindOpportunities(not just the validator directly).resolveDiscoveryGithubTokeninstallation-token fallback — skip-uninstalled (continue), success, and the swallowedcreateInstallationTokenfailure — viarunFindOpportunitieswith a seeded installed repo and a stubbedcreateInstallationToken(only that onesrc/github/appexport is mocked; the rest stay real).Result
find-opportunities.tsis now 100% branch and 100% statement covered (verified locally withvitest --coverage); the fullfind-opportunities.test.tssuite passes (22 tests).