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

test(components): add data-test-ids for e2e tests #870

Open
wants to merge 1 commit 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
9 changes: 5 additions & 4 deletions src/base/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@ import { Button as MuiButton, type ButtonProps as MuiButtonProps } from '@mui/ma
export interface ButtonProps extends MuiButtonProps {
label?: string;
children?: React.ReactNode;
'data-testid'?: string;
}

export function Button({ label, children, ...props }: ButtonProps): JSX.Element {
return (
<MuiButton {...props}>
<MuiButton data-testid={props['data-testid']} {...props}>
{label}
{children}
</MuiButton>
);
}

export const ContainedButton = (props: ButtonProps): JSX.Element => (
<Button variant="contained" {...props}>
<Button variant="contained" data-testid={props['data-testid'] || 'contained-button'} {...props}>
{props.children}
</Button>
);
export const OutlinedButton = (props: ButtonProps): JSX.Element => (
<Button variant="outlined" {...props}>
<Button variant="outlined" data-testid={props['data-testid'] || 'outlined-button'} {...props}>
{props.children}
</Button>
);
export const TextButton = (props: ButtonProps): JSX.Element => (
<Button variant="text" {...props}>
<Button variant="text" data-testid={props['data-testid'] || 'text-button'} {...props}>
{props.children}
</Button>
);
Expand Down
6 changes: 5 additions & 1 deletion src/base/Switch/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Switch as MuiSwitch, type SwitchProps as MuiSwitchProps } from '@mui/material';
import React from 'react';

const Switch = React.forwardRef<HTMLButtonElement, MuiSwitchProps>((props, ref) => {
interface ExtendedSwitchProps extends MuiSwitchProps {
'data-testid'?: string;
}

const Switch = React.forwardRef<HTMLButtonElement, ExtendedSwitchProps>((props, ref) => {
return <MuiSwitch {...props} ref={ref} />;
});

Expand Down
6 changes: 5 additions & 1 deletion src/base/Typography/Typography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
} from '@mui/material';
import React from 'react';

const Typography = React.forwardRef<HTMLDivElement, MuiTypographyProps>((props, ref) => {
interface ExtendedTypographyProps extends MuiTypographyProps {
'data-testid'?: string;
}

const Typography = React.forwardRef<HTMLDivElement, ExtendedTypographyProps>((props, ref) => {
return <MuiTypography {...props} ref={ref} />;
});

Expand Down