-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add data-testid
attribute to SplitButton
's menu trigger element
#2621
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 6fe917b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Change: +198 B (+0.01%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
@@ -134,6 +134,7 @@ export const Menu = ({ | |||
className={cx(triggerBaseStyles, triggerSizeStyles[size], { | |||
[triggerThemeStyles(theme, variant)]: !disabled, | |||
})} | |||
data-testid="lg-split-button-trigger" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We recently adopted a BEM-ish pattern for testid's.
I would suggest: lg-split_button-trigger
.
I’d also recommend creating a constants.ts file to define the testids, following a similar approach as seen in Menu.
I would also add a default testid for the primary button since you're adding one for the trigger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can certainly do that 👍 If I did, should we introduce another breaking change and update
data-testid="lg-split-button-menu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the different between data-testid
and data-lgid
? It seems the Menu
pass both:
leafygreen-ui/packages/menu/src/Menu/Menu.tsx
Lines 200 to 201 in a3d63cb
data-testid={LGIDs.root} | |
data-lgid={LGIDs.root} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just rebased and pushed 2bf7dab with changes taking this comment into considerations.
Regarding the difference between testid
and lgid
I was thinking of an alternative where the testid
supplied by the user could serve as "base" for other testids used throughout the component. I.e. if the user sets data-testid="my_thing"
on the SplitButton
the menu inside would get data-testid="my_thing-menu"
instead of (the default) data-testid="lg-split_button-menu"
. That way the user can provide individual testids when rendering multiple components and more easily target deeply into the individual elements. The alternative (which is what I added with 2bf7dab) the data-testid
supplied by the user is only used for the root and the user has to reference nested testid
values, relative to this.
aaba11a
to
89fb096
Compare
89fb096
to
6fe917b
Compare
✍️ Proposed changes
In an effort to make out tests more robust to future changes, I suggest adding a
data-testid
attribute so theSplitButton
trigger button can be targeted directly.✅ Checklist
For bug fixes, new features & breaking changes
yarn changeset
and documented my changesFor new components
🧪 How to test changes