Skip to content
Source
Sign inSign up
pingdotgg/t3code

test(web): every React test runs in a real browser #20944

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/20944/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

The last three apps/web suites still ran in jsdom. The GitActionsControl suites used react-test-renderer with every UI primitive stubbed as a string, and called onClick props directly. That meant they never exercised the real menu, dialogs, or disabled states. This PR converts those three suites and then removes jsdom from apps/web.

Per file

  • GitActionsControl.test.ts + GitActionsControl.lifecycle.test.ts → GitActionsControl.browser.test.tsx. The two files shared every mock, so they are merged into one real-DOM suite of 14 cases. The suite opens the options menu, clicks Commit, and drives the real commit dialog and default-branch prompt through userEvent. Every vi.mock is built from the real module. The suite mocks useQuietThreadShell (per #20860) and uses the real composer draft store.
    • Kept: no feature branch on a server thread without the task grant; commit and sync before thread details load; archived-thread detail sync after the shell disappears; task grant required for an archived thread; the shell branch wins over stale cached detail; a fresh grant read after Git finishes (revoking each scope); ordinary commits while details load; feature-branch commits for a local draft; a retained PR toast runs in the thread that produced it; the memoized button follows navigation.
    • The old "retained callback after the grant is gained" case only made sense with captured handler props. It is replaced by checks that revoke the grant while the dialog or prompt is open. These assert that readEnvironmentScope stops the action at click time.
    • New: the default-branch prompt's "Check out feature branch & continue" path, plus revocation while that prompt is open.
    • I confirmed coverage by removing both action-time readEnvironmentScope guards: 3 cases fail.
  • BranchToolbar.panel.test.tsx → BranchToolbar.panel.browser.test.tsx. Same 4 cases. The machine menu is now opened with userEvent and queried by role, and the root is shared and unmounted inside act.

Dependencies

  • Removed jsdom, react-test-renderer, and @types/react-test-renderer from apps/web/package.json, and updated the lockfile.
  • Removed the jsdom ignore for apps/web from knip.jsonc.
  • apps/mobile still depends on jsdom, so the pnpm override for jsdom's optional peer stays.
  • vite.config.ts had no jsdom environment or setup file left, so it is unchanged.
  • git grep finds no @vitest-environment jsdom, react-test-renderer, or jsdom in apps/web.

Docs

  • docs/operations/development.md: the Checks section now says that apps/web tests which render React or touch the DOM are *.browser.test.{ts,tsx} and run in headless Chromium, and that there is no jsdom.
  • docs/internals/performance-regressions.md: fixed the renamed ThreadStatusIndicators.subscriptions.browser.test.tsx reference.
  • Reworded three test comments that still referred to jsdom.

Checks

  • Converted files plus the touched browser tests pass in the browser project (61 tests).
  • surface.test.ts passes in the unit project.
  • vp run knip:check, scoped lint, and the apps/web typecheck pass.

Model: Claude Opus 5.5, Claude Code.

🤖 Generated with Claude Code

    1. juliusmarminge added labelsmacroscope-review

    2. Approvability

      Verdict: Approved at c0f530e

      Macroscope's review found this PR approvable — This PR replaces web-only test environments with real Chromium coverage and removes obsolete test dependencies. Its changes are limited to tests, development metadata, documentation, and comments, with no customer-facing runtime behavior or product defaults changed.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB4.9 KiB−23 B (−0.5%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB−23 B (−1.9%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.8 KiB−41 B (−0.2%)29.3 KiB✅
      CodexLive turn messages21−1 (−50.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 4b1024d · PR result: c0f530e · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 4f49a4b5-dae7-4064-bf8d-1ee98816e7eb
      📥 Commits

      Reviewing files that changed from the base of the PR and between 4b1024dafe4766ea7c59546936c21ce0fab8acb3 and c0f530ebebda93cc063b2cd017106a804b325946.

      ⛔ Files ignored due to path filters: 1
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      📒 Files selected for processing: 12
      • apps/web/package.json
      • apps/web/src/components/BranchToolbar.panel.browser.test.tsx
      • apps/web/src/components/BranchToolbar.panel.test.tsx
      • apps/web/src/components/GitActionsControl.browser.test.tsx
      • apps/web/src/components/GitActionsControl.lifecycle.test.ts
      • apps/web/src/components/GitActionsControl.test.ts
      • apps/web/src/components/chat/WorkLog.browser.test.tsx
      • apps/web/src/composer-list-split.browser.test.ts
      • apps/web/src/terminal/ghostty/surface.test.ts
      • docs/internals/performance-regressions.md
      • docs/operations/development.md
      • knip.jsonc
      💤 Files with no reviewable changes: 5
      • apps/web/package.json
      • apps/web/src/components/GitActionsControl.test.ts
      • apps/web/src/components/GitActionsControl.lifecycle.test.ts
      • apps/web/src/components/BranchToolbar.panel.test.tsx
      • knip.jsonc

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

      📝 Walkthrough

      The pull request moves BranchToolbar and GitActionsControl coverage into browser tests. It removes jsdom and React test-renderer development dependencies, updates test-environment guidance, and revises related comments and a performance-coverage reference.

      Changes: Browser test migration

      Layer / File(s)Summary
      Test environment guidance and cleanup
      docs/operations/development.md, apps/web/package.json, knip.jsonc, apps/web/src/components/chat/WorkLog.browser.test.tsx, apps/web/src/composer-list-split.browser.test.ts, apps/web/src/terminal/ghostty/surface.test.ts, docs/internals/performance-regressions.md
      The development guide describes browser and Node test conventions. The package and Knip configuration remove jsdom and React test-renderer dependencies. Related test comments and the performance-coverage reference are updated.
      BranchToolbar browser coverage
      apps/web/src/components/BranchToolbar.panel.browser.test.tsx, apps/web/src/components/BranchToolbar.panel.test.tsx
      Browser tests cover locked-workspace controls, remote environment selection, Ctrl-click behavior, and context-menu path copying. The prior panel test file is deleted.
      GitActionsControl browser coverage
      apps/web/src/components/GitActionsControl.browser.test.tsx, apps/web/src/components/GitActionsControl.lifecycle.test.ts, apps/web/src/components/GitActionsControl.test.ts
      Browser tests cover permission-gated feature-branch actions, thread metadata updates, default-branch prompts, ordinary commits, local drafts, and action targets across navigation. The prior test files are deleted.

      Priority: ⬇️ Low

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Other

      Suggested reviewers: maria-rcks, bil0000, tris203

      Merge Risk: ⚪ Minimal · up to c0f53

      The browser-test migration has no identified issue requiring a fix before merge.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely summarizes the main change: converting all React tests in apps/web to run in a real browser.
      Description checkPassedThe description clearly covers the problem, implementation, affected dependencies, documentation updates, and focused verification results. It is detailed and directly aligned with the pull request ob…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description clearly covers the problem, implementation, affected dependencies, documentation updates, and focused verification results. It is detailed and directly aligned with the pull request objectives, although it does not include a separate Scope and approval section or an issue link.

      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    5. juliusmarminge merged thisd5b7095

    6. juliusmarminge closed this

Sign in to join this conversation.