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 all 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