-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[NoQA] Tests for group chat name #40658
Conversation
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.
- Fix ts errors
- Add unit test for the following case:
- getGroupChatName called with report id only and that report does not have a name
tests/ui/GroupChatNameTests.tsx
Outdated
jest.mock('../../src/libs/Notification/LocalNotification'); | ||
jest.mock('../../src/components/Icon/Expensicons'); |
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.
jest.mock('../../src/libs/Notification/LocalNotification'); | |
jest.mock('../../src/components/Icon/Expensicons'); |
Not needed
tests/ui/GroupChatNameTests.tsx
Outdated
// Connect to Pusher | ||
PusherConnectionManager.init(); | ||
Pusher.init({ | ||
appKey: CONFIG.PUSHER.APP_KEY, | ||
cluster: CONFIG.PUSHER.CLUSTER, | ||
authEndpoint: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/AuthenticatePusher?`, | ||
}); |
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.
// Connect to Pusher | |
PusherConnectionManager.init(); | |
Pusher.init({ | |
appKey: CONFIG.PUSHER.APP_KEY, | |
cluster: CONFIG.PUSHER.CLUSTER, | |
authEndpoint: `${CONFIG.EXPENSIFY.DEFAULT_API_ROOT}api/AuthenticatePusher?`, | |
}); |
Not needed
tests/ui/GroupChatNameTests.tsx
Outdated
let reportActionCreatedDate: string; | ||
let reportAction2CreatedDate: 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.
let reportActionCreatedDate: string; | |
let reportAction2CreatedDate: string; |
We don't need report actions
Any updates on this? |
Will update this by tomorrow. |
tests/utils/LHNTestUtils.tsx
Outdated
participantAccountIDs.forEach((id) => { | ||
participants[id] = { | ||
hidden: false, | ||
role: id === 1 ? 'admin' : 'member', |
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.
Do we need to set the role here?
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.
There should be at least one admin, so it seems good to have the role set.
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.
This would affect other tests that uses this util function. Add the admin participant if needed only on the group test file
tests/utils/LHNTestUtils.tsx
Outdated
const lastVisibleActionCreated = DateUtils.getDBTime(Date.now() - millisecondsInThePast); | ||
|
||
const participants: Record<number, Participant> = {}; |
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.
const participants: Record<number, Participant> = {}; | |
const participants: Participants = {}; |
NAB
tests/utils/LHNTestUtils.tsx
Outdated
participantAccountIDs.forEach((id) => { | ||
participants[id] = { | ||
hidden: false, | ||
role: shouldAddParticipantRole ? (id === 1 ? 'admin' : 'member') : null, |
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.
This is still not valid for a util function. Not all participants are expected to have the admin using account id 1. Instead of shouldAddParticipantRole
use a param that's an array and tells us the account ids of the admins.
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
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.
Tests look nice and thorough! Thanks! Spotted an improvement.
tests/ui/GroupChatNameTests.tsx
Outdated
...jest.requireActual<typeof Animated>('react-native-reanimated/mock'), | ||
createAnimatedPropAdapter: jest.fn, | ||
useReducedMotion: 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.
Lines 48 to 50 in 957b5ec
## Mocking `node_modules`, user modules, and what belongs in `jest/setup.ts` | |
If you need to mock a library that exists in `node_modules` then add it to the `__mocks__` folder in the root of the project. More information about this [here](https://jestjs.io/docs/manual-mocks#mocking-node-modules). If you need to mock an individual library you should create a mock module in a `__mocks__` subdirectory adjacent to the library as explained [here](https://jestjs.io/docs/manual-mocks#mocking-user-modules). However, keep in mind that when you do this you also must manually require the mock by calling something like `jest.mock('../../src/libs/Log');` at the top of an individual test file. If every test in the app will need something to be mocked that's a good case for adding it to `jest/setup.ts`, but we should generally avoid adding user mocks or `node_modules` mocks to this file. Please use the `__mocks__` subdirectories wherever appropriate. |
Can any of these be moved into __mocks__
or no?
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.
Can you help with this? I couldn't get how we can include these in __mocks__
.
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.
What have you tried?
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.
@marcaaron I don't think these could be added to __mocks__
.
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's fine, but can we please add some explanation about why?
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.
Using __mocks__
for @react-native-reanimated
.
For LogBox
, I tried the below but it didn't work:
const mock = {
/* eslint-disable-next-line @typescript-eslint/naming-convention */
__esModule: true,
default: {
ignoreLogs: jest.fn(),
ignoreAllLogs: jest.fn(),
},
};
export default mock;
In @react-navigation/native
, it seems we can't move to __mocks__
because transitionEndCB
is needed in the test file.
@ShridharGoel Can you please address the review comments above and resolve the conflicts |
What's the latest here? |
Any idea what can be causing this? All tests are passing when trying one by one locally.
|
After running test A and navigating to the report, we will go into the Moving the |
Thanks, this wasn't happening earlier - looks like some flow changed in the past few days. |
@ShridharGoel Can you please fix the lint errors |
Prettier and conflicts ^ |
Updated. |
@marcaaron Can you check this? |
Yes sorry, I have been OOO. Looking now. |
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.
LGTM thanks for the discussion and changes.
Sorry this PR broke some workflows on main. Please raise a new PR and merge |
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.4.86-0 🚀
|
1 similar comment
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.4.86-0 🚀
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 1.4.86-0 🚀
|
🚀 Deployed to production by https://github.com/AndrewGable in version: 9.0.0-9 🚀
|
Details
Tests for group chat name.
Fixed Issues
$ #40189
PROPOSAL: #40189 (comment)
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.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 and/or tagged@Expensify/design
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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop