Skip to content

[Refactor] Add shared test utilities and pilot refactors - #1171

Merged
edelauna merged 3 commits into
mainfrom
refactor/test-utils-foundations-pilots-0l3imnen4dykb
Aug 6, 2026
Merged

[Refactor] Add shared test utilities and pilot refactors#1171
edelauna merged 3 commits into
mainfrom
refactor/test-utils-foundations-pilots-0l3imnen4dykb

Conversation

@zoomote

@zoomote zoomote Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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

What changed

  • Added typed shared test utilities for API handler options, filesystem mocks, reset operations, and fresh VS Code test doubles.
  • Extended webview test utilities with reusable extension-state setup, context-aware rendering, and typed vscode.postMessage cleanup.
  • Applied the utilities to the openai-native, DiffViewProvider, and ChatView pilot specs while keeping scenario-specific mocks and assertions local.
  • Reused the shared API-options setup in the OpenAI provider and usage-tracking specs as the first provider rollout batch.
  • Added focused helper tests and repository guidance for choosing shared helpers without hiding test intent, including direct VS Code/reset coverage.
  • Initialized shadowed webview context fields from initialState so test renders reflect supplied state consistently.

Why this change was made

This continues the incremental test-utils refactor plan after the provider stream-helper rollout. It reduces mechanical setup duplication and gives future agent-authored tests consistent, typed entry points without pursuing broad test rewrites.

Impact

Test-only refactor. Production behavior is unchanged; the extension and webview test suites retain their existing coverage while becoming easier to set up and maintain.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.47059% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/test-utils/vscode.ts 95.55% 0 Missing and 2 partials ⚠️
webview-ui/src/utils/test-utils.tsx 85.71% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@zoomote

zoomote Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

0 issues outstanding.

  • webview-ui/src/context/ExtensionStateContext.tsx:279: initialState now seeds the shadowed context fields, including follow-up settings, include flags, router models, and marketplace data.
  • src/test-utils/vscode.ts:4: Added focused tests for the exported VS Code factories and event behavior, plus reset-helper coverage in src/test-utils/__tests__/reset.spec.ts.

Reviewed 359d91b

@zoomote

zoomote Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Fixed and pushed at 359d91b.

  • Added direct coverage for the exported VS Code factories, event emitter, workspace configuration, extension context, and reset helpers. The initial Codecov result was low because these new shared helper lines were only exercised indirectly; the focused helper coverage now reports 97.95% line coverage for the test-utils surface.
  • Initialized the ExtensionStateContextProvider shadowed fields from initialState, so renderWithExtensionState reflects supplied follow-up, include-flag, router-model, and marketplace state.

Full tests, type checks, and lint pass. The draft PR metadata is refreshed; Codecov will rerun against the pushed commit.

@edelauna
edelauna marked this pull request as ready for review August 6, 2026 03:07
@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 6, 2026
@edelauna
edelauna added this pull request to the merge queue Aug 6, 2026
Merged via the queue into main with commit f149073 Aug 6, 2026
26 checks passed
@edelauna
edelauna deleted the refactor/test-utils-foundations-pilots-0l3imnen4dykb branch August 6, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR changes are ready and waiting for maintainer re-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants