From 667ba76aefa3e52643683ae70aa6a8f74200d1d7 Mon Sep 17 00:00:00 2001 From: HyunWoo Lee Date: Thu, 31 Oct 2024 04:33:13 -0700 Subject: [PATCH] Click basic button & scroll down until item 600 is visible (#46804) Summary: This pr is part of issue https://github.com/facebook/react-native/issues/46757 solving a task - [ME2E0008] [ME2E0009] - Set up a test - Starts the app - Scrolls until flatlist is visilbe and clicks on flatlist - Click basic button - Scroll down until item 600 is visible ## Changelog: [Internal] [Added] - Add e2e-test logic that click button & scroll down until specific item is visible Pull Request resolved: https://github.com/facebook/react-native/pull/46804 Test Plan: ### Test Locally - iOS ```bash yarn install cd packages/rn-tester yarn e2e-build-ios ``` - Android ```bash yarn install cd packages/rn-tester yarn e2e-build-android ``` ### Start Maestro - iOS ```bash cd packages/rn-tester yarn e2e-test-ios ``` - Android ``` cd packages/rn-tester yarn e2e-test-android ``` ### Test in CI To test in CI, just add a comment on your PR with the text: ``` /test-e2e ``` Reviewed By: cortinico Differential Revision: D63829274 Pulled By: cipolleschi fbshipit-source-id: f7b4342ed353a48123f87dcfd8d503009f65637c --- packages/rn-tester/.maestro/flatlist.yml | 27 +++++++++++++++++++ .../js/components/ListExampleShared.js | 2 ++ .../js/examples/FlatList/FlatList-basic.js | 1 + 3 files changed, 30 insertions(+) create mode 100644 packages/rn-tester/.maestro/flatlist.yml diff --git a/packages/rn-tester/.maestro/flatlist.yml b/packages/rn-tester/.maestro/flatlist.yml new file mode 100644 index 00000000000..a358e615e02 --- /dev/null +++ b/packages/rn-tester/.maestro/flatlist.yml @@ -0,0 +1,27 @@ +appId: ${APP_ID} # iOS: com.meta.RNTester.localDevelopment | Android: com.facebook.react.uiapp +--- +- launchApp +- assertVisible: "Components" +- scrollUntilVisible: + element: + id: "Flatlist" + direction: DOWN + speed: 40 +- tapOn: + id: "Flatlist" +- tapOn: + id: "Basic" +- assertVisible: + id: "item_550" +- repeat: + while: + notVisible: + id: "item_600" # should trigger a reload + commands: + - swipe: + start: 50%, 85% + end: 50%, 50% + - waitForAnimationToEnd: # wait for the reload to happen + timeout: 1000 +- assertVisible: + id: "item_600" diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 05fda82f9cd..804b04ba3f6 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -71,6 +71,7 @@ class ItemComponent extends React.PureComponent<{ onShowUnderlay?: () => void, onHideUnderlay?: () => void, textSelectable?: ?boolean, + testID?: ?string, ... }> { _onPress = () => { @@ -94,6 +95,7 @@ class ItemComponent extends React.PureComponent<{ ]}> {!item.noImage && } diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index c0750b93837..229425f274f 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -363,6 +363,7 @@ class FlatListExample extends React.PureComponent { const renderProp = ({item, separators}: RenderItemProps) => { return (