[No QA][TS migration] Migrate react-native-permissions mock#35886
Conversation
| notificationCenter: true, | ||
| }; | ||
|
|
||
| const checkNotifications: jest.Mock<{status: Results; settings: typeof notificationSettings}> = jest.fn(() => ({ |
There was a problem hiding this comment.
Extract {status: Results; settings: typeof notificationSettings} to a separate type and use it here
| settings: notificationSettings, | ||
| })); | ||
|
|
||
| const requestNotifications: jest.Mock<{status: Results; settings: typeof notificationSettings}> = jest.fn((options: Record<string, string>) => ({ |
| status: RESULTS.GRANTED, | ||
| settings: Object.keys(options) | ||
| .filter((option: string) => notificationOptions.includes(option)) | ||
| .reduce((acc: ResultsCollection, option: string) => ({...acc, [option]: true}), { |
There was a problem hiding this comment.
| .reduce((acc: ResultsCollection, option: string) => ({...acc, [option]: true}), { | |
| .reduce((acc: NotificationSettings, option: string) => ({...acc, [option]: true}), { |
| type Results = ValueOf<typeof RESULTS>; | ||
| type ResultsCollection = Record<string, Results>; | ||
| type NotificationSettings = Record<string, boolean>; | ||
| type Notification = {status: Results; settings: typeof notificationSettings}; |
There was a problem hiding this comment.
| type Notification = {status: Results; settings: typeof notificationSettings}; | |
| type Notification = {status: Results; settings: NotificationSettings}; |
| @@ -0,0 +1 @@ | |||
| declare module 'react-native-permissions/dist/commonjs/permissions'; | |||
There was a problem hiding this comment.
Because of this declaration {PERMISSIONS, RESULTS} are of type any, is this expected?
There was a problem hiding this comment.
@blazejkustra This was not expected. I have updated the module declaration.
Please have a look, thank you!
| @@ -0,0 +1,77 @@ | |||
| import {PERMISSIONS, RESULTS} from 'react-native-permissions/dist/commonjs/permissions'; | |||
There was a problem hiding this comment.
Would that work?
| import {PERMISSIONS, RESULTS} from 'react-native-permissions/dist/commonjs/permissions'; | |
| import {PERMISSIONS, RESULTS} from 'react-native-permissions'; |
There was a problem hiding this comment.
No, importing these from react-native-permissions directly are breaking the unit tests, this is the reason why I've added this module declaration.
I've tried that on this commit: 1fdb8fd but had to revert it
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
aimane-chnaif
left a comment
There was a problem hiding this comment.
Looks good! Please merge main
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #25255 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
@ruben-rebelo Is this internal testing? |
|
🚀 Deployed to staging by https://github.com/jasperhuangg in version: 1.4.43-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.43-20 🚀
|
Details
[TS migration] Migrate react-native-permissions mock to typescript
Fixed Issues
$ #25255
PROPOSAL: N/A
Tests
Verify that no errors appear in the JS console
Run Unit tests works as before
Offline tests
N/A
QA Steps
Same as in the Tests section.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/a
Android: mWeb Chrome
N/a
iOS: Native
N/a
iOS: mWeb Safari
N/a
MacOS: Chrome / Safari
N/a
MacOS: Desktop
N/a