-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[No QA][TS migration] Migrate react-native-permissions mock #35886
[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>) => ({ |
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.
Same
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this declaration {PERMISSIONS, RESULTS}
are of type any, is this expected?
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.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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] |
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 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.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
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