fix(test): replace raw DOM .click() with userEvent in ComponentMode tests - #3817
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe ComponentMode tests replace raw DOM ChangesComponentMode interaction test stabilization
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized test-only change replaces raw clicks with awaited user interactions to reduce flaky ComponentMode tests; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
53f3b31 to
35420fb
Compare
|



Summary
Replace all raw
element.click()calls (wrapped inawait act()) with@testing-library/user-event'sawait user.click()inComponentMode.test.tsx.Root Cause
PatternFly's
ToggleGroupItemdoes not use a nativeonClickhandler — it uses anonChangecallback triggered through an internal event chain. Whenelement.click()is used directly, JSDOM's event propagation is not deterministic enough; depending on Vitest worker timing, the internal PF event chain may not have completed by the timeact()resolves. This causes the spy to record 0 calls intermittently.Fix
userEvent.click()simulates the full browser event sequence (pointerdown→mousedown→pointerup→mouseup→click) and internally awaits all pending React state updates, making the tests deterministic.Additionally removed two unnecessary
await act(async () => { await Promise.resolve(); })flush workarounds that are no longer needed withuserEvent.Fixes #3816
Summary by CodeRabbit