-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fix/BannerBase to TS #20421
fix/BannerBase to TS #20421
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
ui/components/component-library/banner-base/banner-base.types.ts
Outdated
Show resolved
Hide resolved
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
Codecov Report
@@ Coverage Diff @@
## develop #20421 +/- ##
===========================================
- Coverage 68.68% 68.68% -0.00%
===========================================
Files 991 991
Lines 38451 38452 +1
Branches 10329 10330 +1
===========================================
- Hits 26409 26408 -1
- Misses 12042 12044 +2
|
ui/components/component-library/banner-base/banner-base.types.ts
Outdated
Show resolved
Hide resolved
ui/components/component-library/banner-base/banner-base.types.ts
Outdated
Show resolved
Hide resolved
type MakePropsOptional<T> = { | ||
[K in keyof T]?: T[K]; | ||
}; |
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.
This type helper allows for us to use prop objects without needing to pass all required props through the prop object. @brad-decker do you have any suggestions on where a type like this should live? Should we create a types.ts
file in the root of the ui/components/component-library/types.ts
or maybe in shared/constants/component-library.ts
?
typescript.after.mov
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.
cc @garrettbear
* TypeScript is complaining about data- attributes which means we need to explicitly define this as a prop. | ||
* TODO: Allow data- attributes. | ||
*/ | ||
'data-testid'?: string; |
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.
Temporary fix to allow data-testid
s being passed to prop objects which is generally what they will be used for
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.
LGTM! I made some small updates based on your suggestions while I had your branch checked out. Thanks for your contribution @dhruvv173
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.
Hey @dhruvv173, this PR should fix the linting error #20448 and looks like I missed some snapshots or they were updated in the last merge from develop. I was also thinking that because I added the childrenWrapperProps
we should write a unit test for that. There should be some examples of this with titleProps
in the unit tests. Would you mind updating it?
I have updated the snapshot locally and lint error will be fixed once your PR is merged. About the latter part, I just want to confirm that we want to add a unit test which checks for |
Yes, that's correct! I noticed that we aren't actually testing for
Changing this element to a
|
hi @georgewrmarshall, what do think about something like this?
|
Looks good! |
every instance of |
…hildrenWrapperProps
added |
…ng static data-testid in favor of using it at the instance, updating snapshots associated with those changes
test/e2e/swaps/shared.js
Outdated
@@ -157,7 +157,7 @@ const checkActivityTransaction = async (driver, options) => { | |||
|
|||
const checkNotification = async (driver, options) => { | |||
const boxTitle = await driver.findElement( | |||
'[data-testid="mm-banner-base-title"]', | |||
'[data-testid="swap-token-verification-banner-title"]', |
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.
Removing the static data-testid that was added to the component in favor of using descriptionProps
and making the test id more specific"
{children && typeof children === 'object' ? ( | ||
children | ||
) : ( | ||
<Text {...childrenWrapperProps}>{children}</Text> |
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.
adds childrenWrapperProps
here
|
||
<div> | ||
{title && ( | ||
<Text variant={TextVariant.bodyLgMedium} {...titleProps}> |
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.
Removes static data-testid from title to enable specificity of test id during implementation
@@ -1036,6 +1036,9 @@ export default function PrepareSwapPage({ | |||
? t('swapTokenVerifiedOn1SourceTitle') | |||
: t('swapTokenAddedManuallyTitle') | |||
} | |||
titleProps={{ |
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.
Here we are removing the static data-testid from the BannerBase
component and utilizing titleProps
to assign one at implementation
children: { | ||
control: 'text', | ||
}, | ||
childrenProps: { | ||
control: 'object', | ||
}, | ||
action: { |
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.
This shouldn't be here remove
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.
LGTM! I made some small updates to tests and updated the component to remove the static test id and a class name that I don't think we needed. Just need tests to pass. Thanks for your contribution @dhruvv173
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.
Nice! LGTM. Just looks like we need to sort out some e2e tests that are failing
…se. Also updating snapshot of ConfirmTransaction page
9c8e160
Explanation
Screenshots/Screencaps
Before
before.mp4
After
after.mp4
Manual Testing Steps
yarn storybook
on this branchBannerBase
yarn jest ui/components/ocmponent-library/banner-base
Pre-merge author checklist
Pre-merge reviewer checklist
If further QA is required (e.g. new feature, complex testing steps, large refactor), add the
Extension QA Board
label.In this case, a QA Engineer approval will be be required.