diff --git a/src/CONST.ts b/src/CONST.ts
index 6de65ae74f63..d68c8162f685 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -342,6 +342,7 @@ const EMAIL = {
SVFG: 'svfg@expensify.com',
EXPENSIFY_EMAIL_DOMAIN: '@expensify.com',
EXPENSIFY_TEAM_EMAIL_DOMAIN: '@team.expensify.com',
+ TEAM: 'team@expensify.com',
MANAGER_MCTEST: 'manager_mctest@expensify.com',
};
@@ -3522,6 +3523,7 @@ const CONST = {
EMAIL.RECEIPTS,
EMAIL.STUDENT_AMBASSADOR,
EMAIL.SVFG,
+ EMAIL.TEAM,
EMAIL.MANAGER_MCTEST,
] as string[],
get EXPENSIFY_ACCOUNT_IDS() {
diff --git a/tests/ui/NewChatPageTest.tsx b/tests/ui/NewChatPageTest.tsx
index 837f59bf3af4..d89043916392 100644
--- a/tests/ui/NewChatPageTest.tsx
+++ b/tests/ui/NewChatPageTest.tsx
@@ -1,5 +1,5 @@
import * as NativeNavigation from '@react-navigation/native';
-import {act, fireEvent, render, screen} from '@testing-library/react-native';
+import {act, fireEvent, render, screen, waitFor, within} from '@testing-library/react-native';
import React from 'react';
import {SectionList} from 'react-native';
import Onyx from 'react-native-onyx';
@@ -9,12 +9,25 @@ import OptionsListContextProvider from '@components/OptionListContextProvider';
import ScreenWrapper from '@components/ScreenWrapper';
import {translateLocal} from '@libs/Localize';
import NewChatPage from '@pages/NewChatPage';
+import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {NativeNavigationMock} from '../../__mocks__/@react-navigation/native';
import {fakePersonalDetails} from '../utils/LHNTestUtils';
+import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
import waitForBatchedUpdatesWithAct from '../utils/waitForBatchedUpdatesWithAct';
jest.mock('@react-navigation/native');
+jest.mock('@src/libs/Navigation/navigationRef');
+
+const wrapper = ({children}: {children: React.ReactNode}) => (
+
+
+
+ {children}
+
+
+
+);
describe('NewChatPage', () => {
beforeAll(() => {
@@ -24,19 +37,15 @@ describe('NewChatPage', () => {
jest.spyOn(NativeNavigation, 'useRoute').mockReturnValue({key: '', name: ''});
});
+ afterEach(async () => {
+ jest.clearAllMocks();
+ await Onyx.clear();
+ await waitForBatchedUpdates();
+ });
+
it('should scroll to top when adding a user to the group selection', async () => {
await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, fakePersonalDetails);
- render(
-
-
-
-
-
-
-
-
- ,
- );
+ render(, {wrapper});
await waitForBatchedUpdatesWithAct();
await act(() => {
(NativeNavigation as NativeNavigationMock).triggerTransitionEnd();
@@ -49,4 +58,37 @@ describe('NewChatPage', () => {
expect(spy).toHaveBeenCalledWith(expect.objectContaining({itemIndex: 0}));
}
});
+
+ describe('should not display "Add to group" button on expensify emails', () => {
+ const excludedGroupEmails = CONST.EXPENSIFY_EMAILS.filter((value) => value !== CONST.EMAIL.CONCIERGE && value !== CONST.EMAIL.NOTIFICATIONS).map((email) => [email]);
+
+ it.each(excludedGroupEmails)('%s', async (email) => {
+ // Given that a personal details list is initialized in Onyx
+ await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, {
+ // eslint-disable-next-line @typescript-eslint/naming-convention
+ '1': {accountID: 1, login: email},
+ });
+
+ // And NewChatPage is opened
+ render(, {wrapper});
+ await waitForBatchedUpdatesWithAct();
+ await act(() => {
+ (NativeNavigation as NativeNavigationMock).triggerTransitionEnd();
+ });
+
+ // And email is entered into the search input
+ const input = screen.getByTestId('selection-list-text-input');
+ fireEvent.changeText(input, email);
+
+ // And waited for the user option to appear
+ await waitFor(() => {
+ expect(screen.getByLabelText(email)).toBeOnTheScreen();
+ });
+
+ // Then "Add to group" button should not appear
+ const userOption = screen.getByLabelText(email);
+ const addButton = within(userOption).queryByText(translateLocal('newChatPage.addToGroup'));
+ expect(addButton).not.toBeOnTheScreen();
+ });
+ });
});