Commit 8fbf2fa
Fix AccessibilityInfo.isDarkerSystemColorsEnabled unresolved promise (facebook#56019)
Summary:
This PR fixes a bug in the `AccessibilityInfo` component. This is a follow up of the work I started with the PR I opened last week that has been already merged facebook#55920.
`AccessibilityInfo` exposes the method `isDarkerSystemColorsEnabled`. 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 hangs indefinitely.
This means that if a user calls this method on android without any `Platform.OS === 'ios'` guard, it will result in a unresolved promise.
I fixed the bug in the same way I fixed the one in the PR above: by aligning the implementation of `isDarkerSystemColorsEnabled` to 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.getCurrentDarkerSystemColorsState` is available or not).
The mock of the Platform object has been done the same way I saw while doing another contribution in the Pressability-test (see facebook#55378 ).
## Changelog:
[GENERAL] [FIXED] - Fix AccessibilityInfo.isDarkerSystemColorsEnabled unresolved (never ending) promise
Pull Request resolved: facebook#56019
Test Plan: This fix, like the one in the previous PR, was develop using TDD. I first added a failing test to reproduce that the android branch of the `isDarkerSystemColorsEnabled` method 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.
Reviewed By: cortinico
Differential Revision: D95931847
Pulled By: vzaidman
fbshipit-source-id: 94cd088b286f1b724f0feeb20670b501a458c7741 parent f1ac82c commit 8fbf2fa
2 files changed
Lines changed: 66 additions & 6 deletions
File tree
- packages/react-native/Libraries/Components/AccessibilityInfo
- __tests__
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
260 | | - | |
| 259 | + | |
| 260 | + | |
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
| |||
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
| 37 | + | |
27 | 38 | | |
28 | 39 | | |
29 | 40 | | |
| |||
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
| 55 | + | |
44 | 56 | | |
45 | 57 | | |
46 | 58 | | |
| |||
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
94 | 152 | | |
95 | 153 | | |
96 | 154 | | |
| 155 | + | |
| 156 | + | |
97 | 157 | | |
98 | 158 | | |
99 | 159 | | |
| |||
0 commit comments