diff --git a/src/components/Pressable/GenericPressable/BaseGenericPressable.tsx b/src/components/Pressable/GenericPressable/implementation/BaseGenericPressable.tsx similarity index 97% rename from src/components/Pressable/GenericPressable/BaseGenericPressable.tsx rename to src/components/Pressable/GenericPressable/implementation/BaseGenericPressable.tsx index 5237ff486631..84a595a7bf05 100644 --- a/src/components/Pressable/GenericPressable/BaseGenericPressable.tsx +++ b/src/components/Pressable/GenericPressable/implementation/BaseGenericPressable.tsx @@ -3,6 +3,8 @@ import React, {forwardRef, useCallback, useEffect, useMemo, useState} from 'reac import type {GestureResponderEvent, View} from 'react-native'; // eslint-disable-next-line no-restricted-imports import {Pressable} from 'react-native'; +import type {PressableRef} from '@components/Pressable/GenericPressable/types'; +import type PressableProps from '@components/Pressable/GenericPressable/types'; import useSingleExecution from '@hooks/useSingleExecution'; import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -10,8 +12,6 @@ import Accessibility from '@libs/Accessibility'; import HapticFeedback from '@libs/HapticFeedback'; import KeyboardShortcut from '@libs/KeyboardShortcut'; import CONST from '@src/CONST'; -import type {PressableRef} from './types'; -import type PressableProps from './types'; function GenericPressable( { diff --git a/src/components/Pressable/GenericPressable/index.native.tsx b/src/components/Pressable/GenericPressable/implementation/index.native.tsx similarity index 78% rename from src/components/Pressable/GenericPressable/index.native.tsx rename to src/components/Pressable/GenericPressable/implementation/index.native.tsx index c17163677cbe..5ce313d21ea6 100644 --- a/src/components/Pressable/GenericPressable/index.native.tsx +++ b/src/components/Pressable/GenericPressable/implementation/index.native.tsx @@ -1,7 +1,7 @@ import React, {forwardRef} from 'react'; +import type {PressableRef} from '@components/Pressable/GenericPressable/types'; +import type PressableProps from '@components/Pressable/GenericPressable/types'; import GenericPressable from './BaseGenericPressable'; -import type {PressableRef} from './types'; -import type PressableProps from './types'; function NativeGenericPressable(props: PressableProps, ref: PressableRef) { return ( diff --git a/src/components/Pressable/GenericPressable/implementation/index.tsx b/src/components/Pressable/GenericPressable/implementation/index.tsx new file mode 100644 index 000000000000..b52eea83fdcb --- /dev/null +++ b/src/components/Pressable/GenericPressable/implementation/index.tsx @@ -0,0 +1,33 @@ +import React, {forwardRef} from 'react'; +import type {Role} from 'react-native'; +import type {PressableRef} from '@components/Pressable/GenericPressable/types'; +import type PressableProps from '@components/Pressable/GenericPressable/types'; +import GenericPressable from './BaseGenericPressable'; + +function WebGenericPressable({focusable = true, ...props}: PressableProps, ref: PressableRef) { + const accessible = props.accessible ?? props.accessible === undefined ? true : props.accessible; + + return ( + + ); +} + +WebGenericPressable.displayName = 'WebGenericPressable'; + +export default forwardRef(WebGenericPressable); diff --git a/src/components/Pressable/GenericPressable/index.e2e.tsx b/src/components/Pressable/GenericPressable/index.e2e.tsx new file mode 100644 index 000000000000..5d997977a7e0 --- /dev/null +++ b/src/components/Pressable/GenericPressable/index.e2e.tsx @@ -0,0 +1,34 @@ +import React, {forwardRef, useEffect} from 'react'; +import GenericPressable from './implementation'; +import type {PressableRef} from './types'; +import type PressableProps from './types'; + +const pressableRegistry = new Map(); + +function getPressableProps(nativeID: string): PressableProps | undefined { + return pressableRegistry.get(nativeID); +} + +function E2EGenericPressableWrapper(props: PressableProps, ref: PressableRef) { + useEffect(() => { + const nativeId = props.nativeID; + if (!nativeId) { + return; + } + console.debug(`[E2E] E2EGenericPressableWrapper: Registering pressable with nativeID: ${nativeId}`); + pressableRegistry.set(nativeId, props); + }, [props]); + + return ( + + ); +} + +E2EGenericPressableWrapper.displayName = 'E2EGenericPressableWrapper'; + +export default forwardRef(E2EGenericPressableWrapper); +export {getPressableProps}; diff --git a/src/components/Pressable/GenericPressable/index.tsx b/src/components/Pressable/GenericPressable/index.tsx index 371b4d169714..c3d3a2b2c856 100644 --- a/src/components/Pressable/GenericPressable/index.tsx +++ b/src/components/Pressable/GenericPressable/index.tsx @@ -1,33 +1,3 @@ -import React, {forwardRef} from 'react'; -import type {Role} from 'react-native'; -import GenericPressable from './BaseGenericPressable'; -import type {PressableRef} from './types'; -import type PressableProps from './types'; +import GenericPressable from './implementation'; -function WebGenericPressable({focusable = true, ...props}: PressableProps, ref: PressableRef) { - const accessible = props.accessible ?? props.accessible === undefined ? true : props.accessible; - - return ( - - ); -} - -WebGenericPressable.displayName = 'WebGenericPressable'; - -export default forwardRef(WebGenericPressable); +export default GenericPressable; diff --git a/src/components/Search/SearchRouter/SearchButton.tsx b/src/components/Search/SearchRouter/SearchButton.tsx index b68945e76520..76eacd8b991d 100644 --- a/src/components/Search/SearchRouter/SearchButton.tsx +++ b/src/components/Search/SearchRouter/SearchButton.tsx @@ -26,6 +26,7 @@ function SearchButton({style}: SearchButtonProps) { return ( { diff --git a/src/libs/E2E/tests/openSearchRouterTest.e2e.ts b/src/libs/E2E/tests/openSearchRouterTest.e2e.ts index 840af5acc2c9..48278aee536a 100644 --- a/src/libs/E2E/tests/openSearchRouterTest.e2e.ts +++ b/src/libs/E2E/tests/openSearchRouterTest.e2e.ts @@ -1,4 +1,5 @@ import Config from 'react-native-config'; +import * as E2EGenericPressableWrapper from '@components/Pressable/GenericPressable/index.e2e'; import E2ELogin from '@libs/E2E/actions/e2eLogin'; import waitForAppLoaded from '@libs/E2E/actions/waitForAppLoaded'; import E2EClient from '@libs/E2E/client'; @@ -31,6 +32,29 @@ const test = () => { Performance.subscribeToMeasurements((entry) => { console.debug(`[E2E] Entry: ${JSON.stringify(entry)}`); + if (entry.name === CONST.TIMING.SIDEBAR_LOADED) { + const props = E2EGenericPressableWrapper.getPressableProps('searchButton'); + if (!props) { + console.debug('[E2E] Search button not found, failing test!'); + E2EClient.submitTestResults({ + branch: Config.E2E_BRANCH, + error: 'Search button not found', + name: 'Open Search Router TTI', + }).then(() => E2EClient.submitTestDone()); + return; + } + if (!props.onPress) { + console.debug('[E2E] Search button found but onPress prop was not present, failing test!'); + E2EClient.submitTestResults({ + branch: Config.E2E_BRANCH, + error: 'Search button found but onPress prop was not present', + name: 'Open Search Router TTI', + }).then(() => E2EClient.submitTestDone()); + return; + } + // Open the search router + props.onPress(); + } if (entry.name === CONST.TIMING.SEARCH_ROUTER_RENDER) { E2EClient.submitTestResults({