refactor(test): fix scroll-to-top e2e test on Android#4017
Merged
Conversation
t0maboro
reviewed
May 13, 2026
| </Text> | ||
| ))} | ||
| </ScrollView> | ||
| <SafeAreaView edges={{ bottom: Platform.OS === 'android', top:Platform.OS === 'android' }}> |
Contributor
There was a problem hiding this comment.
top:Platform.OS - missing whitespace, please format this file
| } | ||
| } | ||
|
|
||
| async function scrollDown(targetId: string, scrollViewId: string) { |
Contributor
There was a problem hiding this comment.
looks like a generic helper. we may consider extracting it to some utils file - outside of the scope of this PR
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Android reliability for the “tabs scroll-to-top” Detox E2E test by making scrolling deterministic and ensuring list content isn’t occluded by system bars during assertions.
Changes:
- Updated the E2E test to scroll until a far item becomes visible (instead of using a fixed scroll distance).
- Wrapped the test screen’s
ScrollViewinSafeAreaView(experimental) and added Android-specific safe-area edges.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| FabricExample/e2e/single-feature-tests/tabs/test-tabs-special-effects-scroll-to-top.e2e.ts | Switches to a deterministic “scroll until target visible” pattern for Android stability. |
| apps/src/tests/single-feature-tests/tabs/test-tabs-special-effects-scroll-to-top/index.tsx | Adds SafeAreaView wrapper to prevent top/bottom occlusion during visibility assertions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+19
to
+24
| async function scrollDown(targetId: string, scrollViewId: string) { | ||
| await waitFor(element(by.id(targetId))) | ||
| .toBeVisible() | ||
| .whileElement(by.id(scrollViewId)) | ||
| .scroll(500, 'down', NaN, 0.85); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…oftware-mansion/react-native-screens into @lkuchno/e2e-scroll-to-top-android-fix
t0maboro
approved these changes
May 13, 2026
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
test-tabs-special-effects-scroll-to-tope2e test was failing on Android because the previous approach used a fixed-distance scroll on the ScrollView element directly, which is unreliable — Android does not guarantee the same scroll offset per unit distance as iOS, so the list might not scroll far enough to pushitem-1off screen. This PR switches the scroll calls to use awaitFor(...).whileElement(...).scroll(...)pattern that scrolls until a specific far-off item (item-22) becomes visible, making the scroll deterministic on both platforms.Additionally,
SafeAreaViewfromreact-native-screens/experimentalis wrapped around theScrollViewin the test screen component. This ensures the content is properly inset on Android (where system bars can otherwise occlude list items) and prevents the first item from being partially hidden behind navigation bars, which was causing false-positive visibility assertions.Affected platform: Android (test reliability fix; iOS behavior unchanged).
Changes
element.scroll(300, 'down')calls with ascrollDown(targetId, scrollViewId)helper that useswaitFor().whileElement().scroll(500, 'down')to scroll untilitem-22is visible — guarantees sufficient scroll depth on AndroidScrollViewwithSafeAreaView(fromreact-native-screens/experimental) and importedPlatformto ensure content is correctly inset on Android, preventing system bars from occluding list items during the test