diff --git a/.maestro/tests/room/search.yaml b/.maestro/tests/room/search.yaml new file mode 100644 index 00000000000..07b94cc03d3 --- /dev/null +++ b/.maestro/tests/room/search.yaml @@ -0,0 +1,41 @@ +appId: chat.rocket.reactnative +name: Search +onFlowStart: + - runFlow: '../../helpers/setup.yaml' +tags: + - test-13 + - android-only + +--- +- evalScript: ${output.user = output.utils.createUser()} + +- runFlow: + file: '../../helpers/login-with-deeplink.yaml' + env: + USERNAME: ${output.user.username} + PASSWORD: ${output.user.password} + +- extendedWaitUntil: + visible: + id: 'rooms-list-view-search' + timeout: 60000 +- tapOn: + id: rooms-list-view-search +- extendedWaitUntil: + visible: + id: 'rooms-list-view' + timeout: 60000 +- extendedWaitUntil: + visible: + id: 'rooms-list-view-search-input' + timeout: 60000 +- pressKey: Back +- pressKey: Back +- extendedWaitUntil: + visible: + id: 'rooms-list-view' + timeout: 60000 +- extendedWaitUntil: + notVisible: + id: 'rooms-list-view-search-input' + timeout: 60000 diff --git a/app/views/RoomsListView/index.tsx b/app/views/RoomsListView/index.tsx index 773758c9b85..0ec091befb3 100644 --- a/app/views/RoomsListView/index.tsx +++ b/app/views/RoomsListView/index.tsx @@ -1,6 +1,6 @@ import { useNavigation } from '@react-navigation/native'; -import React, { memo, useContext } from 'react'; -import { FlatList, RefreshControl } from 'react-native'; +import React, { memo, useContext, useEffect } from 'react'; +import { BackHandler, FlatList, RefreshControl } from 'react-native'; import { useSafeAreaFrame } from 'react-native-safe-area-context'; import { shallowEqual } from 'react-redux'; @@ -51,6 +51,18 @@ const RoomsListView = memo(function RoomsListView() { const { refreshing, onRefresh } = useRefresh({ searching }); const supportedVersionsStatus = useAppSelector(state => state.supportedVersions.status); + useEffect(() => { + const subscription = BackHandler.addEventListener('hardwareBackPress', () => { + if (searchEnabled) { + stopSearch(); + navigation.goBack(); + return true; + } + return false; + }); + return () => subscription.remove(); + }, [searchEnabled]); + const onPressItem = (item = {} as IRoomItem) => { if (!navigation.isFocused()) { return;