-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile] Use BlockEdit component when testing component rendering #29569
Conversation
BlockEdit adds the block edit context, which could be required by some parts of an edit component when it's rendered in a unit test.
Size Change: 0 B Total Size: 1.4 MB ℹ️ View Unchanged
|
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 confirmed that this fixes the tests in #29309 🥇 .
I've just pushed a couple of changes to debug the |
Looks like the changes have fixed the workflow so I'm going to make a separate PR for those and then update this one. |
Looks good. Can we merge this one and follow up with anything else? |
I'd rather merge the changes in the e2e tests in another PR I've just created to prevent confusion. Once it's approved I'll merge all of them and then we can update your branch. |
@guarani I assigned you as a reviewer of the PR I had to create to fix the e2e tests oft this one. Let me know if you have some time to check it, if not we could find someone else to take a look, thanks 🙇 ! |
Description
Fixes #29442.
Add extra logic to some of the native unit tests that renders blocks:
BlockEdit
component that will render the block that we want to testThis way, by rendering the edit components from the
BlockEdit
component, we add the block edit context that could be required by other components when they're rendered.In fact, this is the case when the incoming changes from this PR would be merged, the
RichText
editor component will require theclientID
property that is exposed from a new context that is rendered inBlockEdit
component.Caveats
My initial approach was to apply this change to all the native unit tests that render edit components but didn't work.
For example in the
File
block, one of the tests triggers theonLayout
handler. If we render theBlockEdit
component, we don't have access to the instance required to trigger that handler so the test fails.I spent some time on finding an alternative but I didn't find any that fits easily. One option I tried was using the
enzyme
library but when rendering the component via themount
function,AztecView
generates multiple errors. Shallow rendering is not enough because the required handler that we want to trigger is in the children.Probably the best option would be to integrate a more complete library like
@testing-library/react-native
, that provides a lot interesting functionality that would make easier to do native unit tests.How has this been tested?
Test with latest changes from
trunk
branchnpm run native test
.Test with changes from PR
try/block-context-cleanup
from the PR.git cherry-pick -n 742eb696556f87707aca0517656d7464ab543bdc
.npm run native test
.Screenshots
N/A
Types of changes
Bug fix
Checklist: