-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51157 from margelo/fix/e2e-search-tests
[NoQA] fix(e2e): fix e2e search test by clicking search page
- Loading branch information
Showing
7 changed files
with
98 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
4 changes: 2 additions & 2 deletions
4
...essable/GenericPressable/index.native.tsx → ...Pressable/implementation/index.native.tsx
This file contains 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
33 changes: 33 additions & 0 deletions
33
src/components/Pressable/GenericPressable/implementation/index.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<GenericPressable | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={ref} | ||
// change native accessibility props to web accessibility props | ||
focusable={focusable} | ||
tabIndex={props.tabIndex ?? (!accessible || !focusable) ? -1 : 0} | ||
role={(props.accessibilityRole ?? props.role) as Role} | ||
id={props.id} | ||
aria-label={props.accessibilityLabel} | ||
aria-labelledby={props.accessibilityLabelledBy} | ||
aria-valuenow={props.accessibilityValue?.now} | ||
aria-valuemin={props.accessibilityValue?.min} | ||
aria-valuemax={props.accessibilityValue?.max} | ||
aria-valuetext={props.accessibilityValue?.text} | ||
dataSet={{tag: 'pressable', ...(props.noDragArea && {dragArea: false}), ...props.dataSet}} | ||
/> | ||
); | ||
} | ||
|
||
WebGenericPressable.displayName = 'WebGenericPressable'; | ||
|
||
export default forwardRef(WebGenericPressable); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string, PressableProps>(); | ||
|
||
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 ( | ||
<GenericPressable | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
} | ||
|
||
E2EGenericPressableWrapper.displayName = 'E2EGenericPressableWrapper'; | ||
|
||
export default forwardRef(E2EGenericPressableWrapper); | ||
export {getPressableProps}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<GenericPressable | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
ref={ref} | ||
// change native accessibility props to web accessibility props | ||
focusable={focusable} | ||
tabIndex={props.tabIndex ?? (!accessible || !focusable) ? -1 : 0} | ||
role={(props.accessibilityRole ?? props.role) as Role} | ||
id={props.id} | ||
aria-label={props.accessibilityLabel} | ||
aria-labelledby={props.accessibilityLabelledBy} | ||
aria-valuenow={props.accessibilityValue?.now} | ||
aria-valuemin={props.accessibilityValue?.min} | ||
aria-valuemax={props.accessibilityValue?.max} | ||
aria-valuetext={props.accessibilityValue?.text} | ||
dataSet={{tag: 'pressable', ...(props.noDragArea && {dragArea: false}), ...props.dataSet}} | ||
/> | ||
); | ||
} | ||
|
||
WebGenericPressable.displayName = 'WebGenericPressable'; | ||
|
||
export default forwardRef(WebGenericPressable); | ||
export default GenericPressable; |
This file contains 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
This file contains 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