Skip to content
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

DS-979 - Remove default data-testid from snackbar #864

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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));
14 changes: 11 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,20 @@ 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');
expect(
screen.getByTestId('custom-snackbar').querySelector('[role="img"]'),
).toBeTruthy();
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
Loading