Skip to content

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

Closed
ghost wants to merge 1 commit into
mainfrom
feature/test-utils-guardrails-26vxix3b5tqmz
Closed

ghost wants to merge 1 commit into
mainfrom
feature/test-utils-guardrails-26vxix3b5tqmz

Conversation

@ghost

@ghost ghost commented Aug 9, 2026

Copy link
Copy Markdown

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>
@ghost

ghost commented Aug 9, 2026

Copy link
Copy Markdown
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!

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Resolve the merge conflicts. The review sequence resumes after the branch is mergeable.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@github-actions github-actions Bot added has-conflicts PR has merge conflicts with the base branch and removed has-conflicts PR has merge conflicts with the base branch labels Sep 5, 2026
@github-actions github-actions Bot added has-conflicts PR has merge conflicts with the base branch and removed has-conflicts PR has merge conflicts with the base branch labels Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been awaiting author changes for 14 days and will be automatically closed in 7 days. Please address the review comments or leave a comment if you need more time.

@github-actions

Copy link
Copy Markdown
Contributor

Closing due to author inactivity after requested changes. Feel free to reopen once the requested changes have been addressed.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Closing due to author inactivity after requested changes. Feel free to reopen once the requested changes have been addressed.

@zoomote2

zoomote2 Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

This work continues in #2279 on the same branch (feature/test-utils-guardrails-26vxix3b5tqmz). The branch was rebased onto latest main and the straggler conversions were refreshed; GitHub does not allow reopening a closed PR after its branch was force-pushed, so the rebased branch could not be reopened here. #2279 carries the final diff, updated description, and validation results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author PR is waiting for the author to address requested changes has-conflicts PR has merge conflicts with the base branch stale-awaiting-author PR is stale while waiting for requested author changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant