Skip to content

test: restore real ColorPicker and CustomSelect exports after wizard step tests (TA-001 round 2) - #2340

Merged
jatmn merged 1 commit into
mainfrom
test/ta001r2-monitorpermission-leak
Oct 22, 2026
Merged

jatmn merged 1 commit into
mainfrom
test/ta001r2-monitorpermission-leak

Conversation

@jatmn

@jatmn jatmn commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • TA-001 round 2, MonitorPermissionRequest slice. One test file changed: src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx.
  • Root cause: the wizard-step tests use mock.module to replace ../../ColorPicker.js and ../../../CustomSelect/select.js with lightweight stubs. mock.restore() in afterEach does not undo mock.module registrations, so both stubs stayed registered for the rest of the process. Later files that render the real CustomSelect got the stub instead. In bun test --randomize --seed=2027 without --isolate, this caused all 5 interactive MonitorPermissionRequest tests to fail with "Timed out waiting for Monitor permission test condition". It also caused failures in ExportDialog, sessions, AgentRouteSelector and a few other files that ran later.
  • Found by bisecting the 739 files that ran before MonitorPermissionRequest in the seed-2027 order. The failure reproduces with just this pair: the wizard-step tests first, then MonitorPermissionRequest.
  • Fix: before any mock is registered, copy the real exports of both modules from cache-busted imports (?real=<nonce>), then re-register those copies in afterAll. This is the same pattern earlier TA-001 slices used. Test bodies, assertions and the per-test cleanup are unchanged.

Impact

  • user-facing impact: none (test-only).
  • developer/maintainer impact: removes another source of order-dependent failures in no---isolate runs. --isolate stays in CI.

Testing

  • I ran the required local preflight. I reviewed CONTRIBUTING.md and AGENTS.md.
  • exact commands and results (Bun 1.3.13, temp config dirs):
    • bun install --frozen-lockfile: pass.
    • bun run typecheck: pass.
    • bun run typecheck:type-tests: pass.
    • node bin/openclaude --version and NODE_DISABLE_COMPILE_CACHE=1 node bin/openclaude --version: pass.
    • bun run security:pr-scan -- --base FETCH_HEAD --head HEAD: pass.
    • bun run check: pass. An earlier run failed one timing-sensitive loadSkillsDir.test.ts watcher test (".agents linked target edits refresh invoked content and obey source lifetime", notification count 4 vs 3). That file is not touched here and does not use these mocks. It passed 3 times in a row on its own with --isolate, and the full bun run check rerun passed.
  • focused tests:
    • bun test ./src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx ./src/components/permissions/MonitorPermissionRequest/MonitorPermissionRequest.test.tsx: 9 pass, 0 fail (before the fix: 5 MonitorPermissionRequest failures).
    • bun test ./src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx: 3 pass.
  • no---isolate runs:
    • 8 native shards (bun test --shard=K/8): 1066/0, 1530/0, 1373/1, 1492/0, 1070/4, 1459/0, 1287/1, 1182/1 (pass/fail). No new failures compared with current main. Shard 8 went from 6 failures to 1.
    • --randomize --seed=2027: 10399 pass, 55 fail. Before the fix: 10366 pass, 88 fail. There are no new failures. 33 tests that failed before now pass: MonitorPermissionRequest 5, ExportDialog 13, sessions 7, AgentRouteSelector 3, ConsoleOAuthFlow 2, and search, AgentDetailDialog and exaFree 1 each.
    • --randomize --seed=101 and --seed=6001: both runs hang in an unrelated loadSkillsDir.test.ts lock wait and hit the runner timeout, as they do on main. Before that point, all 6 MonitorPermissionRequest tests passed in both runs.
  • documented skipped checks, platform limitations, or verified pre-existing failures: the remaining shard and seed failures, and the seed 101/6001 hang, already happen on main. They belong to other TA-001 round 2 slices.

Notes

  • provider/model path tested: n/a (test-only; agent wizard and permission dialog UI tests).
  • screenshots attached (if UI changed): n/a
  • follow-up work or known limitations: the remaining order-dependent failures are tracked as separate TA-001 round 2 slices.

Summary by CodeRabbit

  • Tests
    • Improved test isolation by restoring mocked modules after the test suite, reducing the chance of mock state affecting other tests.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 90b34cb and d092bb9.

📒 Files selected for processing: 1
  • src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx

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

📜 Recent review details
⏰ Context from checks skipped due to timeout: 18
  • GitHub Check: unit-tests (5)
  • GitHub Check: unit-tests (7)
  • GitHub Check: typecheck
  • GitHub Check: unit-tests (4)
  • GitHub Check: launcher-compatibility (22)
  • GitHub Check: unit-tests (1)
  • GitHub Check: unit-tests (2)
  • GitHub Check: unit-tests (3)
  • GitHub Check: smoke-and-tests
  • GitHub Check: unit-tests (8)
  • GitHub Check: dedicated-tests
  • GitHub Check: unit-tests (6)
  • GitHub Check: launcher-node-floor
  • GitHub Check: launcher-compatibility (24.11.x)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: CodeQL (actions)
  • GitHub Check: pr-intent-scan
  • GitHub Check: CodeQL (javascript-typescript)
🧰 Additional context used
📚 Code guidelines: 1
AGENTS.md — configured
📓 Path-based instructions: 4
Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions.

⚙️ CodeRabbit configuration file

Files:

  • src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx
Apply the OpenClaude maintainer review rubric from AGENTS.md.

⚙️ CodeRabbit configuration file

Files:

  • src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx
Source excerpt: Keep changes focused on one problem.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx
Source excerpt: No hidden policy change: Verify that product, trust-model, routing-default, telemetry/network, and permission-policy changes are not hidden inside unrelated cleanup.

📄 CodeRabbit inference engine (Custom checks)

Files:

  • src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx
🔇 Additional comments: 2
src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx: 2

11-18: LGTM!

172-176: LGTM!

📝 Walkthrough

The wizard steps test captures real ColorPicker and Select exports before installing mocks, then re-registers those exports after the suite.

Changes: Wizard test mock cleanup

Layer / File(s) Summary
Capture and restore component exports
src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx
The test captures the real ColorPicker and Select exports before installing mocks. An afterAll hook re-registers them because mock.restore() does not remove Bun module mock registrations.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Other

Suggested reviewers: chioarub

Merge Risk: ⚪ Minimal · up to d092b

The PR addresses test isolation without established production impact.

Pre-merge checks: Passed 7
Check name Status Explanation
Title check Passed The title clearly describes the test-only change, identifies the restored ColorPicker and CustomSelect exports, and includes the relevant TA-001 scope.
Description check Passed The description follows the repository template and documents the change, root cause, impact, testing commands and results, pre-existing failures, and known limitations.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Risk Surface Disclosed Passed PASS: The PR changes only wizardSteps.test.tsx. The diff restores real ColorPicker and Select test exports after mock.module use. It does not change permissions, auth, provider routing, networ…
No Hidden Policy Change Passed PASS — The PR changes only wizardSteps.test.tsx (+16/-1). The changes add cached real test-module exports and restore them in afterAll, while retaining the existing test doubles. No product code, …
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

Full details: Risk Surface Disclosed

Explanation

PASS: The PR changes only wizardSteps.test.tsx. The diff restores real ColorPicker and Select test exports after mock.module use. It does not change permissions, auth, provider routing, network behavior, background execution, startup/config-home behavior, skills/plugins/MCP, CI permissions, or release scripts. The MonitorPermissionRequest reference is only downstream test context, not a changed permission implementation, so no risk-surface disclosure or blocker is required.

Full details: No Hidden Policy Change

Explanation

PASS — The PR changes only wizardSteps.test.tsx (+16/-1). The changes add cached real test-module exports and restore them in afterAll, while retaining the existing test doubles. No product code, routing defaults, telemetry/network behavior, trust model, or permission policy changes are present. No maintainer policy alignment is required.

✨ 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.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

— jatmn's PR Review agent

This is a surgical TA-001 round 2 test-isolation slice. I do not see any code defects in the reviewed diff on head d092bb96.

Merge readiness

Rebase onto current main before merge. Live target main is one commit ahead of this branch (90b34cbd — merged TA-001 settings/sleep/fast-mode/loadSkillsDir slice #2339). Merge-base decision for this review was live-base-three-dot at a63ad4a9..d092bb96 (single commit, one file). GitHub reports mergeable: true and mergeable_state: blocked while required checks finish.

CI on head d092bb96: typecheck, all eight unit-tests shards, dedicated-tests, launcher compatibility/floor jobs, pr-intent-scan, changes, and all CodeQL jobs (CodeQL, CodeQL (actions), CodeQL (javascript-typescript), Analyze (javascript-typescript)) completed success. web skipped. smoke-and-tests was still in_progress at review capture time — confirm green before merge. Commit combined status had shown CodeRabbit context pending even though the PR already has an empty APPROVED CodeRabbit review.

Scope: Stands alone — one commit, one test file, no dependency on other open PRs. No product or docs surface changes; appropriate for the stated MonitorPermissionRequest / randomize bisect.

Code review: The ?real= export snapshots plus afterAll mock.module re-registration match the established TA-001 pattern and fix the merge-base cross-file stub leak I reproduced locally (wizard steps then MonitorPermissionRequest without --isolate).

@jatmn
jatmn marked this pull request as ready for review October 22, 2026 19:47
@jatmn jatmn self-assigned this Oct 22, 2026
@jatmn
jatmn merged commit 56da2c4 into main Oct 22, 2026
22 checks passed
@jatmn
jatmn deleted the test/ta001r2-monitorpermission-leak branch October 22, 2026 19:55
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