Skip to content

Commit ea51a11

Browse files
committed
components: Fix data-cy
1 parent 7639fc9 commit ea51a11

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

packages/components/src/FormSelect/components/CustomOption.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ import React from "react";
33
import { Option } from "../types";
44
import css from "./index.module.css";
55

6-
export default function CustomOption<T, OptionType extends Option<T>>(props: {
6+
type Props<OptionType> = {
77
data: OptionType;
8-
}) {
8+
dataCyPrefix: string;
9+
};
10+
11+
export default function CustomOption<T, OptionType extends Option<T>>(
12+
props: Props<OptionType>,
13+
) {
914
return (
1015
<span
1116
className={cx({ [css.withIconPath]: !!props.data.iconPath })}
1217
aria-label={String(props.data.value)}
13-
data-cy={String(props.data.value)}
18+
data-cy={`${props.dataCyPrefix}-${props.data.value}`}
1419
>
1520
{props.data.iconPath && (
1621
<img src={props.data.iconPath} alt={props.data.label} />

packages/components/src/FormSelect/components/Option.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function OptionComponent<
1313
>(props: OptionProps<OptionType, IsMulti>): JSX.Element {
1414
return (
1515
<components.Option {...props}>
16-
<CustomOption data={props.data} />
16+
<CustomOption data={props.data} dataCyPrefix="select-option" />
1717
</components.Option>
1818
);
1919
}
@@ -28,7 +28,7 @@ export function OptionForGroup<
2828
<FiCheck
2929
className={cx(css.check, { [css.checkInvisible]: !props.isSelected })}
3030
/>
31-
<CustomOption data={props.data} />
31+
<CustomOption data={props.data} dataCyPrefix="select-option" />
3232
</components.Option>
3333
);
3434
}

packages/components/src/FormSelect/components/SingleValue.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function SingleValueComponent<
1010
>(props: SingleValueProps<OptionType, IsMulti>): JSX.Element {
1111
return (
1212
<components.SingleValue {...props}>
13-
<CustomOption data={props.data} />
13+
<CustomOption data={props.data} dataCyPrefix="single-value" />
1414
</components.SingleValue>
1515
);
1616
}

0 commit comments

Comments
 (0)