Skip to content

[Refactor] Add test-utils guardrails and convert remaining stragglers - #1206

Draft
zoomote[bot] wants to merge 1 commit into
mainfrom
feature/test-utils-guardrails-26vxix3b5tqmz
Draft

[Refactor] Add test-utils guardrails and convert remaining stragglers#1206
zoomote[bot] wants to merge 1 commit into
mainfrom
feature/test-utils-guardrails-26vxix3b5tqmz

Conversation

@zoomote

@zoomote zoomote Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

N/A: Phase 4 test-utils rollout guardrails.

Description

Adds lightweight guardrails so the Phase 3 test-utils migration cannot regress, per the initiative plan's Phase 4:

  • src/eslint.config.mjs: no-restricted-syntax error on vi.clearAllMocks() / vitest.clearAllMocks() scoped to the converted extension lanes (api/providers/__tests__, core/config/__tests__, services/code-index/**/__tests__, integrations/terminal/**/__tests__), pointing authors at src/test-utils/reset.
  • webview-ui/eslint.config.mjs: no-restricted-imports error on importing QueryClientProvider in component specs (src/components/**/__tests__/**/*.tsx), pointing authors at renderWithExtensionState. Scoped to .tsx component specs intentionally — .ts hook specs keep local renderHook wrappers because they pass a specific QueryClient instance to the hook.
  • PR template: new "Test Helpers (test changes only)" checklist item: shared helpers only for mechanical duplication; test intent stays visible.

Two stragglers found while verifying the guardrail are converted here so the rules land green:

  • CustomModesManager.spec.ts: 9 remaining direct vi.clearAllMocks() call sites missed by [Refactor] Reuse shared CustomModesManager test helpers #1190 (helper was already imported).
  • useSelectedModel.spec.ts / useZooGatewayRouterModelsSync.spec.ts: hand-rolled new QueryClient({ queries: { retry: false } }) replaced with the shared createTestQueryClient().

Both rules were probe-tested: a temporary offending file in each lane errors with the intended message.

This is a test-and-lint-config-only change with no intended runtime or user-facing behavior change.

Test Procedure

  • Probe files confirmed each rule errors correctly (removed after verification)
  • pnpm exec vitest run core/config/__tests__/CustomModesManager.spec.ts from src (48 tests passed)
  • pnpm exec vitest run src/components/ui/hooks/__tests__/useZooGatewayRouterModelsSync.spec.ts src/components/ui/hooks/__tests__/useSelectedModel.spec.ts from webview-ui (48 + 42 tests passed)
  • pnpm test (extension: 445 files, 7,355 tests; webview: 145 files, 1,643 tests)
  • pnpm lint
  • pnpm check-types
  • ESLint prune check on touched extension files passes with --max-warnings=0; src/eslint-suppressions.json unchanged.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Test Helpers (test changes only): Shared test helpers (src/test-utils/, @/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible.
  • Visual Snapshot (UI changes only): Not applicable; this is a test-only refactor with no rendered UI change.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Visual Snapshots

Not applicable; no product UI changed.

Videos (interaction / animation only)

Not applicable; no product interaction changed.

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required.

Additional Notes

No changesets were added. Author self-review found no behavior or scope regressions. The .tsx scoping of the webview rule is deliberate; hook specs that need a specific QueryClient instance keep local renderHook wrappers but now share createTestQueryClient().

Get in Touch

Mention @roomote on this PR for follow-up requests.

Co-authored-by: Roomote <roomote@roomote.dev>
@zoomote

zoomote Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Author self-review summary:

  • Scope: 6 files, 60 insertions / 18 deletions — two scoped ESLint rules, one PR-template checklist item, and three straggler conversions so the rules land green.
  • Both rules probe-tested: a temporary offending file per lane produced the intended error message, then was removed.
  • Extension rule is scoped to exactly the four converted lanes; the shared helper module itself sits outside the globs, and the base config has no conflicting no-restricted-syntax.
  • Webview rule is deliberately .tsx-only: .ts hook specs pass a specific QueryClient instance to renderHook, so they keep local wrappers but now share createTestQueryClient() (noted in a config comment).
  • Validation: 48 + 42 focused tests on touched specs; full pnpm test (extension 445 files / 7,355 tests; webview 145 files / 1,643 tests); pnpm lint; pnpm check-types; suppressions file content-identical to HEAD.
  • No production code, docs-site changes, or changesets. Visual proof not applicable.

Per initiative policy, not approving this Roomote-authored PR — leaving review to a human maintainer.

@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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