-
-
+ {chatImage ? (
+
+ ) : (
+
+ )}
+
(chat?.isGroup ? openGroupChatDetails() : null)}
+ className={styles.userDetails}
+ >
{chatTitle}
{chatSubtitle}
@@ -271,6 +372,13 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
)}
+ {message.media && (
+
+ )}
{message.messageContent}
@@ -291,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
@@ -314,6 +431,13 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
>
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx
index 5526206708..ccf23a882b 100644
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx
+++ b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.spec.tsx
@@ -16,9 +16,15 @@ 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 } from 'GraphQl/Queries/PlugInQueries';
+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();
@@ -347,6 +353,9 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [
data: {
messageSentToChat: {
_id: '668ec1f1364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
type: 'STRING',
@@ -373,6 +382,9 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [
data: {
messageSentToChat: {
_id: '668ec1f1df364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
@@ -399,6 +411,9 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [
data: {
messageSentToChat: {
_id: '668ec1f13603ac4697a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
@@ -447,6 +462,7 @@ const CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -473,6 +489,19 @@ const CHAT_BY_ID_QUERY_MOCK = [
image: '',
},
],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
},
},
},
@@ -507,6 +536,7 @@ const CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -533,6 +563,19 @@ const CHAT_BY_ID_QUERY_MOCK = [
image: '',
},
],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 0,
+ '2': 0,
+ }),
},
},
},
@@ -567,6 +610,226 @@ const CHAT_BY_ID_QUERY_MOCK = [
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',
@@ -575,44 +838,2036 @@ const CHAT_BY_ID_QUERY_MOCK = [
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: '',
- },
- ],
- },
+ },
+ ],
+ 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,
+ }),
+ },
+ ],
},
},
},
-];
-
-const CHATS_LIST_MOCK = [
{
request: {
query: CHATS_LIST,
variables: {
- id: null,
+ id: '1',
},
},
result: {
data: {
chatsByUserId: [
{
- _id: '65844efc814dd40fgh03db811c4',
+ _id: '65844efc814dhjmkdftyd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -634,6 +2889,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -681,10 +2937,27 @@ const CHATS_LIST_MOCK = [
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',
+ _id: '65844ewsedrffc814dd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -706,6 +2979,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -753,6 +3027,22 @@ const CHATS_LIST_MOCK = [
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,
+ }),
},
],
},
@@ -762,15 +3052,16 @@ const CHATS_LIST_MOCK = [
request: {
query: CHATS_LIST,
variables: {
- id: '',
+ id: '1',
},
},
result: {
data: {
chatsByUserId: [
{
- _id: '65844ghjefc814dd4003db811c4',
+ _id: '65844efc814dhjmkdftyd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -789,6 +3080,7 @@ const CHATS_LIST_MOCK = [
messages: [
{
_id: '345678',
+ media: null,
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
@@ -839,10 +3131,27 @@ const CHATS_LIST_MOCK = [
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',
+ _id: '65844ewsedrffc814dd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -864,6 +3173,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -911,6 +3221,22 @@ const CHATS_LIST_MOCK = [
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,
+ }),
},
],
},
@@ -929,6 +3255,7 @@ const CHATS_LIST_MOCK = [
{
_id: '65844efc814dhjmkdftyd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -950,6 +3277,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -997,10 +3325,27 @@ const CHATS_LIST_MOCK = [
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',
@@ -1022,6 +3367,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1069,6 +3415,22 @@ const CHATS_LIST_MOCK = [
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,
+ }),
},
],
},
@@ -1087,6 +3449,7 @@ const CHATS_LIST_MOCK = [
{
_id: '65844efc814dhjmkdftyd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1108,6 +3471,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1155,10 +3519,27 @@ const CHATS_LIST_MOCK = [
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',
@@ -1180,6 +3561,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1227,6 +3609,22 @@ const CHATS_LIST_MOCK = [
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,
+ }),
},
],
},
@@ -1247,6 +3645,7 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
chatById: {
_id: '65844efc814dd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1268,6 +3667,7 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1315,6 +3715,22 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
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,
+ }),
},
},
},
@@ -1355,6 +3771,7 @@ const CREATE_CHAT_MUTATION_MOCK = [
messageContent: 'Hello',
replyTo: null,
type: 'STRING',
+ media: null,
sender: {
_id: '2',
firstName: 'Test',
@@ -1380,12 +3797,114 @@ const CREATE_CHAT_MUTATION_MOCK = [
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) => {
@@ -1419,6 +3938,9 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
...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(
@@ -1470,6 +3992,9 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
...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(
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
index 24c853fcdd..8125b6a463 100644
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
+++ b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
@@ -17,6 +17,7 @@ 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';
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');
@@ -187,7 +191,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
index 711bb29a93..440273cbc4 100644
--- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.spec.tsx
+++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.spec.tsx
@@ -5,7 +5,6 @@ import {
render,
screen,
waitFor,
- within,
} from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
@@ -21,11 +20,16 @@ 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 } from 'GraphQl/Queries/PlugInQueries';
+import {
+ CHATS_LIST,
+ CHAT_BY_ID,
+ GROUP_CHAT_LIST,
+ UNREAD_CHAT_LIST,
+} from 'GraphQl/Queries/PlugInQueries';
import useLocalStorage from 'utils/useLocalstorage';
-import userEvent from '@testing-library/user-event';
import { vi } from 'vitest';
/**
@@ -1228,6 +1232,9 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [
data: {
messageSentToChat: {
_id: '668ec1f1364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
type: 'STRING',
@@ -1254,6 +1261,9 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [
data: {
messageSentToChat: {
_id: '668ec1f1df364e03ac47a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
@@ -1280,6 +1290,9 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [
data: {
messageSentToChat: {
_id: '668ec1f13603ac4697a151',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
@@ -1328,6 +1341,7 @@ const CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1354,6 +1368,19 @@ const CHAT_BY_ID_QUERY_MOCK = [
image: '',
},
],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
},
},
},
@@ -1388,6 +1415,7 @@ const CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1414,6 +1442,19 @@ const CHAT_BY_ID_QUERY_MOCK = [
image: '',
},
],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
},
},
},
@@ -1448,6 +1489,7 @@ const CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1474,26 +1516,40 @@ const CHAT_BY_ID_QUERY_MOCK = [
image: '',
},
],
+ admins: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ ],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ }),
},
},
},
},
];
-const CHATS_LIST_MOCK = [
+const UNREAD_CHAT_BY_USER_ID_QUERY_MOCK = [
{
request: {
- query: CHATS_LIST,
+ query: UNREAD_CHAT_LIST,
variables: {
id: null,
},
},
result: {
data: {
- chatsByUserId: [
+ getUnreadChatsByUserId: [
{
- _id: '65844efc814dd40fgh03db811c4',
+ _id: '65844efc814dd40hgjfgh03db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1515,6 +1571,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1562,10 +1619,33 @@ const CHATS_LIST_MOCK = [
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: '65844efc814ddgh4003db811c4',
+ _id: '65844efc814dd40hgjfgh03db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1587,6 +1667,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1634,6 +1715,14 @@ const CHATS_LIST_MOCK = [
image: '',
},
],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
},
],
},
@@ -1641,17 +1730,18 @@ const CHATS_LIST_MOCK = [
},
{
request: {
- query: CHATS_LIST,
+ query: UNREAD_CHAT_LIST,
variables: {
- id: '',
+ id: null,
},
},
result: {
data: {
- chatsByUserId: [
+ getUnreadChatsByUserId: [
{
- _id: '65844ghjefc814dd4003db811c4',
+ _id: '65844efc814dd40hgjfgh03db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1673,6 +1763,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1720,10 +1811,33 @@ const CHATS_LIST_MOCK = [
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: 'ujhgtrdtyuiop',
+ _id: '65844efc814dd40hgjfgh03db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1745,6 +1859,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1792,6 +1907,14 @@ const CHATS_LIST_MOCK = [
image: '',
},
],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
},
],
},
@@ -1799,17 +1922,18 @@ const CHATS_LIST_MOCK = [
},
{
request: {
- query: CHATS_LIST,
+ query: UNREAD_CHAT_LIST,
variables: {
- id: '1',
+ id: null,
},
},
result: {
data: {
- chatsByUserId: [
+ getUnreadChatsByUserId: [
{
- _id: '65844efc814dhjmkdftyd4003db811c4',
+ _id: '65844efc814dd40hgjfgh03db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1831,6 +1955,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1878,10 +2003,33 @@ const CHATS_LIST_MOCK = [
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: '65844ewsedrffc814dd4003db811c4',
+ _id: '65844efc814dd40hgjfgh03db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1903,6 +2051,7 @@ const CHATS_LIST_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -1950,138 +2099,3235 @@ const CHATS_LIST_MOCK = [
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,
+ query: UNREAD_CHAT_LIST,
variables: {
- id: '',
+ id: '1',
},
},
result: {
data: {
- chatById: {
- _id: '65844efc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
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: {
+ 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: '',
},
- },
- ],
- 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: '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 CREATE_CHAT_MUTATION = [
{
request: {
- query: CREATE_CHAT,
+ query: UNREAD_CHAT_LIST,
variables: {
- organizationId: '6401ff65ce8e8406b8jygjgf07af2',
- userIds: [null],
- name: 'Test Group',
- isGroup: true,
+ id: '1',
},
},
result: {
data: {
- createChat: {
- _id: '65844efc814dd4003db811c4',
- isGroup: true,
- creator: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
+ getUnreadChatsByUserId: [
+ {
+ _id: '65844efc814dd40hgjfgh03db811c4',
+ isGroup: true,
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',
+ 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',
@@ -2128,6 +5374,14 @@ const CREATE_CHAT_MUTATION = [
image: '',
},
],
+ admins: [],
+ unseenMessagesByUsers: JSON.stringify({
+ '1': 1,
+ '2': 1,
+ '3': 1,
+ '4': 1,
+ '5': 1,
+ }),
},
},
},
@@ -2140,6 +5394,7 @@ const CREATE_CHAT_MUTATION = [
userIds: [null],
name: 'Test Group',
isGroup: true,
+ image: null,
},
},
result: {
@@ -2147,6 +5402,7 @@ const CREATE_CHAT_MUTATION = [
createChat: {
_id: '65844efc814dd4003db811c4',
isGroup: true,
+ image: null,
creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -2168,6 +5424,7 @@ const CREATE_CHAT_MUTATION = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ media: null,
type: 'STRING',
sender: {
_id: '2',
@@ -2215,6 +5472,97 @@ const CREATE_CHAT_MUTATION = [
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',
},
},
},
@@ -2256,6 +5604,9 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
...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(
@@ -2274,7 +5625,7 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
const dropdown = await screen.findByTestId('dropdown');
expect(dropdown).toBeInTheDocument();
fireEvent.click(dropdown);
- const newGroupChatBtn = await screen.findByTestId('newGroupChat');
+ const newGroupChatBtn = await screen.findByTestId('newDirectChat');
expect(newGroupChatBtn).toBeInTheDocument();
fireEvent.click(newGroupChatBtn);
@@ -2294,6 +5645,9 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
...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(
@@ -2324,9 +5678,9 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
).toBeInTheDocument();
});
- const groupTitleInput = screen.getByLabelText(
- 'Group name',
- ) as HTMLInputElement;
+ const groupTitleInput = (await screen.findByTestId(
+ 'groupTitleInput',
+ )) as unknown as HTMLInputElement;
expect(groupTitleInput).toBeInTheDocument();
@@ -2335,35 +5689,6 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
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(() => {
@@ -2379,9 +5704,9 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
fireEvent.click(await screen.findByTestId('createBtn'));
});
- // await waitFor(() => {
- // expect(createBtn).not.toBeInTheDocument();
- // });
+ await waitFor(() => {
+ expect(createBtn).not.toBeInTheDocument();
+ });
}, 3000);
it('add and remove user', async () => {
@@ -2395,6 +5720,9 @@ describe('Testing Create Group Chat Modal [User Portal]', () => {
...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(
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(null);
+
+ const fileInputRef = useRef(null);
+
+ const handleImageClick = (): void => {
+ fileInputRef?.current?.click();
+ };
+
+ const handleImageChange = async (
+ e: React.ChangeEvent,
+ ): Promise => {
+ const file = e.target.files?.[0];
+ if (file) {
+ const base64 = await convertToBase64(file);
+ setSelectedImage(base64);
}
- }, [joinedOrganizationsData]);
+ };
return (
<>
@@ -195,44 +170,57 @@ export default function CreateGroupChat({
New Group
+
+
+ {selectedImage ? (
+
+ ) : (
+
+ )}
+
+
- Group name
+ Title
{
setTitle(e.target.value);
}}
/>
+
+ Description
+ {
+ setDescription(e.target.value);
+ }}
+ />
+
)}
@@ -358,7 +346,7 @@ export default function CreateGroupChat({
onClick={handleCreateGroupChat}
data-testid="createBtn"
>
- Create
+ {t('create')}
diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.spec.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.spec.tsx
index ac6465a3e6..6435353f89 100644
--- a/src/components/UserPortal/UserSidebar/UserSidebar.spec.tsx
+++ b/src/components/UserPortal/UserSidebar/UserSidebar.spec.tsx
@@ -426,7 +426,7 @@ describe('UserSidebar Component Tests in User Portal', () => {
await wait();
});
- const expectedLinks = ['My Organizations', 'Settings', 'Chat'];
+ const expectedLinks = ['My Organizations', 'Settings'];
expectedLinks.forEach((link) => {
expect(screen.getByText(link)).toBeInTheDocument();
});
@@ -483,8 +483,8 @@ describe('UserSidebar Component Tests in User Portal', () => {
renderUserSidebar('properId', link);
await wait();
});
- const chatBtn = screen.getByTestId('chatBtn');
- fireEvent.click(chatBtn);
+ const settingsBtn = screen.getByTestId('settingsBtn');
+ fireEvent.click(settingsBtn);
expect(props.setHideDrawer).toHaveBeenCalledWith(true);
});
diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.tsx
index 5e258f8a8e..010d8d0e52 100644
--- a/src/components/UserPortal/UserSidebar/UserSidebar.tsx
+++ b/src/components/UserPortal/UserSidebar/UserSidebar.tsx
@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next';
import { NavLink } from 'react-router-dom';
import OrganizationsIcon from 'assets/svgs/organizations.svg?react';
import SettingsIcon from 'assets/svgs/settings.svg?react';
-import ChatIcon from 'assets/svgs/chat.svg?react';
import TalawaLogo from 'assets/svgs/talawa.svg?react';
import styles from './UserSidebar.module.css';
@@ -109,28 +108,6 @@ const userSidebar = ({
)}
-
- {({ isActive }) => (
-
- )}
-