-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat: Adds test id to cards #2976
feat: Adds test id to cards #2976
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2976 +/- ##
==========================================
+ Coverage 96.25% 96.27% +0.02%
==========================================
Files 768 769 +1
Lines 21750 21776 +26
Branches 7434 7042 -392
==========================================
+ Hits 20935 20965 +30
+ Misses 807 803 -4
Partials 8 8 ☔ View full report in Codecov by Sentry. |
da09f0e
to
7411bf8
Compare
7411bf8
to
b253497
Compare
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.
Approved, but left a non-blocking doc comment.
@@ -30,6 +31,19 @@ export class CardWrapper extends ComponentWrapper { | |||
return this.findAllByClassName(styles.section).map(c => new CardSectionWrapper(c.getElement())); | |||
} | |||
|
|||
/** | |||
* Returns the wrapper of the first card section that matches the specified test ID. | |||
* Looks for the `data-testid` attribute that is assigned via `sections.testId` prop. |
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.
Minor, since I don't want to derail all the other PRs: why do we even have this line? From a builder perspective, all they care about is that they provided a testId
and this util finds it based on what you provided. Why would I need to care about the fact that it's using data-testid
?
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.
data-testid
is now part of our public API. This is for keeping the compatibility with RTL and other tools that look for data-testid
.
This is actually one of the reasons why we decided to use this attribute rather than internal ones like data-awsui-id
or others.
You can check the conversation in this PR or comments in related API proposal.
Description
Adds
testId
extractor function to cards inside the card component. Unlike other components, cards can't have a singletestId
prop as theitems
are generic with no base types. For this reason we use a function to extract test id for every individual item.Related links, issue #, if available:
Collective PR: #2985
Project: Improving test utils API
How has this been tested?
Tests added to cover the change.
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md
.CONTRIBUTING.md
.Security
checkSafeUrl
function.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.