Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920
Open
chicio wants to merge 1 commit intofacebook:mainfrom
Open
Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920chicio wants to merge 1 commit intofacebook:mainfrom
chicio wants to merge 1 commit intofacebook:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This PR fixes a bug I found while exploring the codebase in the
Componentsfolder.AccessibilityInfoexposes the methodprefersCrossFadeTransitions. In the android branch,Promise.resolve(false)as return value was creating a new unrelated promise that never calls the resolve function provided by the promise executor constructor, so it was hangs indefinitely.This means that if a user calls this method on android without any
Platform.OS === iosguard, it will result in a unresolved promise.I fixed the bug by aligning the implementation of
prefersCrossFadeTransitionsto the one of other methods (eg.isBoldTextEnabled).I also added the tests to avoid regression, and additionally verify that the iOS method is doing what we are expecting (in both cases for when
NativeAccessibilityManagerIOS.getCurrentPrefersCrossFadeTransitionsStateis available or not).The mock of the
Platformobject has been done the same way I saw while doing another contribution in thePressability-test(see #55378 ).I noticed the same bug in
isHighTextContrastEnabledandisDarkerSystemColorsEnabledand I plan/would like to address them in follow-up PRs (and adding all the missing tests).Changelog:
[ANDROID] [FIXED] - Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved (never ending) promise
Test Plan:
This fix has been develop in TDD. I first added a failing test to reproduce that the android branch of the
prefersCrossFadeTransitionsmethod was acting as described above (resulting in failure due to jest timeout because the promise was not returning). Then I applied the fix, and finally added also the test for the iOS counterpart.One final note:
AccessibilityInfois mocked globally insetup.js(viasetupFilesin the Jest preset).So to test the real implementation I had to use
jest.unmock(pattern that I saw is already used in other component test files like View-test.js and TextInput-test.js).