Skip to content

Commit d588db4

Browse files
authored
Fix/ FloatingButton testID (#1395)
* add testID to floatingButton * add description for testID
1 parent d377226 commit d588db4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

generatedTypes/components/floatingButton/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export interface FloatingButtonProps {
3131
hideBackgroundOverlay?: boolean;
3232
/**
3333
* Used as testing identifier
34+
* <TestID> - the floatingButton container
35+
* <TestID>.button - the floatingButton main button
36+
* <TestID>.secondaryButton - the floatingButton secondaryButton
3437
*/
3538
testID?: string;
3639
}

src/components/floatingButton/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export interface FloatingButtonProps {
3838
hideBackgroundOverlay?: boolean;
3939
/**
4040
* Used as testing identifier
41+
* <TestID> - the floatingButton container
42+
* <TestID>.button - the floatingButton main button
43+
* <TestID>.secondaryButton - the floatingButton secondaryButton
4144
*/
4245
testID?: string;
4346
}
@@ -94,13 +97,14 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
9497
}
9598

9699
renderButton() {
97-
const {bottomMargin, button, secondaryButton} = this.props;
100+
const {bottomMargin, button, secondaryButton, testID} = this.props;
98101
const bottom = secondaryButton ? Spacings.s4 : bottomMargin || Spacings.s8;
99102

100103
return (
101104
<Button
102105
size={Button.sizes.large}
103106
style={[styles.shadow, {marginTop: 16, marginBottom: bottom}]}
107+
testID={`${testID}.button`}
104108
{...button}
105109
/>
106110
);
@@ -121,12 +125,13 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
121125
};
122126

123127
renderSecondaryButton() {
124-
const {secondaryButton, bottomMargin} = this.props;
128+
const {secondaryButton, bottomMargin, testID} = this.props;
125129

126130
return (
127131
<Button
128132
link
129133
size={Button.sizes.large}
134+
testID={`${testID}.secondaryButton`}
130135
{...secondaryButton}
131136
style={{marginBottom: bottomMargin || Spacings.s7}}
132137
enableShadow={false}
@@ -135,7 +140,7 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
135140
}
136141

137142
render() {
138-
const {withoutAnimation, secondaryButton, visible} = this.props;
143+
const {withoutAnimation, secondaryButton, visible, testID} = this.props;
139144
// NOTE: keep this.firstLoad as true as long as the visibility changed to true
140145
this.firstLoad && !visible ? this.firstLoad = true : this.firstLoad = false;
141146

@@ -152,6 +157,7 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
152157
pointerEvents="box-none"
153158
animated
154159
style={[styles.container, this.getAnimatedStyle()]}
160+
testID={testID}
155161
>
156162
{this.renderOverlay()}
157163
{this.renderButton()}

0 commit comments

Comments
 (0)