Skip to content

Commit

Permalink
updated translation files
Browse files Browse the repository at this point in the history
  • Loading branch information
disha1202 committed Oct 29, 2024
1 parent 622e2b6 commit 431e77a
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 30 deletions.
3 changes: 2 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@
"newChat": "New Chat",
"newGroupChat": "New Group Chat",
"groupInfo": "Group Info",
"members": "Members"
"members": "Members",
"addMembers": "Add Members"
},
"userChatRoom": {
"selectContact": "Select a contact to start conversation",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@
"newChat": "nouvelle discussion",
"newGroupChat": "Nouvelle discussion de groupe",
"groupInfo": "Informations sur le groupe",
"members": "Membres"
"members": "Membres",
"addMembers": "Add Members"
},
"userChatRoom": {
"selectContact": "Sélectionnez un contact pour démarrer la conversation",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@
"newChat": "नई चैट",
"newGroupChat": "नया समूह चैट",
"groupInfo": "समूह जानकारी",
"members": "सदस्यों"
"members": "सदस्यों",
"addMembers": "Add Members"
},
"userChatRoom": {
"selectContact": "बातचीत शुरू करने के लिए एक संपर्क चुनें",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,8 @@
"newChat": "nueva charla",
"newGroupChat": "Nuevo chat grupal",
"groupInfo": "Información del grupo",
"members": "Miembros"
"members": "Miembros",
"addMembers": "Add Members"
},
"userChatRoom": {
"selectContact": "Seleccione un contacto para iniciar una conversación",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@
"newChat": "新聊天",
"newGroupChat": "新群聊",
"groupInfo": "集团信息",
"members": "会员"
"members": "会员",
"addMembers": "Add Members"
},
"userChatRoom": {
"selectContact": "选择联系人开始对话",
Expand Down
34 changes: 28 additions & 6 deletions src/GraphQl/Queries/PlugInQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ export const CHAT_BY_ID = gql`
email
image
}
admins {
_id
firstName
lastName
email
image
}
unseenMessagesByUsers
}
}
Expand All @@ -172,12 +179,6 @@ export const GROUP_CHAT_LIST = gql`
createdAt
messageContent
media
receiver {
_id
firstName
lastName
email
}
sender {
_id
firstName
Expand All @@ -196,6 +197,13 @@ export const GROUP_CHAT_LIST = gql`
email
image
}
admins {
_id
firstName
lastName
email
image
}
unseenMessagesByUsers
}
}
Expand Down Expand Up @@ -236,6 +244,13 @@ export const UNREAD_CHAT_LIST = gql`
email
image
}
admins {
_id
firstName
lastName
email
image
}
unseenMessagesByUsers
}
}
Expand Down Expand Up @@ -285,6 +300,13 @@ export const CHATS_LIST = gql`
email
image
}
admins {
_id
firstName
lastName
email
image
}
unseenMessagesByUsers
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/components/GroupChatDetails/GroupChatDetails.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
gap: 10px;
}

.groupMembersList {
display: flex;
align-items: center;
justify-content: space-between;
}

.groupMembersList p {
margin: 0;
color: #959595;
}

.membersImage {
width: 40px !important;
}
Expand Down Expand Up @@ -75,3 +86,9 @@
color: rgb(42, 197, 42);
cursor: pointer;
}

.chatUserDetails {
display: flex;
gap: 10px;
align-items: center;
}
168 changes: 168 additions & 0 deletions src/components/GroupChatDetails/GroupChatDetails.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import React from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import GroupChatDetails from './GroupChatDetails';
import { MockedProvider } from '@apollo/client/testing';
import {
ADD_USER_TO_GROUP_CHAT,
UPDATE_CHAT,
} from 'GraphQl/Mutations/OrganizationMutations';
import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';

const mockChat = {
_id: '1',
isGroup: true,
name: 'Test Group',
image: '',
messages: [],
admins: [
{
_id: '1',
firstName: 'Admin',
lastName: 'User',
email: '[email protected]',
},
],
users: [
{
_id: '2',
firstName: 'Test',
lastName: 'User',
email: '[email protected]',
},
],
unseenMessagesByUsers: JSON.parse('{"1": 0, "2": 0}'),
description: 'Test Description',
};

const mocks = [
{
request: {
query: USERS_CONNECTION_LIST,
variables: { firstName_contains: '', lastName_contains: '' },
},
result: {
data: {
users: [
{
user: {
_id: '3',
firstName: 'New',
lastName: 'User',
email: '[email protected]',
},
},
],
},
},
},
{
request: {
query: ADD_USER_TO_GROUP_CHAT,
variables: { userId: '3', chatId: '1' },
},
result: {
data: {
addUserToGroupChat: { success: true },
},
},
},
{
request: {
query: UPDATE_CHAT,
variables: { input: { _id: '1', image: '', name: 'Updated Group' } },
},
result: {
data: {
updateChat: { success: true },
},
},
},
];

describe('GroupChatDetails', () => {
it('renders correctly', () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
/>
</MockedProvider>,
);

expect(screen.getByText('Test Group')).toBeInTheDocument();
expect(screen.getByText('Test Description')).toBeInTheDocument();
});

it('opens and closes modals correctly', () => {
const toggleGroupChatDetailsModal = jest.fn();
render(
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={toggleGroupChatDetailsModal}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
/>
</MockedProvider>,
);

fireEvent.click(screen.getByTestId('createDirectChat'));
expect(toggleGroupChatDetailsModal).toHaveBeenCalled();
});

it('edits chat title', async () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
/>
</MockedProvider>,
);

fireEvent.click(screen.getByText('Test Group'));
fireEvent.change(screen.getByDisplayValue('Test Group'), {
target: { value: 'Updated Group' },
});
fireEvent.click(screen.getByText('✔'));

await waitFor(() => {
expect(screen.getByText('Updated Group')).toBeInTheDocument();
});
});

it('opens add user modal and adds user', async () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<GroupChatDetails
toggleGroupChatDetailsModal={jest.fn()}
groupChatDetailsModalisOpen={true}
chat={mockChat}
chatRefetch={jest.fn()}
/>
</MockedProvider>,
);

fireEvent.click(screen.getByText('Add Members'));
expect(screen.getByTestId('addExistingUserModal')).toBeInTheDocument();

fireEvent.change(screen.getByPlaceholderText('searchFullName'), {
target: { value: 'New User' },
});
fireEvent.click(screen.getByTestId('submitBtn'));

await waitFor(() => {
expect(screen.getByText('New User')).toBeInTheDocument();
});

fireEvent.click(screen.getByText('Add'));
await waitFor(() => {
expect(screen.queryByText('New User')).not.toBeInTheDocument();
});
});
});
Loading

0 comments on commit 431e77a

Please sign in to comment.