Skip to content

Commit

Permalink
Remove default data-testid from snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-wh committed Jan 17, 2025
1 parent b114938 commit d851c21
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
5 changes: 0 additions & 5 deletions packages/yoga/src/Snackbar/native/Snackbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const Snackbar = forwardRef((props, ref) => {
onSnackbarClose,
duration,
bottomOffset,
dataTestId,
...rest
} = props;
const wrapperRef = useRef();
Expand Down Expand Up @@ -150,7 +149,6 @@ const Snackbar = forwardRef((props, ref) => {
<SnackbarContainer
variant={currentProps.variant}
bottomOffset={bottomOffset}
testID={dataTestId}
{...rest}
{...panResponder.panHandlers}
>
Expand Down Expand Up @@ -203,8 +201,6 @@ Snackbar.propTypes = {
duration: oneOf(['fast', 'default', 'slow', 'indefinite']),
/** Add extra margin to Snackbar. Can be useful for SafeAreaView or button cases. */
bottomOffset: number,
/* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
dataTestId: string,
};

Snackbar.defaultProps = {
Expand All @@ -216,7 +212,6 @@ Snackbar.defaultProps = {
onSnackbarClose: undefined,
duration: 'default',
bottomOffset: 0,
dataTestId: 'snackbar',
};

export default Snackbar;
2 changes: 1 addition & 1 deletion packages/yoga/src/Snackbar/native/Snackbar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('<Snackbar />', () => {
});

it('should render with custom dataTestId', () => {
const { getByTestId } = render(<Component dataTestId="custom-snackbar" />);
const { getByTestId } = render(<Component testID="custom-snackbar" />);

fireEvent.press(getByTestId('custom-snackbar'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ exports[`<Snackbar /> should match snapshot when have a long text 1`] = `
},
]
}
testID="snackbar"
variant="success"
>
<RNSVGSvgView
Expand Down Expand Up @@ -458,7 +457,6 @@ exports[`<Snackbar /> should match snapshot when have a variant informative or a
},
]
}
testID="snackbar"
variant="informative"
>
<Text
Expand Down Expand Up @@ -623,7 +621,6 @@ exports[`<Snackbar /> should match snapshot when have an icon and action 1`] = `
},
]
}
testID="snackbar"
variant="success"
>
<RNSVGSvgView
Expand Down Expand Up @@ -949,7 +946,6 @@ exports[`<Snackbar /> should match snapshot when snackbar is default 1`] = `
},
]
}
testID="snackbar"
variant="success"
>
<Text
Expand Down
6 changes: 0 additions & 6 deletions packages/yoga/src/Snackbar/web/Snackbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ const Snackbar = React.forwardRef(
onClose,
hideCloseButton,
ariaLabelClose,
dataTestId,
theme: {
yoga: {
components: { snackbar },
Expand Down Expand Up @@ -153,7 +152,6 @@ const Snackbar = React.forwardRef(
aria-label={variant}
variant={variant}
ref={ref}
data-testid={dataTestId}
{...props}
>
{!hideIcon && (
Expand All @@ -162,7 +160,6 @@ const Snackbar = React.forwardRef(
alignItems="center"
mr="small"
role="img"
data-testid="img"
aria-hidden
>
<Icon
Expand Down Expand Up @@ -223,8 +220,6 @@ Snackbar.propTypes = {
hideCloseButton: bool,
/** Custom aria label for close button. */
ariaLabelClose: string,
/* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
dataTestId: string,
};

Snackbar.defaultProps = {
Expand All @@ -236,7 +231,6 @@ Snackbar.defaultProps = {
variant: 'success',
hideCloseButton: false,
ariaLabelClose: undefined,
dataTestId: 'snackbar',
};

export default memo(withTheme(Snackbar));
11 changes: 8 additions & 3 deletions packages/yoga/src/Snackbar/web/Snackbar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('<Snackbar />', () => {
open
message="Make wellbeing universal"
onClose={jest.fn()}
dataTestId="custom-snackbar"
data-testid="custom-snackbar"
/>
</ThemeProvider>,
);
Expand All @@ -34,12 +34,17 @@ describe('<Snackbar />', () => {
it('should render a minimal snackbar', () => {
render(
<ThemeProvider>
<Snackbar open message="Make wellbeing universal" onClose={jest.fn()} />
<Snackbar
open
message="Make wellbeing universal"
onClose={jest.fn()}
data-testid="custom-snackbar"
/>
</ThemeProvider>,
);

screen.getByRole('alert');
screen.getByTestId('img');
screen.getByTestId('custom-snackbar');
screen.getByLabelText('success');
screen.getByText('Make wellbeing universal');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,11 @@ exports[`<Snackbar /> should match snapshot 1`] = `
<div
aria-label="success"
class="c0"
data-testid="snackbar"
role="alert"
>
<div
aria-hidden="true"
class="c1"
data-testid="img"
display="flex"
role="img"
>
Expand Down

0 comments on commit d851c21

Please sign in to comment.