diff --git a/src/GraphQl/Mutations/OrganizationMutations.ts b/src/GraphQl/Mutations/OrganizationMutations.ts index c72975b380..3ef2562df9 100644 --- a/src/GraphQl/Mutations/OrganizationMutations.ts +++ b/src/GraphQl/Mutations/OrganizationMutations.ts @@ -110,93 +110,11 @@ export const SEND_MESSAGE_TO_CHAT = gql` $chatId: ID! $replyTo: ID $messageContent: String! - $type: String! ) { sendMessageToChat( chatId: $chatId replyTo: $replyTo messageContent: $messageContent - type: $type - ) { - _id - createdAt - messageContent - replyTo { - _id - createdAt - messageContent - sender { - _id - firstName - lastName - } - updatedAt - } - sender { - _id - firstName - lastName - } - updatedAt - } - } -`; - -export const SEND_MESSAGE_TO_DIRECT_CHAT = gql` - mutation sendMessageToDirectChat( - $chatId: ID! - $replyTo: ID - $messageContent: String! - ) { - sendMessageToDirectChat( - chatId: $chatId - replyTo: $replyTo - messageContent: $messageContent - ) { - _id - createdAt - messageContent - replyTo { - _id - createdAt - messageContent - receiver { - _id - firstName - lastName - } - sender { - _id - firstName - lastName - } - updatedAt - } - receiver { - _id - firstName - lastName - } - sender { - _id - firstName - lastName - } - updatedAt - } - } -`; - -export const SEND_MESSAGE_TO_GROUP_CHAT = gql` - mutation sendMessageToGroupChat( - $chatId: ID! - $replyTo: ID - $messageContent: String! - ) { - sendMessageToGroupChat( - chatId: $chatId - replyTo: $replyTo - messageContent: $messageContent ) { _id createdAt @@ -240,30 +158,6 @@ export const CREATE_MESSAGE_CHAT = gql` } `; -export const MESSAGE_SENT_TO_DIRECT_CHAT = gql` - subscription messageSentToDirectChat($userId: ID!) { - messageSentToDirectChat(userId: $userId) { - _id - createdAt - directChatMessageBelongsTo { - _id - } - messageContent - receiver { - _id - firstName - lastName - } - sender { - _id - firstName - lastName - } - updatedAt - } - } -`; - export const MESSAGE_SENT_TO_CHAT = gql` subscription messageSentToChat($userId: ID!) { messageSentToChat(userId: $userId) { @@ -284,7 +178,6 @@ export const MESSAGE_SENT_TO_CHAT = gql` } updatedAt } - type sender { _id firstName @@ -295,24 +188,6 @@ export const MESSAGE_SENT_TO_CHAT = gql` } `; -export const MESSAGE_SENT_TO_GROUP_CHAT = gql` - subscription messageSentToGroupChat($userId: ID!) { - messageSentToGroupChat(userId: $userId) { - _id - createdAt - groupChatMessageBelongsTo { - _id - } - messageContent - sender { - _id - firstName - lastName - } - updatedAt - } - } -`; //Plugin WebSocket listner /** diff --git a/src/GraphQl/Queries/PlugInQueries.ts b/src/GraphQl/Queries/PlugInQueries.ts index 8a35b4ba7b..91e7a29d07 100644 --- a/src/GraphQl/Queries/PlugInQueries.ts +++ b/src/GraphQl/Queries/PlugInQueries.ts @@ -108,83 +108,6 @@ export const ORGANIZATION_EVENTS_CONNECTION = gql` // directChatsMessagesByChatID(id: ID!): [DirectChatMessage] -export const DIRECT_CHAT_MESSAGES_BY_CHAT_ID = gql` - query directChatsMessagesByChatID($id: ID!) { - directChatsMessagesByChatID(id: $id) { - _id - createdAt - messageContent - receiver { - _id - firstName - lastName - email - image - } - sender { - _id - firstName - lastName - email - image - } - } - } -`; - -export const DIRECT_CHAT_BY_ID = gql` - query directChatById($id: ID!) { - directChatById(id: $id) { - _id - createdAt - messages { - _id - createdAt - messageContent - replyTo { - _id - createdAt - messageContent - receiver { - _id - firstName - lastName - email - image - } - sender { - _id - firstName - lastName - email - image - } - } - receiver { - _id - firstName - lastName - email - image - } - sender { - _id - firstName - lastName - email - image - } - } - users { - _id - firstName - lastName - email - } - } - } -`; - export const CHAT_BY_ID = gql` query chatById($id: ID!) { chatById(id: $id) { @@ -195,47 +118,6 @@ export const CHAT_BY_ID = gql` _id } createdAt - messages { - _id - createdAt - messageContent - replyTo { - _id - createdAt - messageContent - type - sender { - _id - firstName - lastName - email - image - } - } - sender { - _id - firstName - lastName - email - image - } - } - users { - _id - firstName - lastName - email - } - } - } -`; - -export const GROUP_CHAT_BY_ID = gql` - query groupChatById($id: ID!) { - groupChatById(id: $id) { - _id - createdAt - title messages { _id createdAt @@ -265,7 +147,6 @@ export const GROUP_CHAT_BY_ID = gql` firstName lastName email - image } } } @@ -278,43 +159,6 @@ export const CHATS_LIST = gql` isGroup name - creator { - _id - firstName - lastName - email - } - messages { - _id - type - createdAt - messageContent - sender { - _id - firstName - lastName - email - } - } - organization { - _id - name - } - users { - _id - firstName - lastName - email - image - } - } - } -`; - -export const DIRECT_CHATS_LIST = gql` - query DirectChatsByUserID($id: ID!) { - directChatsByUserID(id: $id) { - _id creator { _id firstName @@ -325,12 +169,6 @@ export const DIRECT_CHATS_LIST = gql` _id createdAt messageContent - receiver { - _id - firstName - lastName - email - } sender { _id firstName @@ -353,42 +191,6 @@ export const DIRECT_CHATS_LIST = gql` } `; -export const GROUP_CHAT_LIST = gql` - query GroupChatsByUserID($id: ID!) { - groupChatsByUserId(id: $id) { - _id - creator { - _id - firstName - lastName - email - } - title - messages { - _id - createdAt - messageContent - sender { - _id - firstName - lastName - email - } - } - organization { - _id - name - } - users { - _id - firstName - lastName - email - image - } - } - } -`; /** * GraphQL query to check if an organization is a sample organization. * diff --git a/src/GraphQl/Queries/Queries.ts b/src/GraphQl/Queries/Queries.ts index c3999ba00e..93f40f9e40 100644 --- a/src/GraphQl/Queries/Queries.ts +++ b/src/GraphQl/Queries/Queries.ts @@ -800,7 +800,6 @@ export { AGENDA_ITEM_CATEGORY_LIST } from './AgendaCategoryQueries'; // to take the list of the blocked users export { ADVERTISEMENTS_GET, - DIRECT_CHATS_LIST, IS_SAMPLE_ORGANIZATION_QUERY, ORGANIZATION_CUSTOM_FIELDS, ORGANIZATION_EVENTS_CONNECTION, diff --git a/src/components/UserPortal/ChatRoom/ChatRoom.module.css b/src/components/UserPortal/ChatRoom/ChatRoom.module.css index 66035cea9b..5fc98351cd 100644 --- a/src/components/UserPortal/ChatRoom/ChatRoom.module.css +++ b/src/components/UserPortal/ChatRoom/ChatRoom.module.css @@ -74,6 +74,7 @@ } .userDetails { + display: flex; align-items: center; font-size: 14px; gap: 6px; diff --git a/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx b/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx index f6560e9e1b..c808485132 100644 --- a/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx +++ b/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx @@ -7,7 +7,7 @@ import { fireEvent, waitFor, } from '@testing-library/react'; -import { MockedProvider } from '@apollo/react-testing'; +import { MockSubscriptionLink, MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; @@ -20,6 +20,7 @@ import { } from 'GraphQl/Mutations/OrganizationMutations'; import ChatRoom from './ChatRoom'; import { useLocalStorage } from 'utils/useLocalstorage'; +import { StaticMockLink } from 'utils/StaticMockLink'; const { setItem } = useLocalStorage(); @@ -48,7 +49,6 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [ _id: '1', }, messageContent: 'Test ', - type: 'STRING', replyTo: null, sender: { _id: '64378abd85008f171cf2990d', @@ -78,7 +78,6 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [ _id: '1', }, replyTo: null, - type: 'STRING', sender: { _id: '64378abd85008f171cf2990d', firstName: 'Wilt', @@ -107,7 +106,6 @@ const MESSAGE_SENT_TO_CHAT_MOCK = [ _id: '1', }, replyTo: null, - type: 'STRING', sender: { _id: '64378abd85008f171cf2990d', firstName: 'Wilt', @@ -148,11 +146,10 @@ const CHAT_BY_ID_QUERY_MOCK = [ name: '', messages: [ { - _id: '345678', + _id: '4', createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -208,11 +205,10 @@ const CHAT_BY_ID_QUERY_MOCK = [ createdAt: '2345678903456', messages: [ { - _id: '345678', + _id: '4', createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -268,11 +264,10 @@ const CHAT_BY_ID_QUERY_MOCK = [ createdAt: '2345678903456', messages: [ { - _id: '345678', + _id: '4', createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -339,7 +334,6 @@ const CHATS_LIST_MOCK = [ createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -411,7 +405,6 @@ const CHATS_LIST_MOCK = [ createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -497,7 +490,6 @@ const CHATS_LIST_MOCK = [ createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -569,7 +561,6 @@ const CHATS_LIST_MOCK = [ createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -655,7 +646,6 @@ const CHATS_LIST_MOCK = [ createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -727,7 +717,6 @@ const CHATS_LIST_MOCK = [ createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -811,11 +800,10 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [ name: 'Test Group Chat', messages: [ { - _id: '345678', + _id: '2', createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -895,11 +883,10 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [ name: 'Test Group Chat', messages: [ { - _id: '345678', + _id: '1', createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -979,11 +966,10 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [ name: 'Test Group Chat', messages: [ { - _id: '345678', + _id: '1', createdAt: '345678908765', messageContent: 'Hello', replyTo: null, - type: 'STRING', sender: { _id: '2', firstName: 'Test', @@ -1036,9 +1022,88 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [ }, ]; -// {"chatId":"1","replyTo":"345678","messageContent":"Test reply message","type":"STRING"} - const SEND_MESSAGE_TO_CHAT_MOCK = [ + { + request: { + query: SEND_MESSAGE_TO_CHAT, + variables: { + chatId: '1', + replyTo: '4', + messageContent: 'Test reply message', + }, + }, + result: { + data: { + sendMessageToChat: { + _id: '668ec1f1364e03ac47a151', + createdAt: '2024-07-10T17:16:33.248Z', + messageContent: 'Test ', + replyTo: null, + sender: { + _id: '64378abd85008f171cf2990d', + firstName: 'Wilt', + lastName: 'Shepherd', + image: '', + }, + updatedAt: '2024-07-10', + }, + }, + }, + }, + { + request: { + query: SEND_MESSAGE_TO_CHAT, + variables: { + chatId: '1', + replyTo: '4', + messageContent: 'Test reply message', + }, + }, + result: { + data: { + sendMessageToChat: { + _id: '668ec1f1364e03ac47a151', + createdAt: '2024-07-10T17:16:33.248Z', + messageContent: 'Test ', + replyTo: null, + sender: { + _id: '64378abd85008f171cf2990d', + firstName: 'Wilt', + lastName: 'Shepherd', + image: '', + }, + updatedAt: '2024-07-10', + }, + }, + }, + }, + { + request: { + query: SEND_MESSAGE_TO_CHAT, + variables: { + chatId: '1', + replyTo: '1', + messageContent: 'Test reply message', + }, + }, + result: { + data: { + sendMessageToChat: { + _id: '668ec1f1364e03ac47a151', + createdAt: '2024-07-10T17:16:33.248Z', + messageContent: 'Test ', + replyTo: null, + sender: { + _id: '64378abd85008f171cf2990d', + firstName: 'Wilt', + lastName: 'Shepherd', + image: '', + }, + updatedAt: '2024-07-10', + }, + }, + }, + }, { request: { query: SEND_MESSAGE_TO_CHAT, @@ -1046,7 +1111,6 @@ const SEND_MESSAGE_TO_CHAT_MOCK = [ chatId: '1', replyTo: undefined, messageContent: 'Hello', - type: 'STRING', }, }, result: { @@ -1055,7 +1119,6 @@ const SEND_MESSAGE_TO_CHAT_MOCK = [ _id: '668ec1f1364e03ac47a151', createdAt: '2024-07-10T17:16:33.248Z', messageContent: 'Test ', - type: 'STRING', replyTo: null, sender: { _id: '64378abd85008f171cf2990d', @@ -1075,7 +1138,6 @@ const SEND_MESSAGE_TO_CHAT_MOCK = [ chatId: '1', replyTo: '345678', messageContent: 'Test reply message', - type: 'STRING', }, }, result: { @@ -1084,7 +1146,6 @@ const SEND_MESSAGE_TO_CHAT_MOCK = [ _id: '668ec1f1364e03ac47a151', createdAt: '2024-07-10T17:16:33.248Z', messageContent: 'Test ', - type: 'STRING', replyTo: null, sender: { _id: '64378abd85008f171cf2990d', @@ -1104,7 +1165,6 @@ const SEND_MESSAGE_TO_CHAT_MOCK = [ chatId: '1', replyTo: undefined, messageContent: 'Test message', - type: 'STRING', }, }, result: { @@ -1113,7 +1173,6 @@ const SEND_MESSAGE_TO_CHAT_MOCK = [ _id: '668ec1f1364e03ac47a151', createdAt: '2024-07-10T17:16:33.248Z', messageContent: 'Test ', - type: 'STRING', replyTo: null, sender: { _id: '64378abd85008f171cf2990d', @@ -1136,7 +1195,6 @@ describe('Testing Chatroom Component [User Portal]', () => { ...MESSAGE_SENT_TO_CHAT_MOCK, ...CHAT_BY_ID_QUERY_MOCK, ...CHATS_LIST_MOCK, - ...GROUP_CHAT_BY_ID_QUERY_MOCK, ...SEND_MESSAGE_TO_CHAT_MOCK, ]; render( @@ -1155,15 +1213,15 @@ describe('Testing Chatroom Component [User Portal]', () => { }); test('Selected contact is direct chat', async () => { + const link = new MockSubscriptionLink(); const mocks = [ ...MESSAGE_SENT_TO_CHAT_MOCK, ...CHAT_BY_ID_QUERY_MOCK, ...CHATS_LIST_MOCK, - ...GROUP_CHAT_BY_ID_QUERY_MOCK, ...SEND_MESSAGE_TO_CHAT_MOCK, ]; render( - + @@ -1185,8 +1243,94 @@ describe('Testing Chatroom Component [User Portal]', () => { ...GROUP_CHAT_BY_ID_QUERY_MOCK, ...SEND_MESSAGE_TO_CHAT_MOCK, ]; + const link2 = new StaticMockLink(mocks, true); render( - + + + + + + + + + , + ); + await wait(); + + const input = (await screen.findByTestId( + 'messageInput', + )) as HTMLInputElement; + + act(() => { + fireEvent.change(input, { target: { value: 'Hello' } }); + }); + expect(input.value).toBe('Hello'); + + const sendBtn = await screen.findByTestId('sendMessage'); + + expect(sendBtn).toBeInTheDocument(); + act(() => { + fireEvent.click(sendBtn); + }); + await waitFor(() => { + expect(input.value).toBeFalsy(); + }); + + const messages = await screen.findAllByTestId('message'); + + console.log('MESSAGES', messages); + + expect(messages.length).not.toBe(0); + + act(() => { + fireEvent.mouseOver(messages[0]); + }); + + await waitFor(async () => { + expect(await screen.findByTestId('moreOptions')).toBeInTheDocument(); + }); + + const moreOptionsBtn = await screen.findByTestId('dropdown'); + act(() => { + fireEvent.click(moreOptionsBtn); + }); + + const replyBtn = await screen.findByTestId('replyBtn'); + + act(() => { + fireEvent.click(replyBtn); + }); + + const replyMsg = await screen.findByTestId('replyMsg'); + + await waitFor(() => { + expect(replyMsg).toBeInTheDocument(); + }); + + act(() => { + fireEvent.change(input, { target: { value: 'Test reply message' } }); + }); + expect(input.value).toBe('Test reply message'); + + act(() => { + fireEvent.click(sendBtn); + }); + + await wait(400); + }); + + test('send message direct chat when userId is different', async () => { + setItem('userId', '8'); + const mocks = [ + ...GROUP_CHAT_BY_ID_QUERY_MOCK, + ...MESSAGE_SENT_TO_CHAT_MOCK, + ...CHAT_BY_ID_QUERY_MOCK, + ...CHATS_LIST_MOCK, + ...SEND_MESSAGE_TO_CHAT_MOCK, + ]; + const link2 = new StaticMockLink(mocks, true); + render( + @@ -1216,6 +1360,48 @@ describe('Testing Chatroom Component [User Portal]', () => { await waitFor(() => { expect(input.value).toBeFalsy(); }); + + const messages = await screen.findAllByTestId('message'); + + console.log('MESSAGES', messages); + + expect(messages.length).not.toBe(0); + + act(() => { + fireEvent.mouseOver(messages[0]); + }); + + await waitFor(async () => { + expect(await screen.findByTestId('moreOptions')).toBeInTheDocument(); + }); + + const moreOptionsBtn = await screen.findByTestId('dropdown'); + act(() => { + fireEvent.click(moreOptionsBtn); + }); + + const replyBtn = await screen.findByTestId('replyBtn'); + + act(() => { + fireEvent.click(replyBtn); + }); + + const replyMsg = await screen.findByTestId('replyMsg'); + + await waitFor(() => { + expect(replyMsg).toBeInTheDocument(); + }); + + act(() => { + fireEvent.change(input, { target: { value: 'Test reply message' } }); + }); + expect(input.value).toBe('Test reply message'); + + act(() => { + fireEvent.click(sendBtn); + }); + + await wait(400); }); test('Selected contact is group chat', async () => { @@ -1223,7 +1409,6 @@ describe('Testing Chatroom Component [User Portal]', () => { ...MESSAGE_SENT_TO_CHAT_MOCK, ...CHAT_BY_ID_QUERY_MOCK, ...CHATS_LIST_MOCK, - ...GROUP_CHAT_BY_ID_QUERY_MOCK, ...SEND_MESSAGE_TO_CHAT_MOCK, ]; render( @@ -1245,7 +1430,6 @@ describe('Testing Chatroom Component [User Portal]', () => { ...MESSAGE_SENT_TO_CHAT_MOCK, ...CHAT_BY_ID_QUERY_MOCK, ...CHATS_LIST_MOCK, - ...GROUP_CHAT_BY_ID_QUERY_MOCK, ...SEND_MESSAGE_TO_CHAT_MOCK, ]; render( @@ -1326,11 +1510,11 @@ describe('Testing Chatroom Component [User Portal]', () => { ...MESSAGE_SENT_TO_CHAT_MOCK, ...CHAT_BY_ID_QUERY_MOCK, ...CHATS_LIST_MOCK, - ...GROUP_CHAT_BY_ID_QUERY_MOCK, ...SEND_MESSAGE_TO_CHAT_MOCK, ]; + const link2 = new StaticMockLink(mocks, true); render( - + diff --git a/src/components/UserPortal/ChatRoom/ChatRoom.tsx b/src/components/UserPortal/ChatRoom/ChatRoom.tsx index d07425e7a1..c23244a314 100644 --- a/src/components/UserPortal/ChatRoom/ChatRoom.tsx +++ b/src/components/UserPortal/ChatRoom/ChatRoom.tsx @@ -115,7 +115,6 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element { chatId: props.selectedContact, replyTo: replyToDirectMessage?._id, messageContent: newMessage, - type: 'STRING', }, }); @@ -166,6 +165,11 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element { .chatMessageBelongsTo['_id'] == props.selectedContact ) { chatRefetch(); + } else { + chatRefetch({ + id: messageSubscriptionData?.data.data.messageSentToChat + .chatMessageBelongsTo['_id'], + }); } }, }); diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx index fda0594b01..7eeaeacac1 100644 --- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx +++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { act, fireEvent, - prettyDOM, render, screen, waitFor, @@ -12,7 +11,6 @@ import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; import { - DIRECT_CHATS_LIST, USERS_CONNECTION_LIST, USER_JOINED_ORGANIZATIONS, } from 'GraphQl/Queries/Queries'; @@ -20,22 +18,12 @@ import { BrowserRouter } from 'react-router-dom'; import { Provider } from 'react-redux'; import { store } from 'state/store'; import i18nForTest from 'utils/i18nForTest'; -import { StaticMockLink } from 'utils/StaticMockLink'; import Chat from '../../../screens/UserPortal/Chat/Chat'; import { CREATE_CHAT, - CREATE_GROUP_CHAT, MESSAGE_SENT_TO_CHAT, - MESSAGE_SENT_TO_DIRECT_CHAT, - MESSAGE_SENT_TO_GROUP_CHAT, } from 'GraphQl/Mutations/OrganizationMutations'; -import { - CHATS_LIST, - CHAT_BY_ID, - DIRECT_CHAT_BY_ID, - GROUP_CHAT_BY_ID, - GROUP_CHAT_LIST, -} from 'GraphQl/Queries/PlugInQueries'; +import { CHATS_LIST, CHAT_BY_ID } from 'GraphQl/Queries/PlugInQueries'; import useLocalStorage from 'utils/useLocalstorage'; import userEvent from '@testing-library/user-event'; @@ -2240,7 +2228,7 @@ describe('Testing Create Group Chat Modal [User Portal]', () => { })), }); - test('Test open and close create new direct chat modal', async () => { + test('open and close create new direct chat modal', async () => { const mock = [ ...USER_JOINED_ORG_MOCK, ...GROUP_CHAT_BY_ID_QUERY_MOCK, @@ -2278,7 +2266,7 @@ describe('Testing Create Group Chat Modal [User Portal]', () => { fireEvent.click(closeButton); }); - test('Test create new group chat', async () => { + test('create new group chat', async () => { const mock = [ ...USER_JOINED_ORG_MOCK, ...GROUP_CHAT_BY_ID_QUERY_MOCK, @@ -2378,7 +2366,7 @@ describe('Testing Create Group Chat Modal [User Portal]', () => { // }); }, 3000); - test('Test add and remove user ', async () => { + test('add and remove user', async () => { setItem('userId', '1'); const mock = [ ...USER_JOINED_ORG_MOCK, diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx index 20933f806d..099a42310a 100644 --- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx +++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx @@ -33,7 +33,7 @@ interface InterfaceCreateGroupChatProps { chatsListRefetch: ( variables?: | Partial<{ - id: any; + id: string; }> | undefined, ) => Promise>; @@ -128,7 +128,6 @@ export default function CreateGroupChat({ ); function reset(): void { - setOrganizations([]); setTitle(''); setUserIds([]); setSelectedOrganization(''); @@ -186,7 +185,6 @@ export default function CreateGroupChat({ const organizations = joinedOrganizationsData.users[0]?.user?.joinedOrganizations || []; setOrganizations(organizations); - console.log(organizations); } }, [joinedOrganizationsData]); diff --git a/src/screens/UserPortal/Chat/Chat.test.tsx b/src/screens/UserPortal/Chat/Chat.test.tsx index 900edecc36..d5e8049687 100644 --- a/src/screens/UserPortal/Chat/Chat.test.tsx +++ b/src/screens/UserPortal/Chat/Chat.test.tsx @@ -893,69 +893,6 @@ const CHAT_BY_ID_QUERY_MOCK = [ }, ]; -const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [ - { - request: { - query: CHAT_BY_ID, - variables: { - id: '', - }, - }, - result: { - data: { - chatById: { - _id: '1', - isGroup: false, - creator: { - _id: '64378abd85008f171cf2990d', - firstName: 'Wilt', - lastName: 'Shepherd', - image: null, - email: 'testsuperadmin@example.com', - createdAt: '2023-04-13T04:53:17.742Z', - __typename: 'User', - }, - organization: null, - name: '', - createdAt: '2345678903456', - messages: [ - { - _id: '345678', - createdAt: '345678908765', - messageContent: 'Hello', - replyTo: null, - type: 'STRING', - sender: { - _id: '2', - firstName: 'Test', - lastName: 'User', - email: 'test@example.com', - image: '', - }, - }, - ], - users: [ - { - _id: '1', - firstName: 'Disha', - lastName: 'Talreja', - email: 'disha@example.com', - image: '', - }, - { - _id: '2', - firstName: 'Test', - lastName: 'User', - email: 'test@example.com', - image: '', - }, - ], - }, - }, - }, - }, -]; - const CHATS_LIST_MOCK = [ { request: {