Skip to content

Commit

Permalink
components: Fix data-cy
Browse files Browse the repository at this point in the history
  • Loading branch information
tbantle22 committed Mar 15, 2024
1 parent 7639fc9 commit ea51a11
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions packages/components/src/FormSelect/components/CustomOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ import React from "react";
import { Option } from "../types";
import css from "./index.module.css";

export default function CustomOption<T, OptionType extends Option<T>>(props: {
type Props<OptionType> = {
data: OptionType;
}) {
dataCyPrefix: string;
};

export default function CustomOption<T, OptionType extends Option<T>>(
props: Props<OptionType>,
) {
return (
<span
className={cx({ [css.withIconPath]: !!props.data.iconPath })}
aria-label={String(props.data.value)}
data-cy={String(props.data.value)}
data-cy={`${props.dataCyPrefix}-${props.data.value}`}
>
{props.data.iconPath && (
<img src={props.data.iconPath} alt={props.data.label} />
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/FormSelect/components/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function OptionComponent<
>(props: OptionProps<OptionType, IsMulti>): JSX.Element {
return (
<components.Option {...props}>
<CustomOption data={props.data} />
<CustomOption data={props.data} dataCyPrefix="select-option" />
</components.Option>
);
}
Expand All @@ -28,7 +28,7 @@ export function OptionForGroup<
<FiCheck
className={cx(css.check, { [css.checkInvisible]: !props.isSelected })}
/>
<CustomOption data={props.data} />
<CustomOption data={props.data} dataCyPrefix="select-option" />
</components.Option>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function SingleValueComponent<
>(props: SingleValueProps<OptionType, IsMulti>): JSX.Element {
return (
<components.SingleValue {...props}>
<CustomOption data={props.data} />
<CustomOption data={props.data} dataCyPrefix="single-value" />
</components.SingleValue>
);
}

0 comments on commit ea51a11

Please sign in to comment.