test(web): every React test runs in a real browser #20944
main fromrefs/pull/20944/head·merged by juliusmarminge View on GitHubThe 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 throughuserEvent. Every vi.mock is built from the real module. The suite mocksuseQuietThreadShell(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
readEnvironmentScopestops 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
readEnvironmentScopeguards: 3 cases fail.
BranchToolbar.panel.test.tsx→BranchToolbar.panel.browser.test.tsx. Same 4 cases. The machine menu is now opened withuserEventand queried by role, and the root is shared and unmounted insideact.
Dependencies#
- Removed
jsdom,react-test-renderer, and@types/react-test-rendererfromapps/web/package.json, and updated the lockfile. - Removed the
jsdomignore for apps/web fromknip.jsonc. apps/mobilestill depends on jsdom, so the pnpm override for jsdom's optional peer stays.vite.config.tshad no jsdom environment or setup file left, so it is unchanged.git grepfinds no@vitest-environment jsdom,react-test-renderer, orjsdomin 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 renamedThreadStatusIndicators.subscriptions.browser.test.tsxreference.- 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.tspasses 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
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
c0f530eMacroscope'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).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 4.9 KiB −23 B (−0.5%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB −23 B (−1.9%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.8 KiB −41 B (−0.2%) 29.3 KiB ✅ Codex Live turn messages 2 1 −1 (−50.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
4b1024d· PR result:c0f530e· Source CI: successScenario 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.
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.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing: 12
-
apps/web/package.jsonapps/web/src/components/BranchToolbar.panel.browser.test.tsxapps/web/src/components/BranchToolbar.panel.test.tsxapps/web/src/components/GitActionsControl.browser.test.tsxapps/web/src/components/GitActionsControl.lifecycle.test.tsapps/web/src/components/GitActionsControl.test.tsapps/web/src/components/chat/WorkLog.browser.test.tsxapps/web/src/composer-list-split.browser.test.tsapps/web/src/terminal/ghostty/surface.test.tsdocs/internals/performance-regressions.mddocs/operations/development.mdknip.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.mdThe 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.tsxBrowser 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.tsBrowser 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:
4-
Check name Status Explanation Title check The title clearly and concisely summarizes the main change: converting all React tests in apps/web to run in a real browser. Description check 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 ob… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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
-
juliusmarminge merged thisd5b7095
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes