Skip to content

🤖 tests: isolate renderer test globals#3574

Merged
ThomasK33 merged 1 commit into
mainfrom
tests-ui-test-isolation
Jun 16, 2026
Merged

🤖 tests: isolate renderer test globals#3574
ThomasK33 merged 1 commit into
mainfrom
tests-ui-test-isolation

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

  • Stabilizes local renderer unit-test runs by keeping test-only module mocks and DOM globals scoped to the suites that need them.

Background

  • bun test src runs many renderer test files in one process locally, so file-scope mock.module() registrations and direct globalThis.window/document overwrites can leak into later suites.
  • The repro surfaced as useChatTranscriptFullWidth not calling its real API context after useModelsFromSettings, events.test seeing document as undefined, chatCommands inheriting a remote window.location, and ImmersiveReviewView rendering a stubbed diff renderer from ProposePlanToolCall.

Implementation

  • Moves useModelsFromSettings and ProposePlanToolCall module mocks behind setup/teardown helpers that restore the real module exports after each test.
  • Uses installDom() or explicit previous-global restoration so renderer tests leave the global DOM state as they found it.
  • Makes events.test install its own DOM per test instead of relying on a one-time side-effect import.

Validation

  • bun test src/browser/hooks/useModelsFromSettings.test.ts src/browser/hooks/useChatTranscriptFullWidth.test.tsx src/browser/utils/events.test.ts
  • bun test src/browser/hooks/useRouting.test.ts src/browser/utils/chatCommands.test.ts
  • bun test src/browser/features/Tools/ProposePlanToolCall.test.tsx src/browser/features/RightSidebar/CodeReview/ImmersiveReviewView.test.tsx
  • bun test src/browser/hooks src/browser/utils
  • make static-check

Risks

  • Low product risk: this is test-only isolation. The main risk is that moving mocks into hooks could reveal tests that were unintentionally depending on cross-file pollution; the targeted cross-suite commands cover the known leak chains.

Pains

  • make test now gets past the renderer failures but still exits on the pre-existing local Storybook budget guard (71 > 70 snapshot-enabled story files, 276 > 262 estimated snapshots), which is unrelated to this diff and not part of the CI unit shard.

Generated with mux • Model: openai:gpt-5.5 • Thinking: xhigh • Cost: $46.22

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: ccd7666ea3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33 ThomasK33 added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit ec3314e Jun 16, 2026
23 checks passed
@ThomasK33 ThomasK33 deleted the tests-ui-test-isolation branch June 16, 2026 10:36
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