Repository navigation
[Refactor] Add test-utils guardrails and convert remaining stragglers - #2279
Conversation
Co-authored-by: Roomote <roomote@roomote.dev>
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the
|
|
No code issues found. See session Reviewed 22f1cf4 |
Review statusThis PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging. Current step: The required review sequence passed. Remaining merge requirements apply. Review-state labels are managed by this workflow; do not edit them manually. |
|
Self-review summary (rebased refresh, supersedes #1206) Reviewed the full branch diff against
No changesets, no runtime or user-facing behavior change. Visual proof not applicable (ESLint config + test-only). |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…#2279) * refactor: add test-utils guardrails and convert remaining stragglers Co-authored-by: Roomote <roomote@roomote.dev> * refactor: convert new test-utils stragglers to shared helpers --------- Co-authored-by: Roomote <roomote@roomote.dev>
Related GitHub Issue
N/A — internal test-infrastructure initiative (test-utils rollout, Phase 4 guardrails). No user-facing issue.
Description
Adds guardrails so the test-utils migration cannot regress, and converts the remaining stragglers so the guardrails land green. Rebased onto latest
mainand refreshed: conflicts resolved and new stragglers introduced since the original branch were converted.Guardrails
src/eslint.config.mjs: ano-restricted-syntaxrule blocks directvi.clearAllMocks()/vitest.clearAllMocks()in the converted lanes (api/providers/__tests__,core/config/__tests__,services/code-index/**/__tests__,integrations/terminal/**/__tests__). The error message points to the sharedclearAllMocks()helper insrc/test-utils/reset. The rule shares onetestResetHelperSelectorconst and repeats main's test path-traversal and API-provider-hygiene selectors in the lane blocks, because laterno-restricted-syntaxblocks replace earlier ones for the same files.webview-ui/eslint.config.mjs: ano-restricted-importsrule blocksQueryClientProviderimports insrc/components/**/__tests__/**/*.tsx, pointing torenderWithExtensionState. Hook specs (including.tsxones, which pass a specificQueryClienttorenderHook) and Playwright*.visual.fixture.tsxfiles are explicitly exempt..github/pull_request_template.md: adds a "Test Helpers" checklist item — shared helpers are only for mechanical duplication; test intent and scenario-specific mocks stay visible.Straggler conversions (assertions and scenario mocks untouched)
CustomModesManager.spec.ts: 9 call sites moved to the sharedclearAllMocks().mainsince the original branch:github-copilot(3 sites),vscode-lm,io-intelligence,nanogpt,code-index-manager-registry,code-index-scope,code-index-status-manager,code-index-workspace-scope,embedder-validation-manager,processor-factories,vector-store-factory.useSelectedModel,useZooGatewayRouterModelsSync, anduseOpenRouterModelProvidersnow usecreateTestQueryClient().Poe,Moonshot, andLiteLLMrender throughrenderWithExtensionState(withcreateTestQueryClient()where a test spies on cache invalidation); theirExtensionStateContextmocks spread the real module so the provider stays available.ProviderRoutinguses the sharedrenderfrom@/utils/test-utils(QueryClient + Tooltip only) because the extension-state provider's mount posts an extra message that would break an exactpostMessagecall-count assertion.Test Procedure
api/providersandservices/code-indexlanes, and the webview rule fires for a hand-wrappedQueryClientProvider— each with the intended error message. Exempted hook specs and visual fixtures lint clean. Probes removed.pnpm testgreen (extension 11,980 passed / 552 files; webview and all other packages green). One earlier full run flaked in__tests__/extension.spec.ts(untouched by this PR); it passes in isolation and on the full rerun.pnpm lintandpnpm check-typesgreen across all packages.src/eslint-suppressions.jsonunchanged.Pre-Submission Checklist
src/test-utils/,@/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible.Visual Snapshots
N/A — ESLint configuration and test-only changes; no rendered surface changes.
Videos (interaction / animation only)
N/A.
Documentation Updates
Additional Notes
Supersedes #1206 (closed; GitHub cannot reopen it because the branch was force-pushed while closed). Same branch, rebased onto latest
main, with the original guardrail intent preserved and the rule implementation adapted to compose with main's newerno-restricted-syntaxblocks.