Skip to content

refactor(test): fix scroll-to-top e2e test on Android#4017

Merged
LKuchno merged 6 commits into
mainfrom
@lkuchno/e2e-scroll-to-top-android-fix
May 13, 2026
Merged

refactor(test): fix scroll-to-top e2e test on Android#4017
LKuchno merged 6 commits into
mainfrom
@lkuchno/e2e-scroll-to-top-android-fix

Conversation

@LKuchno

@LKuchno LKuchno commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Description

The test-tabs-special-effects-scroll-to-top e2e 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 push item-1 off screen. This PR switches the scroll calls to use a waitFor(...).whileElement(...).scroll(...) pattern that scrolls until a specific far-off item (item-22) becomes visible, making the scroll deterministic on both platforms.

Additionally, SafeAreaView from react-native-screens/experimental is wrapped around the ScrollView in 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

  • E2E / Tabs scroll-to-top test: Replaced element.scroll(300, 'down') calls with a scrollDown(targetId, scrollViewId) helper that uses waitFor().whileElement().scroll(500, 'down') to scroll until item-22 is visible — guarantees sufficient scroll depth on Android
  • Test screen component: Wrapped ScrollView with SafeAreaView (from react-native-screens/experimental) and imported Platform to ensure content is correctly inset on Android, preventing system bars from occluding list items during the test

@LKuchno LKuchno added platform:android Issue related to Android part of the library area:tabs Issue related to bottom tabs type:e2e Actions related to e2e maintenance and development, especially automation. labels May 12, 2026
@LKuchno LKuchno changed the title refactor(test): Fix e2e test scroll to top for android fix(test): fix scroll-to-top e2e test on Android May 13, 2026
@LKuchno LKuchno changed the title fix(test): fix scroll-to-top e2e test on Android refactor(test): fix scroll-to-top e2e test on Android May 13, 2026
@LKuchno LKuchno requested review from Copilot and t0maboro May 13, 2026 08:15
</Text>
))}
</ScrollView>
<SafeAreaView edges={{ bottom: Platform.OS === 'android', top:Platform.OS === 'android' }}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

top:Platform.OS - missing whitespace, please format this file

}
}

async function scrollDown(targetId: string, scrollViewId: string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like a generic helper. we may consider extracting it to some utils file - outside of the scope of this PR

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 ScrollView in SafeAreaView (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);
}

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.

LKuchno and others added 3 commits May 13, 2026 10:33
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
@LKuchno LKuchno merged commit ac87ab2 into main May 13, 2026
7 checks passed
@LKuchno LKuchno deleted the @lkuchno/e2e-scroll-to-top-android-fix branch May 13, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tabs Issue related to bottom tabs platform:android Issue related to Android part of the library type:e2e Actions related to e2e maintenance and development, especially automation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants