From 5669518bf25d4ada19c6b2933201b44ca43a904d Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Mon, 2 Dec 2024 18:02:44 +0700 Subject: [PATCH] add test for unread chat --- tests/ui/LHNItemsPresence.tsx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/ui/LHNItemsPresence.tsx b/tests/ui/LHNItemsPresence.tsx index 9adc406fb4c3..4e5674a64f40 100644 --- a/tests/ui/LHNItemsPresence.tsx +++ b/tests/ui/LHNItemsPresence.tsx @@ -1,10 +1,12 @@ import {screen} from '@testing-library/react-native'; import type {ComponentType} from 'react'; +import type {TextStyle} from 'react-native'; import Onyx from 'react-native-onyx'; import type {OnyxMultiSetInput} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import * as Localize from '@libs/Localize'; +import FontUtils from '@styles/utils/FontUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetailsList, Report, ViolationName} from '@src/types/onyx'; @@ -73,9 +75,10 @@ const createReport = ( messageCount = 1, chatType: ValueOf | undefined = undefined, policyID: string = CONST.POLICY.ID_FAKE, + isUnread = false, ) => { return { - ...LHNTestUtils.getFakeReport(participants, messageCount), + ...LHNTestUtils.getFakeReport(participants, messageCount, isUnread), isPinned, chatType, policyID, @@ -246,6 +249,31 @@ describe('SidebarLinksData', () => { // And a green dot icon should be shown expect(screen.getByTestId('GBR Icon')).toBeOnTheScreen(); }); + + it('should display the unread report in the focuse mode with the bold text', async () => { + // When the SidebarLinks are rendered. + LHNTestUtils.getDefaultRenderedSidebarLinks(); + const report: Report = { + ...createReport(undefined, undefined, undefined, undefined, undefined, true), + hasOutstandingChildRequest: true, + }; + + await initializeState({ + [`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report, + }); + + await waitForBatchedUpdatesWithAct(); + + // And the user is in focus mode + await Onyx.merge(ONYXKEYS.NVP_PRIORITY_MODE, CONST.PRIORITY_MODE.GSD); + + // The report should appear in the sidebar because it's unread + expect(getOptionRows()).toHaveLength(1); + + // And the text is bold + const displayNameText = getDisplayNames()?.at(0); + expect((displayNameText?.props?.style as TextStyle)?.fontWeight).toBe(FontUtils.fontWeight.bold); + }); }); describe('Report that should NOT be included in the LHN', () => {