diff --git a/src/pages/Debug/Report/DebugReportActions.tsx b/src/pages/Debug/Report/DebugReportActions.tsx index e86befd81217..792df8bfd561 100644 --- a/src/pages/Debug/Report/DebugReportActions.tsx +++ b/src/pages/Debug/Report/DebugReportActions.tsx @@ -8,6 +8,7 @@ import useDebouncedState from '@hooks/useDebouncedState'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; +import {getHeaderMessageForNonUserList} from '@libs/OptionsListUtils'; import Parser from '@libs/Parser'; import {getOriginalMessage, getReportActionMessage, getReportActionMessageText, getSortedReportActionsForDisplay, isCreatedAction} from '@libs/ReportActionsUtils'; import {canUserPerformWriteAction, formatReportLastMessageText} from '@libs/ReportUtils'; @@ -85,6 +86,7 @@ function DebugReportActions({reportID}: DebugReportActionsProps) { listItemTitleStyles={styles.fontWeightNormal} textInputValue={searchValue} textInputLabel={translate('common.search')} + headerMessage={getHeaderMessageForNonUserList(searchedReportActions.length > 0, debouncedSearchValue)} onChangeText={setSearchValue} onSelectRow={(item) => Navigation.navigate(ROUTES.DEBUG_REPORT_ACTION.getRoute(reportID, item.reportActionID))} ListItem={RadioListItem} diff --git a/tests/ui/DebugReportActionsTest.tsx b/tests/ui/DebugReportActionsTest.tsx new file mode 100644 index 000000000000..82dcab972bb2 --- /dev/null +++ b/tests/ui/DebugReportActionsTest.tsx @@ -0,0 +1,76 @@ +import {fireEvent, render, screen} from '@testing-library/react-native'; +import Onyx from 'react-native-onyx'; +import {LocaleContextProvider} from '@components/LocaleContextProvider'; +import OnyxProvider from '@components/OnyxProvider'; +import type Navigation from '@libs/Navigation/Navigation'; +import DebugReportActions from '@pages/Debug/Report/DebugReportActions'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import type {Policy, Report, ReportAction} from '@src/types/onyx'; +import createRandomPolicy from '../utils/collections/policies'; +import createRandomReportAction from '../utils/collections/reportActions'; +import createRandomReport from '../utils/collections/reports'; +import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct'; + +jest.mock('@react-navigation/native', () => { + const actualNav = jest.requireActual('@react-navigation/native'); + return { + ...actualNav, + useIsFocused: () => true, + useFocusEffect: jest.fn(), + }; +}); + +jest.mock('@src/libs/Navigation/Navigation', () => ({ + navigate: jest.fn(), +})); + +describe('DebugReportActions', () => { + beforeAll(() => { + Onyx.init({ + keys: ONYXKEYS, + safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS], + }); + }); + + afterEach(async () => { + await Onyx.clear(); + }); + + it('should show no results message when search is empty', async () => { + const policyID = '12'; + const reportID = '1'; + const reportActionID = '123'; + const policy: Policy = createRandomPolicy(Number(policyID)); + const report: Report = {...createRandomReport(Number(reportID)), chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, policyID}; + const reportActionL: ReportAction = { + ...createRandomReportAction(Number(reportActionID)), + reportID, + message: { + html: '', + text: '', + type: '', + }, + }; + await Onyx.merge(`${ONYXKEYS.NVP_PREFERRED_LOCALE}`, 'en'); + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { + [reportActionID]: reportActionL, + }); + + render( + + + + + , + ); + + await waitForBatchedUpdatesWithAct(); + + const input = screen.getByTestId('selection-list-text-input'); + fireEvent.changeText(input, 'testtesttesttest'); + expect(await screen.findByText('No results found')).toBeOnTheScreen(); + }); +});