Skip to content

Commit

Permalink
fix: Allow DS dropdown to have custom data-test attributes (#5284)
Browse files Browse the repository at this point in the history
Co-authored-by: Geoffroy Baccarini <[email protected]>
  • Loading branch information
Gbacc and Geoffroy Baccarini authored Apr 23, 2024
1 parent 4998047 commit 25fb283
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-fishes-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talend/design-system": patch
---

Allow Design System dropdown to have custom data-test attributes
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ describe('Dropdown', () => {
{
label: 'Link as',
type: 'link',
'data-testid': 'link-as',
'data-test': 'link-as',
as: <RouterLink to="/route" />,
},
]}
Expand Down
8 changes: 4 additions & 4 deletions packages/design-system/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export const Dropdown = ({
const id = `${label}-${index}`;
return (
<DropdownButton
data-testid={`${menuItemTestId}.${id}`}
data-test={`${menuItemTest}.${id}`}
{...entryRest}
// {...menu}
onClick={(event: MouseEvent<HTMLButtonElement> | KeyboardEvent) => {
Expand All @@ -123,8 +125,6 @@ export const Dropdown = ({
key={uuid}
tabIndex={0}
id={uuid}
data-testid={`${menuItemTestId}.${id}`}
data-test={`${menuItemTest}.${id}`}
>
{label}
</DropdownButton>
Expand Down Expand Up @@ -161,6 +161,8 @@ export const Dropdown = ({
const id = `${label}-${index}`;
return (
<DropdownLink
data-testid={`${menuItemTestId}.${id}`}
data-test={`${menuItemTest}.${id}`}
as={as}
{...entryRest}
// {...menu}
Expand All @@ -172,8 +174,6 @@ export const Dropdown = ({
entry.onClick(event);
}
}}
data-testid={`${menuItemTestId}.${id}`}
data-test={`${menuItemTest}.${id}`}
>
{label}
</DropdownLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ exports[`Dropdown should render a11y html 1`] = `
</button>
<a
class="theme-linkable theme-dropdownEntry"
data-test="dropdown.menuitem.Link as-5"
data-testid="dropdown.menuitem.Link as-5"
data-test="link-as"
data-testid="link-as"
href="/route"
id="mocked-uuid-11"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Story } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { BrowserRouter, Link as RouterLink } from 'react-router-dom';

import { action } from '@storybook/addon-actions';
import { Story } from '@storybook/react';

import { ButtonIcon, ButtonPrimary, ButtonSecondary, ButtonTertiary, Dropdown } from '../../';

export default {
Expand Down Expand Up @@ -246,6 +248,8 @@ export const Basic = () => (
label: 'Router link with too much copy to create an overflow',
type: 'link',
icon: 'plus-stroke',
'data-testid': 'link-as',
'data-test': 'link-as',
as: <RouterLink to="/documentation" />,
},
{
Expand Down

0 comments on commit 25fb283

Please sign in to comment.