@@ -38,6 +38,9 @@ export interface FloatingButtonProps {
38
38
hideBackgroundOverlay ?: boolean ;
39
39
/**
40
40
* Used as testing identifier
41
+ * <TestID> - the floatingButton container
42
+ * <TestID>.button - the floatingButton main button
43
+ * <TestID>.secondaryButton - the floatingButton secondaryButton
41
44
*/
42
45
testID ?: string ;
43
46
}
@@ -94,13 +97,14 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
94
97
}
95
98
96
99
renderButton ( ) {
97
- const { bottomMargin, button, secondaryButton} = this . props ;
100
+ const { bottomMargin, button, secondaryButton, testID } = this . props ;
98
101
const bottom = secondaryButton ? Spacings . s4 : bottomMargin || Spacings . s8 ;
99
102
100
103
return (
101
104
< Button
102
105
size = { Button . sizes . large }
103
106
style = { [ styles . shadow , { marginTop : 16 , marginBottom : bottom } ] }
107
+ testID = { `${ testID } .button` }
104
108
{ ...button }
105
109
/>
106
110
) ;
@@ -121,12 +125,13 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
121
125
} ;
122
126
123
127
renderSecondaryButton ( ) {
124
- const { secondaryButton, bottomMargin} = this . props ;
128
+ const { secondaryButton, bottomMargin, testID } = this . props ;
125
129
126
130
return (
127
131
< Button
128
132
link
129
133
size = { Button . sizes . large }
134
+ testID = { `${ testID } .secondaryButton` }
130
135
{ ...secondaryButton }
131
136
style = { { marginBottom : bottomMargin || Spacings . s7 } }
132
137
enableShadow = { false }
@@ -135,7 +140,7 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
135
140
}
136
141
137
142
render ( ) {
138
- const { withoutAnimation, secondaryButton, visible} = this . props ;
143
+ const { withoutAnimation, secondaryButton, visible, testID } = this . props ;
139
144
// NOTE: keep this.firstLoad as true as long as the visibility changed to true
140
145
this . firstLoad && ! visible ? this . firstLoad = true : this . firstLoad = false ;
141
146
@@ -152,6 +157,7 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
152
157
pointerEvents = "box-none"
153
158
animated
154
159
style = { [ styles . container , this . getAnimatedStyle ( ) ] }
160
+ testID = { testID }
155
161
>
156
162
{ this . renderOverlay ( ) }
157
163
{ this . renderButton ( ) }
0 commit comments