Adds recognizer-backed Jest gesture simulation for v3 gestures and relations.#4312
Closed
coado wants to merge 3 commits into
Closed
Adds recognizer-backed Jest gesture simulation for v3 gestures and relations.#4312coado wants to merge 3 commits into
coado wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a recognizer-backed Jest gesture simulation API for v3 gestures on web by feeding deterministic pointer input into the existing web recognizers and routing competing/simultaneous state transitions through a newly extracted GestureArbitrator (so tests can validate real recognition outcomes + relations without manually crafting RNGH state events).
Changes:
- Extract shared relation/state arbitration logic into
GestureArbitrator, leaving web-specific pointer-overlap conflict detection inGestureHandlerOrchestrator. - Add new Jest utilities:
fireGesture, pointer-gesture builders (tap,swipe,pinch,rotate, etc.), and acreateGestureControllerstate-machine driver. - Refactor web handlers to allow injecting an orchestrator + interaction manager for isolated (non-singleton) Jest sessions; add new tests for the helpers.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/web/tools/InteractionManager.ts | Makes interaction relations configurable per isolated session (no longer constructor-locked to singleton). |
| packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts | Becomes a web adapter delegating shared arbitration to GestureArbitrator. |
| packages/react-native-gesture-handler/src/web/tools/GestureArbitrator.ts | New shared arbitration engine for handler state observability across relations. |
| packages/react-native-gesture-handler/src/web/handlers/IGestureHandler.ts | Adds injection hooks for orchestrator + interaction manager to support isolated sessions. |
| packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts | Stores injected orchestrator/interaction manager and uses them instead of global singletons. |
| packages/react-native-gesture-handler/src/jestUtils/jestUtils.ts | Adds createGestureController, fireGesture, and pointer gesture primitives/helpers. |
| packages/react-native-gesture-handler/src/jestUtils/index.ts | Re-exports the new Jest helper APIs and types. |
| packages/react-native-gesture-handler/src/tests/gestureController.test.tsx | Adds Jest coverage for controller lifecycle and recognizer-backed pointer simulations + relations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1169
to
+1174
| invariant( | ||
| pointerGesture.steps.length > 0, | ||
| 'fireGesture requires pointer input. Use tap(), swipe(), or pointerSequence().' | ||
| ); | ||
|
|
||
| let time = 0; |
Comment on lines
+1203
to
+1211
| if (step.type === 'wait') { | ||
| invariant( | ||
| advanceTimers !== undefined, | ||
| 'fireGesture needs advanceTimers to process waits. Pass jest.advanceTimersByTime as the third argument.' | ||
| ); | ||
| advanceTimers(step.duration); | ||
| time += step.duration; | ||
| return; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
fireGesturefeeds deterministic pointer input into web gesture recognizers, then routes their state requests throughGestureArbitrator. This lets tests cover real recognition outcomes and composed relations without manually supplying RNGH states.or with other helpers:
The API includes low-level composable primitives (
pointerSequence,multiPointerSequence) and convenience helpers (tap,doubleTap,longPress,swipe,pinch,rotate). Also extracts the shared relation/state policy intoGestureArbitrator, leaving web-specific pointer-overlap behavior inGestureHandlerOrchestrator.Test plan
Added new tests.