-
Notifications
You must be signed in to change notification settings - Fork 76
LG-5778(feat): update expandable card test utils #3442
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
4a376f9
c940fe7
c5751c9
9315b8d
f4688a4
8a10064
ac6ac19
40c6465
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@leafygreen-ui/expandable-card': minor | ||
| --- | ||
|
|
||
| Adds `getTitle`, `getDescription`, and `getFlagText` test utils to `ExpandableCard`. [LG-5778](https://jira.mongodb.org/browse/LG-5778) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import LeafyGreenProvider, { | |
| } from '@leafygreen-ui/leafygreen-provider'; | ||
| import { Body, Subtitle } from '@leafygreen-ui/typography'; | ||
|
|
||
| import { DEFAULT_LGID_ROOT, getLgIds } from '../testing'; | ||
| import { getLgIds } from '../testing'; | ||
|
|
||
| import { | ||
| cardStyle, | ||
|
|
@@ -43,7 +43,7 @@ const ExpandableCard = ({ | |
| id: idProp, | ||
| flagText, | ||
| contentClassName, | ||
| 'data-lgid': dataLgId = DEFAULT_LGID_ROOT, | ||
| 'data-lgid': dataLgId, | ||
shaneeza marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ...rest | ||
| }: ExpandableCardProps) => { | ||
| const { darkMode, theme } = useDarkMode(darkModeProp); | ||
|
|
@@ -123,11 +123,30 @@ const ExpandableCard = ({ | |
| tabIndex={-1} | ||
| > | ||
| <span> | ||
| <Subtitle className={summaryHeader}>{title}</Subtitle> | ||
| {flagText && <span className={flagTextStyle}>{flagText}</span>} | ||
| <Subtitle | ||
| data-testid={lgIds.title} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've been looking into this pattern of adding lgIds to CC @stephl3
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would agree. The pattern of implementing test utils and setting
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few reasons. This is to support consumers who are testing without a DOM. Our test utils require the use of the DOM, but without a DOM you can still query with |
||
| data-lgid={lgIds.title} | ||
| className={summaryHeader} | ||
| > | ||
| {title} | ||
| </Subtitle> | ||
| {flagText && ( | ||
| <span | ||
| data-testid={lgIds.flagText} | ||
| data-lgid={lgIds.flagText} | ||
| className={flagTextStyle} | ||
| > | ||
| {flagText} | ||
| </span> | ||
| )} | ||
| </span> | ||
| {description && ( | ||
| <Body as="div" className={summaryTextThemeStyle[theme]}> | ||
| <Body | ||
| as="div" | ||
| data-testid={lgIds.description} | ||
| data-lgid={lgIds.description} | ||
| className={summaryTextThemeStyle[theme]} | ||
| > | ||
| {description} | ||
| </Body> | ||
| )} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.