Skip to content

Fix/ FloatingButton testID #1395

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 2 commits into from
Jul 14, 2021
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: 3 additions & 0 deletions generatedTypes/components/floatingButton/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export interface FloatingButtonProps {
hideBackgroundOverlay?: boolean;
/**
* Used as testing identifier
* <TestID> - the floatingButton container
* <TestID>.button - the floatingButton main button
* <TestID>.secondaryButton - the floatingButton secondaryButton
*/
testID?: string;
}
Expand Down
12 changes: 9 additions & 3 deletions src/components/floatingButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export interface FloatingButtonProps {
hideBackgroundOverlay?: boolean;
/**
* Used as testing identifier
* <TestID> - the floatingButton container
* <TestID>.button - the floatingButton main button
* <TestID>.secondaryButton - the floatingButton secondaryButton
*/
testID?: string;
}
Expand Down Expand Up @@ -94,13 +97,14 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
}

renderButton() {
const {bottomMargin, button, secondaryButton} = this.props;
const {bottomMargin, button, secondaryButton, testID} = this.props;
const bottom = secondaryButton ? Spacings.s4 : bottomMargin || Spacings.s8;

return (
<Button
size={Button.sizes.large}
style={[styles.shadow, {marginTop: 16, marginBottom: bottom}]}
testID={`${testID}.button`}
{...button}
/>
);
Expand All @@ -121,12 +125,13 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
};

renderSecondaryButton() {
const {secondaryButton, bottomMargin} = this.props;
const {secondaryButton, bottomMargin, testID} = this.props;

return (
<Button
link
size={Button.sizes.large}
testID={`${testID}.secondaryButton`}
{...secondaryButton}
style={{marginBottom: bottomMargin || Spacings.s7}}
enableShadow={false}
Expand All @@ -135,7 +140,7 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
}

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

Expand All @@ -152,6 +157,7 @@ class FloatingButton extends PureComponent<FloatingButtonProps> {
pointerEvents="box-none"
animated
style={[styles.container, this.getAnimatedStyle()]}
testID={testID}
>
{this.renderOverlay()}
{this.renderButton()}
Expand Down