feat(android): add dialog root fallback for React Native Modal support#4933
Open
yuki2006 wants to merge 1 commit intowix:masterfrom
Open
feat(android): add dialog root fallback for React Native Modal support#4933yuki2006 wants to merge 1 commit intowix:masterfrom
yuki2006 wants to merge 1 commit intowix:masterfrom
Conversation
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.
Summary
Adds automatic
inRoot(RootMatchers.isDialog())fallback on Android to support interactions with elements rendered inside React Native<Modal>.Fixes #4928
Problem
On Android, React Native's
<Modal>component renders its content in a separate dialog window root. Espresso's default view matching only searches the main window root, causingNoMatchingViewExceptionfor any element inside a Modal — even though the element is visible on screen.This makes it impossible to test flows involving Modal (e.g. pickers, confirmation dialogs, bottom sheets) without manual
inRootworkarounds, which Detox does not currently expose.Solution
When a view interaction fails with
NoMatchingViewException, automatically retry with.inRoot(RootMatchers.isDialog()). This is applied to:DetoxAssertion.java):assertMatcherandwaitForAssertMatcherSingleViewActionPerformer.kt,MultipleViewsActionPerformer.kt):performThe fallback only triggers on
NoMatchingViewException, so there is no impact on views found in the default root.Changes
DetoxAssertion.javaassertMatcher()andwaitForAssertMatcher()SingleViewActionPerformer.ktperformOn()MultipleViewsActionPerformer.ktperformOn()Test plan
<Modal visible={true}>containing tappable elements and assertionsNoMatchingViewException)