[NoQA] Tests for group chat name#40658
Conversation
s77rt
left a comment
There was a problem hiding this comment.
- 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.
| 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.
| // 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.
| 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.
There should be at least one admin, so it seems good to have the role set.
There was a problem hiding this comment.
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
| function getFakeReport(participantAccountIDs = [1, 2], millisecondsInThePast = 0, isUnread = false, shouldAddParticipantRole: boolean = false): Report { | ||
| const lastVisibleActionCreated = DateUtils.getDBTime(Date.now() - millisecondsInThePast); | ||
|
|
||
| const participants: Record<number, Participant> = {}; |
There was a problem hiding this comment.
| 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.
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 |
marcaaron
left a comment
There was a problem hiding this comment.
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.
Lines 48 to 50 in 957b5ec
Can any of these be moved into __mocks__ or no?
There was a problem hiding this comment.
Can you help with this? I couldn't get how we can include these in __mocks__.
There was a problem hiding this comment.
@marcaaron I don't think these could be added to __mocks__.
There was a problem hiding this comment.
Ok that's fine, but can we please add some explanation about why?
There was a problem hiding this comment.
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. |
marcaaron
left a comment
There was a problem hiding this comment.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.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 and/or tagged@Expensify/designso 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop