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

feat(Rows, Cards, FeedbackScreen, FormFields, Buttons): add test ids for components and their internal elements #1270

Open
wants to merge 4 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
2 changes: 1 addition & 1 deletion src/__private_stories__/image-sizes-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const Default: StoryComponent<Args> = ({forceNonCssAspectRatio}) => {
);

return (
<Stack space={16} dataAttributes={{testId: 'story'}}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated, but camelCase is not correct here

<Stack space={16} dataAttributes={{testid: 'story'}}>
<div style={{width: 400, border: '2px solid pink'}}>
<Stack space={16}>{cases.map((props, index) => renderCase(props, index))}</Stack>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/boxed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const InternalBoxed = React.forwardRef<HTMLDivElement, Props & InternalPr
(
{
children,
isInverse: isInverseInside = false,
isInverse = false,
className,
role,
dataAttributes,
Expand All @@ -90,6 +90,7 @@ export const InternalBoxed = React.forwardRef<HTMLDivElement, Props & InternalPr
ref
) => {
const isInverseOutside = useIsInverseOrMediaVariant();
const isInverseInside = isInverse || variant === 'inverse' || variant === 'media';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but Boxed was not working properly when using media variant


return (
<div
Expand Down
30 changes: 24 additions & 6 deletions src/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ const renderButtonContent = ({
alignItems: 'center',
marginRight: styles.iconMargin,
}}
data-testid="startIcon"
>
<StartIcon size={defaultIconSize} color="currentColor" />
</div>
Expand All @@ -201,6 +202,7 @@ const renderButtonContent = ({
alignItems: 'center',
marginLeft: styles.iconMargin,
}}
data-testid="endIcon"
>
<EndIcon size={defaultIconSize} color="currentColor" />
</div>
Expand Down Expand Up @@ -249,7 +251,11 @@ const renderButtonContent = ({
}}
/>
)}
{loadingText ? <Box paddingLeft={8}>{loadingButtonElement}</Box> : null}
{loadingText ? (
<Box paddingLeft={8} dataAttributes={{testid: 'loadingText'}}>
{loadingButtonElement}
</Box>
) : null}
</div>
</>
);
Expand Down Expand Up @@ -513,7 +519,7 @@ export const ButtonLink = React.forwardRef<
>(({dataAttributes, className, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonLink', ...dataAttributes}}
dataAttributes={{'component-name': 'ButtonLink', testid: 'ButtonLink', ...dataAttributes}}
className={classnames(className, {[styles.smallLink]: props.small})}
{...props}
ref={ref}
Expand All @@ -526,7 +532,11 @@ export const ButtonLinkDanger = React.forwardRef<TouchableElement, ButtonLinkPro
({dataAttributes, className, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonLinkDanger', ...dataAttributes}}
dataAttributes={{
'component-name': 'ButtonLinkDanger',
testid: 'ButtonLinkDanger',
...dataAttributes,
}}
className={classnames(className, {[styles.smallLink]: props.small})}
{...props}
withChevron={false}
Expand All @@ -541,7 +551,11 @@ export const ButtonPrimary = React.forwardRef<TouchableElement, ButtonProps>(
({dataAttributes, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonPrimary', ...dataAttributes}}
dataAttributes={{
'component-name': 'ButtonPrimary',
testid: 'ButtonPrimary',
...dataAttributes,
}}
{...props}
ref={ref}
buttonType="primary"
Expand All @@ -554,7 +568,11 @@ export const ButtonSecondary = React.forwardRef<TouchableElement, ButtonProps>(
({dataAttributes, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonSecondary', ...dataAttributes}}
dataAttributes={{
'component-name': 'ButtonSecondary',
testid: 'ButtonSecondary',
...dataAttributes,
}}
{...props}
ref={ref}
buttonType="secondary"
Expand All @@ -567,7 +585,7 @@ export const ButtonDanger = React.forwardRef<TouchableElement, ButtonProps>(
({dataAttributes, ...props}, ref) => {
return (
<BaseButton
dataAttributes={{'component-name': 'ButtonDanger', ...dataAttributes}}
dataAttributes={{'component-name': 'ButtonDanger', testid: 'ButtonDanger', ...dataAttributes}}
{...props}
ref={ref}
buttonType="danger"
Expand Down
Loading
Loading