Skip to content

Expandable testids #2784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/expandableSection/expandableSection.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"name": "onPress",
"type": "() => void",
"description": "Called when pressing the header of the ExpandableSection"
}
},
{"name": "testID","type": "string","description": "testing identifier"}
],
"snippet": [
"<ExpandableSection",
Expand Down
8 changes: 6 additions & 2 deletions src/components/expandableSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export type ExpandableSectionProps = {
* action for when pressing the header of the expandableSection
*/
onPress?: () => void;
/**
* Testing identifier
*/
testID?: string;
};

/**
Expand All @@ -34,7 +38,7 @@ export type ExpandableSectionProps = {
*/

function ExpandableSection(props: ExpandableSectionProps) {
const {expanded, sectionHeader, children, top} = props;
const {expanded, sectionHeader, children, top, testID} = props;

/**
* TODO: move to reanimated LayoutAnimation after updating to version 2.3.0
Expand All @@ -60,7 +64,7 @@ function ExpandableSection(props: ExpandableSectionProps) {
return (
<View style={styles.container}>
{top && expanded && children}
<TouchableOpacity onPress={onPress} accessibilityState={accessibilityState}>
<TouchableOpacity onPress={onPress} testID={testID} accessibilityState={accessibilityState}>
{sectionHeader}
</TouchableOpacity>
{!top && expanded && children}
Expand Down
4 changes: 4 additions & 0 deletions src/components/touchableOpacity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export interface TouchableOpacityProps
* Custom value of any type to pass on to TouchableOpacity and receive back in onPress callback
*/
customValue?: any;
/**
* Testing identifier
*/
testID?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you don't need to define a testID prop on TouchableOpacity, it already inherit it from React Native's TouchableOpacity

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. Fixed.

style?: ViewProps['style'];
onPress?: (props?: (TouchableOpacityProps & {event: GestureResponderEvent}) | any) => void;
onPressIn?: (
Expand Down
3 changes: 2 additions & 1 deletion src/components/touchableOpacity/touchableOpacity.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
},
{"name": "style", "type": "ViewStyle", "description": "Custom style"},
{"name": "recorderTag", "type": "'mask' | 'unmask'", "description": "Recorder Tag"},
{"name": "onPress", "type": "(props?: TouchableOpacityProps & {event: GestureResponderEvent} | any) => void", "description": "On press callback"}
{"name": "onPress", "type": "(props?: TouchableOpacityProps & {event: GestureResponderEvent} | any) => void", "description": "On press callback"},
{"name": "testID", "type": "string", "description": "testing identifier"}
],
"snippet": [
"<TouchableOpacity onPress={() => console.log('pressed')$1}/>"
Expand Down