-
-
+ {chatImage ? (
+
+ ) : (
+
+ )}
+
(chat?.isGroup ? openGroupChatDetails() : null)}
+ className={styles.userDetails}
+ >
{chatTitle}
{chatSubtitle}
@@ -274,6 +372,13 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
)}
+ {message.media && (
+
+ )}
{message.messageContent}
@@ -294,7 +399,16 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
}}
data-testid="replyBtn"
>
- Reply
+ {t('reply')}
+
+ {
+ setEditMessage(message);
+ setNewMessage(message.messageContent);
+ }}
+ data-testid="replyToMessage"
+ >
+ Edit
@@ -317,6 +431,13 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
>
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.module.css b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.module.css
deleted file mode 100644
index 3795e402fa..0000000000
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.module.css
+++ /dev/null
@@ -1,9 +0,0 @@
-.userData {
- height: 400px;
- overflow-y: scroll;
- overflow-x: hidden !important;
-}
-
-.modalContent {
- width: 530px;
-}
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx
new file mode 100644
index 0000000000..ccf23a882b
--- /dev/null
+++ b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx
@@ -0,0 +1,4036 @@
+import React from 'react';
+import {
+ act,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@testing-library/react';
+import { MockedProvider } from '@apollo/react-testing';
+import { I18nextProvider } from 'react-i18next';
+import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
+import { BrowserRouter } from 'react-router-dom';
+import { Provider } from 'react-redux';
+import { store } from 'state/store';
+import i18nForTest from 'utils/i18nForTest';
+import Chat from '../../../screens/UserPortal/Chat/Chat';
+import {
+ CREATE_CHAT,
+ MARK_CHAT_MESSAGES_AS_READ,
+ MESSAGE_SENT_TO_CHAT,
+} from 'GraphQl/Mutations/OrganizationMutations';
+import {
+ CHATS_LIST,
+ CHAT_BY_ID,
+ GROUP_CHAT_LIST,
+ UNREAD_CHAT_LIST,
+} from 'GraphQl/Queries/PlugInQueries';
+import useLocalStorage from 'utils/useLocalstorage';
+import { vi } from 'vitest';
+const { setItem } = useLocalStorage();
+
+/**
+ * Unit tests for the Create Direct Chat Modal functionality in the User Portal
+ *
+ * These tests cover the following scenarios:
+ * 1. Opening and closing the create new direct chat modal, ensuring proper UI elements
+ * like dropdown, search input, and submit button are displayed and functional.
+ * 2. Creating a new direct chat, which includes testing the interaction with the add button,
+ * submitting the chat, and closing the modal.
+ *
+ * Tests involve interacting with the modal's UI elements, performing actions like
+ * opening the dropdown, searching for users, clicking on the submit button, and closing
+ * the modal. GraphQL mocks are used for testing chat-related queries and mutations,
+ * ensuring that the modal behaves as expected when interacting with the GraphQL API.
+ */
+
+const UserConnectionListMock = [
+ {
+ request: {
+ query: USERS_CONNECTION_LIST,
+ variables: {
+ firstName_contains: '',
+ lastName_contains: '',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ firstName: 'Deanne',
+ lastName: 'Marks',
+ image: null,
+ _id: '6589389d2caa9d8d69087487',
+ email: 'testuser8@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ organizationsBlockedBy: [],
+ joinedOrganizations: [
+ {
+ _id: '6537904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Queens',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Coffee Street',
+ line2: 'Apartment 501',
+ postalCode: '11427',
+ sortingCode: 'ABC-133',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6637904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Staten Island',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 church Street',
+ line2: 'Apartment 499',
+ postalCode: '10301',
+ sortingCode: 'ABC-122',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6737904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Brooklyn',
+ countryCode: 'US',
+ dependentLocality: 'Sample Dependent Locality',
+ line1: '123 Main Street',
+ line2: 'Apt 456',
+ postalCode: '10004',
+ sortingCode: 'ABC-789',
+ state: 'NY',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6437904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Bronx',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Random Street',
+ line2: 'Apartment 456',
+ postalCode: '10451',
+ sortingCode: 'ABC-123',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ ],
+ __typename: 'User',
+ },
+ appUserProfile: {
+ _id: '64378abd85308f171cf2993d',
+ adminFor: [],
+ isSuperAdmin: false,
+ createdOrganizations: [],
+ createdEvents: [],
+ eventAdmin: [],
+ __typename: 'AppUserProfile',
+ },
+ __typename: 'UserData',
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USERS_CONNECTION_LIST,
+ variables: {
+ firstName_contains: 'Disha',
+ lastName_contains: '',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ firstName: 'Deanne',
+ lastName: 'Marks',
+ image: null,
+ _id: '6589389d2caa9d8d69087487',
+ email: 'testuser8@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ organizationsBlockedBy: [],
+ joinedOrganizations: [
+ {
+ _id: '6537904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Queens',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Coffee Street',
+ line2: 'Apartment 501',
+ postalCode: '11427',
+ sortingCode: 'ABC-133',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6637904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Staten Island',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 church Street',
+ line2: 'Apartment 499',
+ postalCode: '10301',
+ sortingCode: 'ABC-122',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6737904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Brooklyn',
+ countryCode: 'US',
+ dependentLocality: 'Sample Dependent Locality',
+ line1: '123 Main Street',
+ line2: 'Apt 456',
+ postalCode: '10004',
+ sortingCode: 'ABC-789',
+ state: 'NY',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6437904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Bronx',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Random Street',
+ line2: 'Apartment 456',
+ postalCode: '10451',
+ sortingCode: 'ABC-123',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ ],
+ __typename: 'User',
+ },
+ appUserProfile: {
+ _id: '64378abd85308f171cf2993d',
+ adminFor: [],
+ isSuperAdmin: false,
+ createdOrganizations: [],
+ createdEvents: [],
+ eventAdmin: [],
+ __typename: 'AppUserProfile',
+ },
+ __typename: 'UserData',
+ },
+ ],
+ },
+ },
+ },
+];
+
+const MESSAGE_SENT_TO_CHAT_MOCK = [
+ {
+ request: {
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: null,
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f1364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ type: 'STRING',
+ replyTo: null,
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: '2',
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f1df364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: '1',
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f13603ac4697a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+];
+
+const CHAT_BY_ID_QUERY_MOCK = [
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '1',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ createdAt: '2345678903456',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '1',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ createdAt: '2345678903456',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const UNREAD_CHAT_LIST_QUERY_MOCK = [
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const GROUP_CHAT_BY_USER_ID_QUERY_MOCK = [
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const CHATS_LIST_MOCK = [
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844ghjefc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: 'ujhgtrdtyuiop',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ media: null,
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+];
+
+const GROUP_CHAT_BY_ID_QUERY_MOCK = [
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const CREATE_CHAT_MUTATION_MOCK = [
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ organizationId: undefined,
+ userIds: ['1', '6589389d2caa9d8d69087487'],
+ isGroup: false,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ media: null,
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const MARK_CHAT_MESSAGES_AS_READ_MOCK = [
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: null,
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: null,
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: null,
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: null,
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: '1',
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: '1',
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+];
+async function wait(ms = 100): Promise
{
+ await act(() => {
+ return new Promise((resolve) => {
+ setTimeout(resolve, ms);
+ });
+ });
+}
+
+describe('Testing Create Direct Chat Modal [User Portal]', () => {
+ window.HTMLElement.prototype.scrollIntoView = vi.fn();
+
+ Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ value: vi.fn().mockImplementation((query) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: vi.fn(), // Deprecated
+ removeListener: vi.fn(), // Deprecated
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ dispatchEvent: vi.fn(),
+ })),
+ });
+
+ it('Open and close create new direct chat modal', async () => {
+ const mock = [
+ ...GROUP_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...UserConnectionListMock,
+ ...CHATS_LIST_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CREATE_CHAT_MUTATION_MOCK,
+ ...MARK_CHAT_MESSAGES_AS_READ_MOCK,
+ ...UNREAD_CHAT_LIST_QUERY_MOCK,
+ ...GROUP_CHAT_BY_USER_ID_QUERY_MOCK,
+ ];
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const dropdown = await screen.findByTestId('dropdown');
+ expect(dropdown).toBeInTheDocument();
+ fireEvent.click(dropdown);
+ const newDirectChatBtn = await screen.findByTestId('newDirectChat');
+ expect(newDirectChatBtn).toBeInTheDocument();
+ fireEvent.click(newDirectChatBtn);
+
+ const submitBtn = await screen.findByTestId('submitBtn');
+ expect(submitBtn).toBeInTheDocument();
+
+ const searchInput = (await screen.findByTestId(
+ 'searchUser',
+ )) as HTMLInputElement;
+ expect(searchInput).toBeInTheDocument();
+
+ fireEvent.change(searchInput, { target: { value: 'Disha' } });
+
+ expect(searchInput.value).toBe('Disha');
+
+ fireEvent.click(submitBtn);
+
+ const closeButton = screen.getByRole('button', { name: /close/i });
+ expect(closeButton).toBeInTheDocument();
+
+ fireEvent.click(closeButton);
+ });
+
+ it('create new direct chat', async () => {
+ setItem('userId', '1');
+ const mock = [
+ ...GROUP_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...UserConnectionListMock,
+ ...CHATS_LIST_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CREATE_CHAT_MUTATION_MOCK,
+ ...MARK_CHAT_MESSAGES_AS_READ_MOCK,
+ ...UNREAD_CHAT_LIST_QUERY_MOCK,
+ ...GROUP_CHAT_BY_USER_ID_QUERY_MOCK,
+ ];
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const dropdown = await screen.findByTestId('dropdown');
+ expect(dropdown).toBeInTheDocument();
+ fireEvent.click(dropdown);
+ const newDirectChatBtn = await screen.findByTestId('newDirectChat');
+ expect(newDirectChatBtn).toBeInTheDocument();
+ fireEvent.click(newDirectChatBtn);
+
+ const addBtn = await screen.findAllByTestId('addBtn');
+ waitFor(() => {
+ expect(addBtn[0]).toBeInTheDocument();
+ });
+
+ fireEvent.click(addBtn[0]);
+
+ const closeButton = screen.getByRole('button', { name: /close/i });
+ expect(closeButton).toBeInTheDocument();
+
+ fireEvent.click(closeButton);
+
+ await new Promise(process.nextTick);
+
+ await wait();
+ });
+});
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx
deleted file mode 100644
index d8b3466207..0000000000
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx
+++ /dev/null
@@ -1,1496 +0,0 @@
-import React from 'react';
-import {
- act,
- fireEvent,
- render,
- screen,
- waitFor,
-} from '@testing-library/react';
-import { MockedProvider } from '@apollo/react-testing';
-import { I18nextProvider } from 'react-i18next';
-import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
-import { BrowserRouter } from 'react-router-dom';
-import { Provider } from 'react-redux';
-import { store } from 'state/store';
-import i18nForTest from 'utils/i18nForTest';
-import Chat from '../../../screens/UserPortal/Chat/Chat';
-import {
- CREATE_CHAT,
- MESSAGE_SENT_TO_CHAT,
-} from 'GraphQl/Mutations/OrganizationMutations';
-import { CHATS_LIST, CHAT_BY_ID } from 'GraphQl/Queries/PlugInQueries';
-import useLocalStorage from 'utils/useLocalstorage';
-
-const { setItem } = useLocalStorage();
-
-const UserConnectionListMock = [
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: '',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- firstName: 'Deanne',
- lastName: 'Marks',
- image: null,
- _id: '6589389d2caa9d8d69087487',
- email: 'testuser8@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- organizationsBlockedBy: [],
- joinedOrganizations: [
- {
- _id: '6537904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Queens',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Coffee Street',
- line2: 'Apartment 501',
- postalCode: '11427',
- sortingCode: 'ABC-133',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6637904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Staten Island',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 church Street',
- line2: 'Apartment 499',
- postalCode: '10301',
- sortingCode: 'ABC-122',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Brooklyn',
- countryCode: 'US',
- dependentLocality: 'Sample Dependent Locality',
- line1: '123 Main Street',
- line2: 'Apt 456',
- postalCode: '10004',
- sortingCode: 'ABC-789',
- state: 'NY',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6437904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Bronx',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Random Street',
- line2: 'Apartment 456',
- postalCode: '10451',
- sortingCode: 'ABC-123',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- ],
- __typename: 'User',
- },
- appUserProfile: {
- _id: '64378abd85308f171cf2993d',
- adminFor: [],
- isSuperAdmin: false,
- createdOrganizations: [],
- createdEvents: [],
- eventAdmin: [],
- __typename: 'AppUserProfile',
- },
- __typename: 'UserData',
- },
- ],
- },
- },
- },
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: 'Disha',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- firstName: 'Deanne',
- lastName: 'Marks',
- image: null,
- _id: '6589389d2caa9d8d69087487',
- email: 'testuser8@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- organizationsBlockedBy: [],
- joinedOrganizations: [
- {
- _id: '6537904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Queens',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Coffee Street',
- line2: 'Apartment 501',
- postalCode: '11427',
- sortingCode: 'ABC-133',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6637904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Staten Island',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 church Street',
- line2: 'Apartment 499',
- postalCode: '10301',
- sortingCode: 'ABC-122',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Brooklyn',
- countryCode: 'US',
- dependentLocality: 'Sample Dependent Locality',
- line1: '123 Main Street',
- line2: 'Apt 456',
- postalCode: '10004',
- sortingCode: 'ABC-789',
- state: 'NY',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6437904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Bronx',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Random Street',
- line2: 'Apartment 456',
- postalCode: '10451',
- sortingCode: 'ABC-123',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- ],
- __typename: 'User',
- },
- appUserProfile: {
- _id: '64378abd85308f171cf2993d',
- adminFor: [],
- isSuperAdmin: false,
- createdOrganizations: [],
- createdEvents: [],
- eventAdmin: [],
- __typename: 'AppUserProfile',
- },
- __typename: 'UserData',
- },
- ],
- },
- },
- },
-];
-
-const MESSAGE_SENT_TO_CHAT_MOCK = [
- {
- request: {
- query: MESSAGE_SENT_TO_CHAT,
- variables: {
- userId: null,
- },
- },
- result: {
- data: {
- messageSentToChat: {
- _id: '668ec1f1364e03ac47a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- type: 'STRING',
- replyTo: null,
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_CHAT,
- variables: {
- userId: '2',
- },
- },
- result: {
- data: {
- messageSentToChat: {
- _id: '668ec1f1df364e03ac47a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_CHAT,
- variables: {
- userId: '1',
- },
- },
- result: {
- data: {
- messageSentToChat: {
- _id: '668ec1f13603ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
-];
-
-const CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '1',
- createdAt: '2345678903456',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '1',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '1',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
-];
-
-const CHATS_LIST_MOCK = [
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844efc814dd40fgh03db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: '65844efc814ddgh4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844ghjefc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: 'ujhgtrdtyuiop',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844efc814dhjmkdftyd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: '65844ewsedrffc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844efc814dhjmkdftyd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: '65844ewsedrffc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
-];
-
-const GROUP_CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '65844efc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
-];
-
-const CREATE_CHAT_MUTATION_MOCK = [
- {
- request: {
- query: CREATE_CHAT,
- variables: {
- organizationId: undefined,
- userIds: ['1', '6589389d2caa9d8d69087487'],
- isGroup: false,
- },
- },
- result: {
- data: {
- createChat: {
- _id: '1',
- createdAt: '2345678903456',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
-];
-
-async function wait(ms = 100): Promise {
- await act(() => {
- return new Promise((resolve) => {
- setTimeout(resolve, ms);
- });
- });
-}
-
-describe('Testing Create Direct Chat Modal [User Portal]', () => {
- window.HTMLElement.prototype.scrollIntoView = jest.fn();
-
- Object.defineProperty(window, 'matchMedia', {
- writable: true,
- value: jest.fn().mockImplementation((query) => ({
- matches: false,
- media: query,
- onchange: null,
- addListener: jest.fn(), // Deprecated
- removeListener: jest.fn(), // Deprecated
- addEventListener: jest.fn(),
- removeEventListener: jest.fn(),
- dispatchEvent: jest.fn(),
- })),
- });
-
- test('Open and close create new direct chat modal', async () => {
- const mock = [
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_CHAT_MOCK,
- ...UserConnectionListMock,
- ...CHATS_LIST_MOCK,
- ...CHAT_BY_ID_QUERY_MOCK,
- ...CREATE_CHAT_MUTATION_MOCK,
- ];
- render(
-
-
-
-
-
-
-
-
- ,
- );
-
- await wait();
-
- const dropdown = await screen.findByTestId('dropdown');
- expect(dropdown).toBeInTheDocument();
- fireEvent.click(dropdown);
- const newDirectChatBtn = await screen.findByTestId('newDirectChat');
- expect(newDirectChatBtn).toBeInTheDocument();
- fireEvent.click(newDirectChatBtn);
-
- const submitBtn = await screen.findByTestId('submitBtn');
- expect(submitBtn).toBeInTheDocument();
-
- const searchInput = (await screen.findByTestId(
- 'searchUser',
- )) as HTMLInputElement;
- expect(searchInput).toBeInTheDocument();
-
- fireEvent.change(searchInput, { target: { value: 'Disha' } });
-
- expect(searchInput.value).toBe('Disha');
-
- fireEvent.click(submitBtn);
-
- const closeButton = screen.getByRole('button', { name: /close/i });
- expect(closeButton).toBeInTheDocument();
-
- fireEvent.click(closeButton);
- });
-
- test('create new direct chat', async () => {
- setItem('userId', '1');
- const mock = [
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_CHAT_MOCK,
- ...UserConnectionListMock,
- ...CHATS_LIST_MOCK,
- ...CHAT_BY_ID_QUERY_MOCK,
- ...CREATE_CHAT_MUTATION_MOCK,
- ];
- render(
-
-
-
-
-
-
-
-
- ,
- );
-
- await wait();
-
- const dropdown = await screen.findByTestId('dropdown');
- expect(dropdown).toBeInTheDocument();
- fireEvent.click(dropdown);
- const newDirectChatBtn = await screen.findByTestId('newDirectChat');
- expect(newDirectChatBtn).toBeInTheDocument();
- fireEvent.click(newDirectChatBtn);
-
- const addBtn = await screen.findAllByTestId('addBtn');
- waitFor(() => {
- expect(addBtn[0]).toBeInTheDocument();
- });
-
- fireEvent.click(addBtn[0]);
-
- const closeButton = screen.getByRole('button', { name: /close/i });
- expect(closeButton).toBeInTheDocument();
-
- fireEvent.click(closeButton);
-
- await new Promise(process.nextTick);
-
- await wait();
- });
-});
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
index 24c853fcdd..4b1c2cda02 100644
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
+++ b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
@@ -1,7 +1,6 @@
import { Paper, TableBody } from '@mui/material';
import React, { useState } from 'react';
import { Button, Form, Modal } from 'react-bootstrap';
-import styles from './CreateDirectChat.module.css';
import type { ApolloQueryResult } from '@apollo/client';
import { useMutation, useQuery } from '@apollo/client';
import useLocalStorage from 'utils/useLocalstorage';
@@ -17,6 +16,8 @@ import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
import Loader from 'components/Loader/Loader';
import { Search } from '@mui/icons-material';
import { useParams } from 'react-router-dom';
+import { useTranslation } from 'react-i18next';
+import styles from '../../../style/app.module.css';
interface InterfaceCreateDirectChatProps {
toggleCreateDirectChatModal: () => void;
@@ -27,7 +28,7 @@ interface InterfaceCreateDirectChatProps {
id: string;
}>
| undefined,
- ) => Promise>;
+ ) => Promise>;
}
/**
@@ -61,6 +62,9 @@ export default function createDirectChatModal({
createDirectChatModalisOpen,
chatsListRefetch,
}: InterfaceCreateDirectChatProps): JSX.Element {
+ const { t } = useTranslation('translation', {
+ keyPrefix: 'userChat',
+ });
const { orgId: organizationId } = useParams();
const userId: string | null = getItem('userId');
@@ -125,7 +129,7 @@ export default function createDirectChatModal({
>
) : (
<>
-
+
-
+
@@ -187,7 +194,7 @@ export default function createDirectChatModal({
}}
data-testid="addBtn"
>
- Add
+ {t('add')}
diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.module.css b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.module.css
index 3795e402fa..77fcfaf38f 100644
--- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.module.css
+++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.module.css
@@ -7,3 +7,32 @@
.modalContent {
width: 530px;
}
+
+.groupInfo {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+}
+
+.groupImage {
+ margin-bottom: 10px;
+}
+
+.editImgBtn {
+ padding: 2px 6px 6px 8px;
+ border-radius: 100%;
+ background-color: white;
+ border: 1px solid #959595;
+ color: #959595;
+ outline: none;
+ position: relative;
+ top: -40px;
+ left: 40px;
+}
+
+.chatImage {
+ height: 120px;
+ border-radius: 100%;
+ width: 120px;
+}
diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.spec.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.spec.tsx
new file mode 100644
index 0000000000..440273cbc4
--- /dev/null
+++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.spec.tsx
@@ -0,0 +1,5801 @@
+import React from 'react';
+import {
+ act,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@testing-library/react';
+import { MockedProvider } from '@apollo/react-testing';
+import { I18nextProvider } from 'react-i18next';
+
+import {
+ USERS_CONNECTION_LIST,
+ USER_JOINED_ORGANIZATIONS,
+} from 'GraphQl/Queries/Queries';
+import { BrowserRouter } from 'react-router-dom';
+import { Provider } from 'react-redux';
+import { store } from 'state/store';
+import i18nForTest from 'utils/i18nForTest';
+import Chat from '../../../screens/UserPortal/Chat/Chat';
+import {
+ CREATE_CHAT,
+ MARK_CHAT_MESSAGES_AS_READ,
+ MESSAGE_SENT_TO_CHAT,
+} from 'GraphQl/Mutations/OrganizationMutations';
+import {
+ CHATS_LIST,
+ CHAT_BY_ID,
+ GROUP_CHAT_LIST,
+ UNREAD_CHAT_LIST,
+} from 'GraphQl/Queries/PlugInQueries';
+import useLocalStorage from 'utils/useLocalstorage';
+import { vi } from 'vitest';
+
+/**
+ * Unit tests for the Create Group Chat Modal functionality in the User Portal
+ *
+ * These tests cover the following scenarios:
+ * 1. Opening and closing the create new group chat modal, ensuring proper UI elements
+ * like the dropdown, new group chat button, and close button are displayed and functional.
+ * 2. Creating a new group chat by interacting with the group name input field, organization
+ * selection, and submission process. It also ensures that the create button is properly
+ * triggered after filling out the required fields.
+ * 3. Adding and removing users from the group chat, testing the interactions with the add
+ * and remove buttons, and verifying the submit button and search functionality for user selection.
+ *
+ * GraphQL mocks are used to simulate chat-related queries and mutations. The tests ensure that
+ * the modal behaves correctly in various user interaction scenarios, including handling of form
+ * fields, user management, and modal navigation.
+ */
+
+const { setItem } = useLocalStorage();
+
+const USER_JOINED_ORG_MOCK = [
+ {
+ request: {
+ query: USER_JOINED_ORGANIZATIONS,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USER_JOINED_ORGANIZATIONS,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: 'qsxhgjhbmnbkhlk,njgjfhgv',
+ name: 'Any Organization',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USER_JOINED_ORGANIZATIONS,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8fhgjhnm07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8egfhbn8406b8f07af2',
+ name: 'Any Organization',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USER_JOINED_ORGANIZATIONS,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65fghce8e8406b8f07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8jygjgf07af2',
+ name: 'Any Organization',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USER_JOINED_ORGANIZATIONS,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65cehgh8e8406b8f07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Any Organization',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USER_JOINED_ORGANIZATIONS,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406nbmnmb8f07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8fnnmm07af2',
+ name: 'Any Organization',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ ],
+ },
+ },
+ ],
+ },
+ },
+ },
+];
+
+const UserConnectionListMock = [
+ {
+ request: {
+ query: USERS_CONNECTION_LIST,
+ variables: {
+ firstName_contains: '',
+ lastName_contains: '',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ firstName: 'Deanne',
+ lastName: 'Marks',
+ image: null,
+ _id: '6589389d2caa9d8d69087487',
+ email: 'testuser8@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ organizationsBlockedBy: [],
+ joinedOrganizations: [
+ {
+ _id: '6537904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Queens',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Coffee Street',
+ line2: 'Apartment 501',
+ postalCode: '11427',
+ sortingCode: 'ABC-133',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6637904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Staten Island',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 church Street',
+ line2: 'Apartment 499',
+ postalCode: '10301',
+ sortingCode: 'ABC-122',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6737904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Brooklyn',
+ countryCode: 'US',
+ dependentLocality: 'Sample Dependent Locality',
+ line1: '123 Main Street',
+ line2: 'Apt 456',
+ postalCode: '10004',
+ sortingCode: 'ABC-789',
+ state: 'NY',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6437904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Bronx',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Random Street',
+ line2: 'Apartment 456',
+ postalCode: '10451',
+ sortingCode: 'ABC-123',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ ],
+ __typename: 'User',
+ },
+ appUserProfile: {
+ _id: '64378abd85308f171cf2993d',
+ adminFor: [],
+ isSuperAdmin: false,
+ createdOrganizations: [],
+ createdEvents: [],
+ eventAdmin: [],
+ __typename: 'AppUserProfile',
+ },
+ __typename: 'UserData',
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: USERS_CONNECTION_LIST,
+ variables: {
+ firstName_contains: '',
+ lastName_contains: '',
+ },
+ },
+ result: {
+ data: {
+ users: {
+ user: [
+ {
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ image: 'img',
+ _id: '1',
+ email: 'disha@email.com',
+ createdAt: '',
+ appUserProfile: {
+ _id: '12',
+ isSuperAdmin: 'false',
+ createdOrganizations: {
+ _id: '345678',
+ },
+ createdEvents: {
+ _id: '34567890',
+ },
+ },
+ organizationsBlockedBy: [],
+ joinedOrganizations: [],
+ },
+ {
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ image: 'img',
+ _id: '1',
+ email: 'disha@email.com',
+ createdAt: '',
+ appUserProfile: {
+ _id: '12',
+ isSuperAdmin: 'false',
+ createdOrganizations: {
+ _id: '345678',
+ },
+ createdEvents: {
+ _id: '34567890',
+ },
+ },
+ organizationsBlockedBy: [],
+ joinedOrganizations: [],
+ },
+ {
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ image: 'img',
+ _id: '1',
+ email: 'disha@email.com',
+ createdAt: '',
+ appUserProfile: {
+ _id: '12',
+ isSuperAdmin: 'false',
+ createdOrganizations: {
+ _id: '345678',
+ },
+ createdEvents: {
+ _id: '34567890',
+ },
+ },
+ organizationsBlockedBy: [],
+ joinedOrganizations: [],
+ },
+ ],
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: USERS_CONNECTION_LIST,
+ variables: {
+ firstName_contains: 'Disha',
+ lastName_contains: '',
+ },
+ },
+ result: {
+ data: {
+ users: [
+ {
+ user: {
+ firstName: 'Deanne',
+ lastName: 'Marks',
+ image: null,
+ _id: '6589389d2caa9d8d69087487',
+ email: 'testuser8@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ organizationsBlockedBy: [],
+ joinedOrganizations: [
+ {
+ _id: '6537904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Queens',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Coffee Street',
+ line2: 'Apartment 501',
+ postalCode: '11427',
+ sortingCode: 'ABC-133',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6637904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Staten Island',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 church Street',
+ line2: 'Apartment 499',
+ postalCode: '10301',
+ sortingCode: 'ABC-122',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6737904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Brooklyn',
+ countryCode: 'US',
+ dependentLocality: 'Sample Dependent Locality',
+ line1: '123 Main Street',
+ line2: 'Apt 456',
+ postalCode: '10004',
+ sortingCode: 'ABC-789',
+ state: 'NY',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ {
+ _id: '6437904485008f171cf29924',
+ name: 'Unity Foundation',
+ image: null,
+ address: {
+ city: 'Bronx',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Random Street',
+ line2: 'Apartment 456',
+ postalCode: '10451',
+ sortingCode: 'ABC-123',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ createdAt: '2023-04-13T05:16:52.827Z',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ __typename: 'Organization',
+ },
+ ],
+ __typename: 'User',
+ },
+ appUserProfile: {
+ _id: '64378abd85308f171cf2993d',
+ adminFor: [],
+ isSuperAdmin: false,
+ createdOrganizations: [],
+ createdEvents: [],
+ eventAdmin: [],
+ __typename: 'AppUserProfile',
+ },
+ __typename: 'UserData',
+ },
+ ],
+ },
+ },
+ },
+];
+
+const MESSAGE_SENT_TO_CHAT_MOCK = [
+ {
+ request: {
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: null,
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f1364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ type: 'STRING',
+ replyTo: null,
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: '2',
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f1df364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: '1',
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f13603ac4697a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+];
+
+const CHAT_BY_ID_QUERY_MOCK = [
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '1',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ createdAt: '2345678903456',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '1',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
+ createdAt: '2345678903456',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const UNREAD_CHAT_BY_USER_ID_QUERY_MOCK = [
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: UNREAD_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+];
+
+const CHATS_LIST_MOCK = [
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844ghjefc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: 'fcfgcgchnbjhgfrftghj',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db8gjhbhn11c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844ghjefc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: 'ujhgtrdtyuiop',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ ],
+ },
+ },
+ },
+];
+
+const GROUP_CHAT_LIST_QUERY_MOCK = [
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {},
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GROUP_CHAT_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ getGroupChatsByUserId: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const GROUP_CHAT_BY_ID_QUERY_MOCK = [
+ {
+ request: {
+ query: CHAT_BY_ID,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatById: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const CREATE_CHAT_MUTATION = [
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ organizationId: '6401ff65ce8e8406b8jygjgf07af2',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ organizationId: '6401ff65ce8e8406b8jygjgf07af2',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ organizationId: '6401ff65ce8e8406b8jygjgf07af2',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ organizationId: '6401ff65ce8e8406b8jygjgf07af2',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ media: null,
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: CREATE_CHAT,
+ variables: {
+ organizationId: '',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
+ image: null,
+ },
+ },
+ result: {
+ data: {
+ createChat: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ image: null,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ media: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
+ },
+ },
+ },
+ },
+];
+
+const MARK_CHAT_MESSAGES_AS_READ_MOCK = [
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: null,
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: null,
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: '1',
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: '1',
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: MARK_CHAT_MESSAGES_AS_READ,
+ variables: {
+ userId: '1',
+ chatId: '',
+ },
+ },
+ result: {
+ data: {
+ markChatMessagesAsRead: {
+ _id: '1',
+ },
+ },
+ },
+ },
+];
+
+async function wait(ms = 100): Promise {
+ await act(() => {
+ return new Promise((resolve) => {
+ setTimeout(resolve, ms);
+ });
+ });
+}
+
+describe('Testing Create Group Chat Modal [User Portal]', () => {
+ window.HTMLElement.prototype.scrollIntoView = vi.fn();
+
+ Object.defineProperty(window, 'matchMedia', {
+ writable: true,
+ value: vi.fn().mockImplementation((query) => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: vi.fn(), // Deprecated
+ removeListener: vi.fn(), // Deprecated
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ dispatchEvent: vi.fn(),
+ })),
+ });
+
+ it('open and close create new direct chat modal', async () => {
+ const mock = [
+ ...USER_JOINED_ORG_MOCK,
+ ...GROUP_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
+ ...UserConnectionListMock,
+ ...CREATE_CHAT_MUTATION,
+ ...CHATS_LIST_MOCK,
+ ...MARK_CHAT_MESSAGES_AS_READ_MOCK,
+ ...UNREAD_CHAT_BY_USER_ID_QUERY_MOCK,
+ ...GROUP_CHAT_LIST_QUERY_MOCK,
+ ];
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const dropdown = await screen.findByTestId('dropdown');
+ expect(dropdown).toBeInTheDocument();
+ fireEvent.click(dropdown);
+ const newGroupChatBtn = await screen.findByTestId('newDirectChat');
+ expect(newGroupChatBtn).toBeInTheDocument();
+ fireEvent.click(newGroupChatBtn);
+
+ const closeButton = screen.getByRole('button', { name: /close/i });
+ expect(closeButton).toBeInTheDocument();
+
+ fireEvent.click(closeButton);
+ });
+
+ it('create new group chat', async () => {
+ const mock = [
+ ...USER_JOINED_ORG_MOCK,
+ ...GROUP_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
+ ...UserConnectionListMock,
+ ...CREATE_CHAT_MUTATION,
+ ...CHATS_LIST_MOCK,
+ ...MARK_CHAT_MESSAGES_AS_READ_MOCK,
+ ...UNREAD_CHAT_BY_USER_ID_QUERY_MOCK,
+ ...GROUP_CHAT_LIST_QUERY_MOCK,
+ ];
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const dropdown = await screen.findByTestId('dropdown');
+ expect(dropdown).toBeInTheDocument();
+ fireEvent.click(dropdown);
+
+ const newGroupChatBtn = await screen.findByTestId('newGroupChat');
+ expect(newGroupChatBtn).toBeInTheDocument();
+
+ fireEvent.click(newGroupChatBtn);
+
+ await waitFor(async () => {
+ expect(
+ await screen.findByTestId('createGroupChatModal'),
+ ).toBeInTheDocument();
+ });
+
+ const groupTitleInput = (await screen.findByTestId(
+ 'groupTitleInput',
+ )) as unknown as HTMLInputElement;
+
+ expect(groupTitleInput).toBeInTheDocument();
+
+ fireEvent.change(groupTitleInput, { target: { value: 'Test Group' } });
+ await waitFor(() => {
+ expect(groupTitleInput.value).toBe('Test Group');
+ });
+
+ const nextBtn = await screen.findByTestId('nextBtn');
+
+ act(() => {
+ fireEvent.click(nextBtn);
+ });
+
+ const createBtn = await screen.findByTestId('createBtn');
+ await waitFor(async () => {
+ expect(createBtn).toBeInTheDocument();
+ });
+
+ await act(async () => {
+ fireEvent.click(await screen.findByTestId('createBtn'));
+ });
+
+ await waitFor(() => {
+ expect(createBtn).not.toBeInTheDocument();
+ });
+ }, 3000);
+
+ it('add and remove user', async () => {
+ setItem('userId', '1');
+ const mock = [
+ ...USER_JOINED_ORG_MOCK,
+ ...GROUP_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
+ ...UserConnectionListMock,
+ ...CREATE_CHAT_MUTATION,
+ ...CHATS_LIST_MOCK,
+ ...MARK_CHAT_MESSAGES_AS_READ_MOCK,
+ ...UNREAD_CHAT_BY_USER_ID_QUERY_MOCK,
+ ...GROUP_CHAT_LIST_QUERY_MOCK,
+ ];
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const dropdown = await screen.findByTestId('dropdown');
+ expect(dropdown).toBeInTheDocument();
+ fireEvent.click(dropdown);
+ const newGroupChatBtn = await screen.findByTestId('newGroupChat');
+ expect(newGroupChatBtn).toBeInTheDocument();
+ fireEvent.click(newGroupChatBtn);
+
+ await waitFor(async () => {
+ expect(
+ await screen.findByTestId('createGroupChatModal'),
+ ).toBeInTheDocument();
+ });
+
+ const nextBtn = await screen.findByTestId('nextBtn');
+
+ act(() => {
+ fireEvent.click(nextBtn);
+ });
+
+ await waitFor(async () => {
+ const addBtn = await screen.findAllByTestId('addBtn');
+ expect(addBtn[0]).toBeInTheDocument();
+ });
+
+ const addBtn = await screen.findAllByTestId('addBtn');
+
+ fireEvent.click(addBtn[0]);
+
+ const removeBtn = await screen.findAllByText('Remove');
+ await waitFor(async () => {
+ expect(removeBtn[0]).toBeInTheDocument();
+ });
+ fireEvent.click(removeBtn[0]);
+
+ await waitFor(() => {
+ expect(addBtn[0]).toBeInTheDocument();
+ });
+
+ const submitBtn = await screen.findByTestId('submitBtn');
+
+ expect(submitBtn).toBeInTheDocument();
+
+ const searchInput = (await screen.findByTestId(
+ 'searchUser',
+ )) as HTMLInputElement;
+ expect(searchInput).toBeInTheDocument();
+
+ fireEvent.change(searchInput, { target: { value: 'Disha' } });
+
+ expect(searchInput.value).toBe('Disha');
+
+ fireEvent.click(submitBtn);
+
+ const closeButton = screen.getAllByRole('button', { name: /close/i });
+ expect(closeButton[0]).toBeInTheDocument();
+
+ fireEvent.click(closeButton[0]);
+
+ await wait(500);
+ });
+});
diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx
deleted file mode 100644
index 055985d5fb..0000000000
--- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx
+++ /dev/null
@@ -1,2455 +0,0 @@
-import React from 'react';
-import {
- act,
- fireEvent,
- render,
- screen,
- waitFor,
- within,
-} from '@testing-library/react';
-import { MockedProvider } from '@apollo/react-testing';
-import { I18nextProvider } from 'react-i18next';
-
-import {
- USERS_CONNECTION_LIST,
- USER_JOINED_ORGANIZATIONS,
-} from 'GraphQl/Queries/Queries';
-import { BrowserRouter } from 'react-router-dom';
-import { Provider } from 'react-redux';
-import { store } from 'state/store';
-import i18nForTest from 'utils/i18nForTest';
-import Chat from '../../../screens/UserPortal/Chat/Chat';
-import {
- CREATE_CHAT,
- MESSAGE_SENT_TO_CHAT,
-} from 'GraphQl/Mutations/OrganizationMutations';
-import { CHATS_LIST, CHAT_BY_ID } from 'GraphQl/Queries/PlugInQueries';
-import useLocalStorage from 'utils/useLocalstorage';
-import userEvent from '@testing-library/user-event';
-
-const { setItem } = useLocalStorage();
-
-const USER_JOINED_ORG_MOCK = [
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Test Org 1',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Test Org 1',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Test Org 1',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Test Org 1',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- ],
- },
- },
- ],
- },
- },
- },
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Test org',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: 'qsxhgjhbmnbkhlk,njgjfhgv',
- name: 'Any Organization',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- ],
- },
- },
- ],
- },
- },
- },
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8fhgjhnm07af2',
- name: 'Test org',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8egfhbn8406b8f07af2',
- name: 'Any Organization',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- ],
- },
- },
- ],
- },
- },
- },
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
- {
- __typename: 'Organization',
- _id: '6401ff65fghce8e8406b8f07af2',
- name: 'Test org',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8jygjgf07af2',
- name: 'Any Organization',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- ],
- },
- },
- ],
- },
- },
- },
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
- {
- __typename: 'Organization',
- _id: '6401ff65cehgh8e8406b8f07af2',
- name: 'Test org',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Any Organization',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- ],
- },
- },
- ],
- },
- },
- },
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406nbmnmb8f07af2',
- name: 'Test org',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- {
- __typename: 'Organization',
- _id: '6401ff65ce8e8406b8fnnmm07af2',
- name: 'Any Organization',
- image: '',
- description: 'New Desc',
- address: {
- city: 'abc',
- countryCode: '123',
- postalCode: '456',
- state: 'def',
- dependentLocality: 'ghi',
- line1: 'asdfg',
- line2: 'dfghj',
- sortingCode: '4567',
- },
- createdAt: '1234567890',
- userRegistrationRequired: true,
- creator: {
- __typename: 'User',
- firstName: 'John',
- lastName: 'Doe',
- },
- members: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- admins: [
- {
- _id: '45gj5678jk45678fvgbhnr4rtgh',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- membershipRequests: [
- {
- _id: '56gheqyr7deyfuiwfewifruy8',
- user: {
- _id: '45ydeg2yet721rtgdu32ry',
- },
- },
- ],
- },
- ],
- },
- },
- ],
- },
- },
- },
-];
-
-const UserConnectionListMock = [
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: '',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- firstName: 'Deanne',
- lastName: 'Marks',
- image: null,
- _id: '6589389d2caa9d8d69087487',
- email: 'testuser8@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- organizationsBlockedBy: [],
- joinedOrganizations: [
- {
- _id: '6537904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Queens',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Coffee Street',
- line2: 'Apartment 501',
- postalCode: '11427',
- sortingCode: 'ABC-133',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6637904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Staten Island',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 church Street',
- line2: 'Apartment 499',
- postalCode: '10301',
- sortingCode: 'ABC-122',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Brooklyn',
- countryCode: 'US',
- dependentLocality: 'Sample Dependent Locality',
- line1: '123 Main Street',
- line2: 'Apt 456',
- postalCode: '10004',
- sortingCode: 'ABC-789',
- state: 'NY',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6437904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Bronx',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Random Street',
- line2: 'Apartment 456',
- postalCode: '10451',
- sortingCode: 'ABC-123',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- ],
- __typename: 'User',
- },
- appUserProfile: {
- _id: '64378abd85308f171cf2993d',
- adminFor: [],
- isSuperAdmin: false,
- createdOrganizations: [],
- createdEvents: [],
- eventAdmin: [],
- __typename: 'AppUserProfile',
- },
- __typename: 'UserData',
- },
- ],
- },
- },
- },
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: '',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: {
- user: [
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: 'Disha',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- firstName: 'Deanne',
- lastName: 'Marks',
- image: null,
- _id: '6589389d2caa9d8d69087487',
- email: 'testuser8@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- organizationsBlockedBy: [],
- joinedOrganizations: [
- {
- _id: '6537904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Queens',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Coffee Street',
- line2: 'Apartment 501',
- postalCode: '11427',
- sortingCode: 'ABC-133',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6637904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Staten Island',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 church Street',
- line2: 'Apartment 499',
- postalCode: '10301',
- sortingCode: 'ABC-122',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Brooklyn',
- countryCode: 'US',
- dependentLocality: 'Sample Dependent Locality',
- line1: '123 Main Street',
- line2: 'Apt 456',
- postalCode: '10004',
- sortingCode: 'ABC-789',
- state: 'NY',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- {
- _id: '6437904485008f171cf29924',
- name: 'Unity Foundation',
- image: null,
- address: {
- city: 'Bronx',
- countryCode: 'US',
- dependentLocality: 'Some Dependent Locality',
- line1: '123 Random Street',
- line2: 'Apartment 456',
- postalCode: '10451',
- sortingCode: 'ABC-123',
- state: 'NYC',
- __typename: 'Address',
- },
- createdAt: '2023-04-13T05:16:52.827Z',
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- __typename: 'Organization',
- },
- ],
- __typename: 'User',
- },
- appUserProfile: {
- _id: '64378abd85308f171cf2993d',
- adminFor: [],
- isSuperAdmin: false,
- createdOrganizations: [],
- createdEvents: [],
- eventAdmin: [],
- __typename: 'AppUserProfile',
- },
- __typename: 'UserData',
- },
- ],
- },
- },
- },
-];
-
-const MESSAGE_SENT_TO_CHAT_MOCK = [
- {
- request: {
- query: MESSAGE_SENT_TO_CHAT,
- variables: {
- userId: null,
- },
- },
- result: {
- data: {
- messageSentToChat: {
- _id: '668ec1f1364e03ac47a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- type: 'STRING',
- replyTo: null,
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_CHAT,
- variables: {
- userId: '2',
- },
- },
- result: {
- data: {
- messageSentToChat: {
- _id: '668ec1f1df364e03ac47a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_CHAT,
- variables: {
- userId: '1',
- },
- },
- result: {
- data: {
- messageSentToChat: {
- _id: '668ec1f13603ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
-];
-
-const CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '1',
- createdAt: '2345678903456',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '1',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '1',
- isGroup: false,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: null,
- name: '',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
-];
-
-const CHATS_LIST_MOCK = [
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844efc814dd40fgh03db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: '65844efc814ddgh4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844ghjefc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: 'ujhgtrdtyuiop',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- chatsByUserId: [
- {
- _id: '65844efc814dhjmkdftyd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- {
- _id: '65844ewsedrffc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- ],
- },
- },
- },
-];
-
-const GROUP_CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- chatById: {
- _id: '65844efc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
-];
-
-const CREATE_CHAT_MUTATION = [
- {
- request: {
- query: CREATE_CHAT,
- variables: {
- organizationId: '6401ff65ce8e8406b8jygjgf07af2',
- userIds: [null],
- name: 'Test Group',
- isGroup: true,
- },
- },
- result: {
- data: {
- createChat: {
- _id: '65844efc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: CREATE_CHAT,
- variables: {
- organizationId: '',
- userIds: [null],
- name: 'Test Group',
- isGroup: true,
- },
- },
- result: {
- data: {
- createChat: {
- _id: '65844efc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: null,
- email: 'testsuperadmin@example.com',
- createdAt: '2023-04-13T04:53:17.742Z',
- __typename: 'User',
- },
- organization: {
- _id: 'pw3ertyuiophgfre45678',
- name: 'rtyu',
- },
- createdAt: '2345678903456',
- name: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- type: 'STRING',
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
-];
-
-async function wait(ms = 100): Promise {
- await act(() => {
- return new Promise((resolve) => {
- setTimeout(resolve, ms);
- });
- });
-}
-
-describe('Testing Create Group Chat Modal [User Portal]', () => {
- window.HTMLElement.prototype.scrollIntoView = jest.fn();
-
- Object.defineProperty(window, 'matchMedia', {
- writable: true,
- value: jest.fn().mockImplementation((query) => ({
- matches: false,
- media: query,
- onchange: null,
- addListener: jest.fn(), // Deprecated
- removeListener: jest.fn(), // Deprecated
- addEventListener: jest.fn(),
- removeEventListener: jest.fn(),
- dispatchEvent: jest.fn(),
- })),
- });
-
- test('open and close create new direct chat modal', async () => {
- const mock = [
- ...USER_JOINED_ORG_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_CHAT_MOCK,
- ...CHAT_BY_ID_QUERY_MOCK,
- ...CHATS_LIST_MOCK,
- ...UserConnectionListMock,
- ...CREATE_CHAT_MUTATION,
- ...CHATS_LIST_MOCK,
- ];
- render(
-
-
-
-
-
-
-
-
- ,
- );
-
- await wait();
-
- const dropdown = await screen.findByTestId('dropdown');
- expect(dropdown).toBeInTheDocument();
- fireEvent.click(dropdown);
- const newGroupChatBtn = await screen.findByTestId('newGroupChat');
- expect(newGroupChatBtn).toBeInTheDocument();
- fireEvent.click(newGroupChatBtn);
-
- const closeButton = screen.getByRole('button', { name: /close/i });
- expect(closeButton).toBeInTheDocument();
-
- fireEvent.click(closeButton);
- });
-
- test('create new group chat', async () => {
- const mock = [
- ...USER_JOINED_ORG_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_CHAT_MOCK,
- ...CHAT_BY_ID_QUERY_MOCK,
- ...CHATS_LIST_MOCK,
- ...UserConnectionListMock,
- ...CREATE_CHAT_MUTATION,
- ...CHATS_LIST_MOCK,
- ];
- render(
-
-
-
-
-
-
-
-
- ,
- );
-
- await wait();
-
- const dropdown = await screen.findByTestId('dropdown');
- expect(dropdown).toBeInTheDocument();
- fireEvent.click(dropdown);
-
- const newGroupChatBtn = await screen.findByTestId('newGroupChat');
- expect(newGroupChatBtn).toBeInTheDocument();
-
- fireEvent.click(newGroupChatBtn);
-
- await waitFor(async () => {
- expect(
- await screen.findByTestId('createGroupChatModal'),
- ).toBeInTheDocument();
- });
-
- const groupTitleInput = screen.getByLabelText(
- 'Group name',
- ) as HTMLInputElement;
-
- expect(groupTitleInput).toBeInTheDocument();
-
- fireEvent.change(groupTitleInput, { target: { value: 'Test Group' } });
- await waitFor(() => {
- expect(groupTitleInput.value).toBe('Test Group');
- });
-
- const selectLabel = /select organization/i;
- const orgSelect = await screen.findByLabelText('Select Organization');
- // console.log(prettyDOM(document));
-
- // act(() => {
- // fireEvent.change(orgSelect, {
- // target: { value: '6401ff65ce8e8406b8f07af2' },
- // });
- // })
- // fireEvent.change(orgSelect, {
- // target: { value: '6401ff65ce8e8406b8f07af2' },
- // });
-
- // act(() => {
- userEvent.click(orgSelect);
-
- const optionsPopupEl = await screen.findByRole('listbox', {
- name: selectLabel,
- });
-
- userEvent.click(within(optionsPopupEl).getByText(/any organization/i));
- // });
-
- // await waitFor(async () => {
- // const option = await screen.findAllByText('Any Organization');
-
- // console.log("option", option);
- // });
-
- const nextBtn = await screen.findByTestId('nextBtn');
-
- act(() => {
- fireEvent.click(nextBtn);
- });
-
- const createBtn = await screen.findByTestId('createBtn');
- await waitFor(async () => {
- expect(createBtn).toBeInTheDocument();
- });
-
- await act(async () => {
- fireEvent.click(await screen.findByTestId('createBtn'));
- });
-
- // await waitFor(() => {
- // expect(createBtn).not.toBeInTheDocument();
- // });
- }, 3000);
-
- test('add and remove user', async () => {
- setItem('userId', '1');
- const mock = [
- ...USER_JOINED_ORG_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_CHAT_MOCK,
- ...CHAT_BY_ID_QUERY_MOCK,
- ...CHATS_LIST_MOCK,
- ...UserConnectionListMock,
- ...CREATE_CHAT_MUTATION,
- ...CHATS_LIST_MOCK,
- ];
- render(
-
-
-
-
-
-
-
-
- ,
- );
-
- await wait();
-
- const dropdown = await screen.findByTestId('dropdown');
- expect(dropdown).toBeInTheDocument();
- fireEvent.click(dropdown);
- const newGroupChatBtn = await screen.findByTestId('newGroupChat');
- expect(newGroupChatBtn).toBeInTheDocument();
- fireEvent.click(newGroupChatBtn);
-
- await waitFor(async () => {
- expect(
- await screen.findByTestId('createGroupChatModal'),
- ).toBeInTheDocument();
- });
-
- const nextBtn = await screen.findByTestId('nextBtn');
-
- act(() => {
- fireEvent.click(nextBtn);
- });
-
- await waitFor(async () => {
- const addBtn = await screen.findAllByTestId('addBtn');
- expect(addBtn[0]).toBeInTheDocument();
- });
-
- const addBtn = await screen.findAllByTestId('addBtn');
-
- fireEvent.click(addBtn[0]);
-
- const removeBtn = await screen.findAllByText('Remove');
- await waitFor(async () => {
- expect(removeBtn[0]).toBeInTheDocument();
- });
- fireEvent.click(removeBtn[0]);
-
- await waitFor(() => {
- expect(addBtn[0]).toBeInTheDocument();
- });
-
- const submitBtn = await screen.findByTestId('submitBtn');
-
- expect(submitBtn).toBeInTheDocument();
-
- const searchInput = (await screen.findByTestId(
- 'searchUser',
- )) as HTMLInputElement;
- expect(searchInput).toBeInTheDocument();
-
- fireEvent.change(searchInput, { target: { value: 'Disha' } });
-
- expect(searchInput.value).toBe('Disha');
-
- fireEvent.click(submitBtn);
-
- const closeButton = screen.getAllByRole('button', { name: /close/i });
- expect(closeButton[0]).toBeInTheDocument();
-
- fireEvent.click(closeButton[0]);
-
- await wait(500);
- });
-});
diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx
index e293675a03..f61dcf620d 100644
--- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx
+++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx
@@ -1,18 +1,9 @@
-import {
- FormControl,
- InputLabel,
- MenuItem,
- Paper,
- Select,
- TableBody,
-} from '@mui/material';
-import type { SelectChangeEvent } from '@mui/material/Select';
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useRef, useState } from 'react';
+import { Paper, TableBody } from '@mui/material';
import { Button, Form, Modal } from 'react-bootstrap';
import styles from './CreateGroupChat.module.css';
import type { ApolloQueryResult } from '@apollo/client';
import { useMutation, useQuery } from '@apollo/client';
-import { USER_JOINED_ORGANIZATIONS } from 'GraphQl/Queries/OrganizationQueries';
import useLocalStorage from 'utils/useLocalstorage';
import { CREATE_CHAT } from 'GraphQl/Mutations/OrganizationMutations';
import Table from '@mui/material/Table';
@@ -25,6 +16,11 @@ import type { InterfaceQueryUserListItem } from 'utils/interfaces';
import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
import Loader from 'components/Loader/Loader';
import { Search } from '@mui/icons-material';
+import { useTranslation } from 'react-i18next';
+import { useParams } from 'react-router-dom';
+import convertToBase64 from 'utils/convertToBase64';
+import Avatar from 'components/Avatar/Avatar';
+import { FiEdit } from 'react-icons/fi';
interface InterfaceCreateGroupChatProps {
toggleCreateGroupChatModal: () => void;
@@ -35,31 +31,7 @@ interface InterfaceCreateGroupChatProps {
id: string;
}>
| undefined,
- ) => Promise>;
-}
-
-interface InterfaceOrganization {
- _id: string;
- name: string;
- image: string;
- description: string;
- admins: [];
- members: [];
- address: {
- city: string;
- countryCode: string;
- line1: string;
- postalCode: string;
- state: string;
- };
- membershipRequestStatus: string;
- userRegistrationRequired: boolean;
- membershipRequests: {
- _id: string;
- user: {
- _id: string;
- };
- }[];
+ ) => Promise>;
}
/**
@@ -94,12 +66,14 @@ export default function CreateGroupChat({
chatsListRefetch,
}: InterfaceCreateGroupChatProps): JSX.Element {
const userId: string | null = getItem('userId');
+ const { t } = useTranslation('translation', {
+ keyPrefix: 'userChat',
+ });
const [createChat] = useMutation(CREATE_CHAT);
- const [organizations, setOrganizations] = useState([]);
- const [selectedOrganization, setSelectedOrganization] = useState('');
const [title, setTitle] = useState('');
+ const [description, setDescription] = useState('');
const [userIds, setUserIds] = useState([]);
const [addUserModalisOpen, setAddUserModalisOpen] = useState(false);
@@ -111,21 +85,11 @@ export default function CreateGroupChat({
const toggleAddUserModal = /* istanbul ignore next */ (): void =>
setAddUserModalisOpen(!addUserModalisOpen);
- const handleChange = (event: SelectChangeEvent): void => {
- setSelectedOrganization(event.target.value as string);
- };
-
- const { data: joinedOrganizationsData } = useQuery(
- USER_JOINED_ORGANIZATIONS,
- {
- variables: { id: userId },
- },
- );
+ const { orgId: currentOrg } = useParams();
function reset(): void {
setTitle('');
setUserIds([]);
- setSelectedOrganization('');
}
useEffect(() => {
@@ -135,10 +99,11 @@ export default function CreateGroupChat({
async function handleCreateGroupChat(): Promise {
await createChat({
variables: {
- organizationId: selectedOrganization,
+ organizationId: currentOrg,
userIds: [userId, ...userIds],
name: title,
isGroup: true,
+ image: selectedImage,
},
});
chatsListRefetch();
@@ -175,13 +140,23 @@ export default function CreateGroupChat({
});
};
- useEffect(() => {
- if (joinedOrganizationsData && joinedOrganizationsData.users.length > 0) {
- const organizations =
- joinedOrganizationsData.users[0]?.user?.joinedOrganizations || [];
- setOrganizations(organizations);
+ const [selectedImage, setSelectedImage] = useState