-
Notifications
You must be signed in to change notification settings - Fork 2.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: mock animation completion callback to trigger setState #17956
fix: mock animation completion callback to trigger setState #17956
Conversation
cc @mountiny |
@@ -142,7 +142,7 @@ class SidebarLinks extends React.Component { | |||
|
|||
return ( | |||
<View | |||
accessibilityElementsHidden={!this.props.isFocused} | |||
isFocused={this.props.isFocused} |
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.
Is all this necessary for mocking jest? I can't imagine it is, so it's just strange to see these changes in this PR
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.
accessibilityElementsHidden
was used before both for checking the value in tests and probably to mock the navigation behavior of accessibility (see: https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/stack/src/views/Stack/CardContainer.tsx#L242). If we still want to check if this route is focused or not, we need to keep a way of doing it. If you know a better way to do it, it would be great 😅
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.
OK, that explains why accessibilityElementsHidden
is there in the first place, but I guess I am still not quite understanding why it needs to change from accessibilityElementsHidden
to isFocused
. We can't keep the original way, or it's not desired for some reason?
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.
Hmm accessibilityElementsHidden
should not be needed anymore, but we can keep it. I just wanted a prop that does not do anything so I didn't destroy any of the behaviors, but since the screen is not focused when this prop is set, it should all work just fine.
tests/ui/UnreadIndicatorsTest.js
Outdated
@@ -31,6 +31,14 @@ jest.setTimeout(30000); | |||
|
|||
jest.mock('../../src/libs/Notification/LocalNotification'); | |||
|
|||
// we need to mock it for the ReportScreen to update its state immediately for tests to pass |
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.
Please be sure to capitalize the first word in every comment. Also, this comment is only a partial explanation of why the mocking is necessary. Can you please improve it so that it also says why the state isn't updating immediately in the first place and why the tests fail when it doesn't update immediately?
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 saw that we have a special file for adding the mocks to react-native
, so I'll move this mock there. Should I add a comment there or maybe just in the PR?
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.
Ah, thanks for moving it to the __mocks__
folder! Can you please add the comment there in the file?
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.
@WoLewicki Thanks for raising this PR, I agree with @tgolen comments.
Could you also always make sure you link the navigation refactor issue this is related to? I know this is a leftover from the previous PR but it would be great to have an issue linked for context. Thank you!
dont forget to fill in the checklist too and note why you are not adding any screenshots
Reviewer ChecklistThis is handling jest tests to work with the new Navigation architecture so there is nothing to test in the App
Screenshots/VideosNo screenshots, PR is changing automated tests. WebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
Ok, I answered the comments and updated the code and description. Could you take another look? |
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.
Thank you @WoLewicki!
All yours @tgolen
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.
Looks great. Thank you!
🚀 Deployed to staging by https://github.com/tgolen in version: 1.3.25-1 🚀
|
@mountiny @WoLewicki @tgolen Hello! Any QA needed for this PR? |
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.25-8 🚀
|
Details
Fix the tests for navigation refactor by mocking
InteractionManager
'srunAfterInteractions
method so it triggers it's callback immediately, making the state change work correctly and showing the tested content. This method would normally be triggered after the native animation is completed, we would have to mock waiting for the animation end and more state changes, which I couldn't have achieved despite testing many approaches, so it seems easier to just run the callback immediately.Fixed Issues
Related to #11768
PROPOSAL: GH_LINK_ISSUE(COMMENT)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
There are no screenshots since those are jest tests, so there is no visual output for those kind of issues.
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android