@@ -179,6 +182,6 @@ function organizationAgendaCategory(): JSX.Element {
/>
);
-}
+};
export default organizationAgendaCategory;
diff --git a/src/screens/OrganizationAgendaCategory/OrganizationAgendaCategoryErrorMocks.ts b/src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategoryErrorMocks.ts
similarity index 100%
rename from src/screens/OrganizationAgendaCategory/OrganizationAgendaCategoryErrorMocks.ts
rename to src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategoryErrorMocks.ts
diff --git a/src/screens/OrganizationAgendaCategory/OrganizationAgendaCategoryMocks.ts b/src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategoryMocks.ts
similarity index 100%
rename from src/screens/OrganizationAgendaCategory/OrganizationAgendaCategoryMocks.ts
rename to src/components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategoryMocks.ts
diff --git a/src/components/DeleteOrg/DeleteOrg.module.css b/src/components/OrgSettings/General/DeleteOrg/DeleteOrg.module.css
similarity index 100%
rename from src/components/DeleteOrg/DeleteOrg.module.css
rename to src/components/OrgSettings/General/DeleteOrg/DeleteOrg.module.css
diff --git a/src/components/DeleteOrg/DeleteOrg.test.tsx b/src/components/OrgSettings/General/DeleteOrg/DeleteOrg.test.tsx
similarity index 100%
rename from src/components/DeleteOrg/DeleteOrg.test.tsx
rename to src/components/OrgSettings/General/DeleteOrg/DeleteOrg.test.tsx
diff --git a/src/components/DeleteOrg/DeleteOrg.tsx b/src/components/OrgSettings/General/DeleteOrg/DeleteOrg.tsx
similarity index 100%
rename from src/components/DeleteOrg/DeleteOrg.tsx
rename to src/components/OrgSettings/General/DeleteOrg/DeleteOrg.tsx
diff --git a/src/components/OrgSettings/General/GeneralSettings.tsx b/src/components/OrgSettings/General/GeneralSettings.tsx
new file mode 100644
index 0000000000..4dbca1b6eb
--- /dev/null
+++ b/src/components/OrgSettings/General/GeneralSettings.tsx
@@ -0,0 +1,73 @@
+import React, { type FC } from 'react';
+import { Card, Col, Form, Row } from 'react-bootstrap';
+import styles from 'screens/OrgSettings/OrgSettings.module.css';
+import OrgProfileFieldSettings from './OrgProfileFieldSettings/OrgProfileFieldSettings';
+import ChangeLanguageDropDown from 'components/ChangeLanguageDropdown/ChangeLanguageDropDown';
+import DeleteOrg from './DeleteOrg/DeleteOrg';
+import OrgUpdate from './OrgUpdate/OrgUpdate';
+import { useTranslation } from 'react-i18next';
+
+/**
+ * Props for the `GeneralSettings` component.
+ */
+interface InterfaceGeneralSettingsProps {
+ orgId: string;
+}
+
+/**
+ * A component for displaying general settings for an organization.
+ *
+ * @param props - The properties passed to the component.
+ * @returns The `GeneralSettings` component.
+ */
+const GeneralSettings: FC
= ({ orgId }) => {
+ const { t } = useTranslation('translation', {
+ keyPrefix: 'orgSettings',
+ });
+
+ return (
+
+
+
+
+
{t('updateOrganization')}
+
+
+ {/* Render organization update component */}
+
+
+
+
+
+
+
+
+
+
+
+ {t('changeLanguage')}
+
+ {/* Render language change dropdown component */}
+
+
+
+
+
+
+
+
+
{t('manageCustomFields')}
+
+
+ {/* Render organization profile field settings component */}
+
+
+
+
+
+ );
+};
+
+export default GeneralSettings;
diff --git a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.module.css b/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.module.css
similarity index 100%
rename from src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.module.css
rename to src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.module.css
diff --git a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.test.tsx b/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.test.tsx
similarity index 100%
rename from src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.test.tsx
rename to src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.test.tsx
diff --git a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx b/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx
similarity index 97%
rename from src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx
rename to src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx
index 8fc9da0290..dcb6992e21 100644
--- a/src/components/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx
+++ b/src/components/OrgSettings/General/OrgProfileFieldSettings/OrgProfileFieldSettings.tsx
@@ -13,14 +13,7 @@ import { useTranslation } from 'react-i18next';
import { toast } from 'react-toastify';
import EditOrgCustomFieldDropDown from 'components/EditCustomFieldDropDown/EditCustomFieldDropDown';
import { useParams } from 'react-router-dom';
-
-/**
- * Interface for custom field data
- */
-export interface InterfaceCustomFieldData {
- type: string;
- name: string;
-}
+import type { InterfaceCustomFieldData } from 'utils/interfaces';
/**
* Component for managing organization profile field settings
diff --git a/src/components/OrgUpdate/OrgUpdate.module.css b/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.module.css
similarity index 100%
rename from src/components/OrgUpdate/OrgUpdate.module.css
rename to src/components/OrgSettings/General/OrgUpdate/OrgUpdate.module.css
diff --git a/src/components/OrgUpdate/OrgUpdate.test.tsx b/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.test.tsx
similarity index 100%
rename from src/components/OrgUpdate/OrgUpdate.test.tsx
rename to src/components/OrgSettings/General/OrgUpdate/OrgUpdate.test.tsx
diff --git a/src/components/OrgUpdate/OrgUpdate.tsx b/src/components/OrgSettings/General/OrgUpdate/OrgUpdate.tsx
similarity index 100%
rename from src/components/OrgUpdate/OrgUpdate.tsx
rename to src/components/OrgSettings/General/OrgUpdate/OrgUpdate.tsx
diff --git a/src/components/OrgUpdate/OrgUpdateMocks.ts b/src/components/OrgSettings/General/OrgUpdate/OrgUpdateMocks.ts
similarity index 100%
rename from src/components/OrgUpdate/OrgUpdateMocks.ts
rename to src/components/OrgSettings/General/OrgUpdate/OrgUpdateMocks.ts
diff --git a/src/components/OrganizationDashCards/CardItem.tsx b/src/components/OrganizationDashCards/CardItem.tsx
index 8ad99194cf..a7cfaa0f57 100644
--- a/src/components/OrganizationDashCards/CardItem.tsx
+++ b/src/components/OrganizationDashCards/CardItem.tsx
@@ -1,9 +1,9 @@
import React from 'react';
-import { ReactComponent as EventsIcon } from 'assets/svgs/cardItemEvent.svg';
-import { ReactComponent as PostsIcon } from 'assets/svgs/post.svg';
-import { ReactComponent as MarkerIcon } from 'assets/svgs/cardItemLocation.svg';
-import { ReactComponent as DateIcon } from 'assets/svgs/cardItemDate.svg';
-import { ReactComponent as UserIcon } from 'assets/svgs/user.svg';
+import EventsIcon from 'assets/svgs/cardItemEvent.svg?react';
+import PostsIcon from 'assets/svgs/post.svg?react';
+import MarkerIcon from 'assets/svgs/cardItemLocation.svg?react';
+import DateIcon from 'assets/svgs/cardItemDate.svg?react';
+import UserIcon from 'assets/svgs/user.svg?react';
import dayjs from 'dayjs';
import styles from './CardItem.module.css';
import { PersonAddAlt1Rounded } from '@mui/icons-material';
diff --git a/src/components/OrganizationScreen/OrganizationScreen.tsx b/src/components/OrganizationScreen/OrganizationScreen.tsx
index e0781d996d..7bd2119a82 100644
--- a/src/components/OrganizationScreen/OrganizationScreen.tsx
+++ b/src/components/OrganizationScreen/OrganizationScreen.tsx
@@ -1,9 +1,10 @@
import LeftDrawerOrg from 'components/LeftDrawerOrg/LeftDrawerOrg';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { useDispatch, useSelector } from 'react-redux';
+import { useSelector } from 'react-redux';
import { Navigate, Outlet, useLocation, useParams } from 'react-router-dom';
import { updateTargets } from 'state/action-creators';
+import { useAppDispatch } from 'state/hooks';
import type { RootState } from 'state/reducers';
import type { TargetsType } from 'state/reducers/routesReducer';
import styles from './OrganizationScreen.module.css';
@@ -44,7 +45,7 @@ const OrganizationScreen = (): JSX.Element => {
} = useSelector((state: RootState) => state.appRoutes);
const { targets } = appRoutes;
- const dispatch = useDispatch();
+ const dispatch = useAppDispatch();
// Update targets whenever the organization ID changes
useEffect(() => {
diff --git a/src/components/PaginationList/PaginationList.tsx b/src/components/PaginationList/PaginationList.tsx
index ca02db3b4c..430e8ba1aa 100644
--- a/src/components/PaginationList/PaginationList.tsx
+++ b/src/components/PaginationList/PaginationList.tsx
@@ -67,7 +67,6 @@ const PaginationList = ({
({
@@ -104,13 +118,16 @@ describe('ProfileDropdown Component', () => {
,
);
+
await act(async () => {
userEvent.click(screen.getByTestId('togDrop'));
});
userEvent.click(screen.getByTestId('logoutBtn'));
+
expect(global.window.location.pathname).toBe('/');
});
+
describe('Member screen routing testing', () => {
test('member screen', async () => {
render(
diff --git a/src/components/ProfileDropdown/ProfileDropdown.tsx b/src/components/ProfileDropdown/ProfileDropdown.tsx
index 27fb6951c7..059e5b910a 100644
--- a/src/components/ProfileDropdown/ProfileDropdown.tsx
+++ b/src/components/ProfileDropdown/ProfileDropdown.tsx
@@ -7,6 +7,7 @@ import styles from './ProfileDropdown.module.css';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import { useMutation } from '@apollo/client';
import { useTranslation } from 'react-i18next';
+import useSession from 'utils/useSession';
/**
* Renders a profile dropdown menu for the user.
@@ -21,6 +22,7 @@ import { useTranslation } from 'react-i18next';
* @returns JSX.Element - The profile dropdown menu.
*/
const profileDropdown = (): JSX.Element => {
+ const { endSession } = useSession();
const { t: tCommon } = useTranslation('common');
const [revokeRefreshToken] = useMutation(REVOKE_REFRESH_TOKEN);
const { getItem } = useLocalStorage();
@@ -45,6 +47,7 @@ const profileDropdown = (): JSX.Element => {
console.error('Error revoking refresh token:', error);
}
localStorage.clear();
+ endSession();
navigate('/');
};
const MAX_NAME_LENGTH = 20;
diff --git a/src/components/UpdateSession/UpdateSession.css b/src/components/UpdateSession/UpdateSession.css
new file mode 100644
index 0000000000..073bbf973d
--- /dev/null
+++ b/src/components/UpdateSession/UpdateSession.css
@@ -0,0 +1,96 @@
+/* Card styles */
+.update-timeout-card {
+ width: 700px;
+ background: #ffffff;
+ border: none;
+ border-radius: 16px;
+ filter: drop-shadow(0px 4px 15.3px rgba(0, 0, 0, 0.08));
+ padding: 20px;
+}
+
+.update-timeout-card-header {
+ background: none;
+ padding: 16px;
+ border-bottom: none;
+}
+
+.update-timeout-card-title {
+ font-family: 'Lato', sans-serif;
+ font-weight: 600;
+ font-size: 24px;
+ color: #000000;
+}
+
+.update-timeout-card-body {
+ padding: 20px;
+}
+
+.update-timeout-current {
+ font-family: 'Lato', sans-serif;
+ font-weight: 400;
+ font-size: 16px;
+ color: #000000;
+ margin-bottom: 20px; /* Increased margin to create more space */
+}
+
+.update-timeout-label {
+ font-family: 'Lato', sans-serif;
+ font-weight: 400;
+ font-size: 16px;
+ color: #000000;
+ margin-bottom: 10px; /* Keep the same margin to maintain spacing with the slider */
+}
+
+.update-timeout-labels-container {
+ display: flex;
+ flex-direction: column;
+ align-items: start;
+}
+
+.update-timeout-value {
+ color: #14ae5c;
+ font-weight: bold;
+}
+
+.update-timeout-slider-labels {
+ display: flex;
+ justify-content: space-between;
+ font-size: 0.9rem;
+ color: #757575;
+}
+
+.update-timeout-button-container {
+ display: flex;
+ justify-content: right;
+ margin-top: 20px;
+}
+
+.update-timeout-button {
+ width: 112px;
+ height: 36px;
+ background: #31bb6b;
+ border-radius: 6px;
+ font-family: 'Lato', sans-serif;
+ font-weight: 500;
+ font-size: 16px;
+ color: #ffffff;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: none;
+ box-shadow: none;
+}
+
+.update-timeout-button:hover {
+ background-color: #28a745;
+ border-color: #28a745;
+ box-shadow: none;
+}
+
+.update-timeout-button:active {
+ transform: scale(0.98);
+}
+
+.update-timeout-slider-container {
+ position: relative;
+}
diff --git a/src/components/UpdateSession/UpdateSession.test.tsx b/src/components/UpdateSession/UpdateSession.test.tsx
new file mode 100644
index 0000000000..ce0a868820
--- /dev/null
+++ b/src/components/UpdateSession/UpdateSession.test.tsx
@@ -0,0 +1,346 @@
+import React from 'react';
+import { MockedProvider } from '@apollo/client/testing';
+import {
+ render,
+ screen,
+ act,
+ within,
+ fireEvent,
+ waitFor,
+} from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import 'jest-localstorage-mock';
+import 'jest-location-mock';
+import { I18nextProvider } from 'react-i18next';
+import { BrowserRouter } from 'react-router-dom';
+import { toast } from 'react-toastify';
+import UpdateTimeout from './UpdateSession';
+import i18n from 'utils/i18nForTest';
+import { GET_COMMUNITY_SESSION_TIMEOUT_DATA } from 'GraphQl/Queries/Queries';
+import { UPDATE_SESSION_TIMEOUT } from 'GraphQl/Mutations/mutations';
+import { errorHandler } from 'utils/errorHandler';
+
+const MOCKS = [
+ {
+ request: {
+ query: GET_COMMUNITY_SESSION_TIMEOUT_DATA,
+ },
+ result: {
+ data: {
+ getCommunityData: {
+ timeout: 30,
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GET_COMMUNITY_SESSION_TIMEOUT_DATA,
+ },
+ result: {
+ data: {
+ getCommunityData: null,
+ },
+ },
+ },
+ {
+ request: {
+ query: UPDATE_SESSION_TIMEOUT,
+ variables: {
+ timeout: 30,
+ },
+ },
+ result: {
+ data: {
+ updateSessionTimeout: true,
+ },
+ },
+ },
+];
+
+async function wait(ms = 100): Promise {
+ await act(() => {
+ return new Promise((resolve) => {
+ setTimeout(resolve, ms);
+ });
+ });
+}
+
+jest.mock('react-toastify', () => ({
+ toast: {
+ success: jest.fn(),
+ warn: jest.fn(),
+ error: jest.fn(),
+ },
+}));
+
+jest.mock('utils/errorHandler', () => ({
+ errorHandler: jest.fn(),
+}));
+
+describe('Testing UpdateTimeout Component', () => {
+ let consoleWarnSpy: jest.SpyInstance;
+
+ beforeEach(() => {
+ consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
+ });
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
+ test('Should handle minimum slider value correctly', async () => {
+ const mockOnValueChange = jest.fn();
+
+ render(
+
+
+ ,
+ );
+
+ const slider = await screen.findByTestId('slider-thumb');
+
+ // Simulate dragging to minimum value
+ userEvent.click(slider, {
+ // Simulate clicking on the slider to focus
+ clientX: -999, // Adjust the clientX to simulate different slider positions
+ });
+
+ expect(mockOnValueChange).toHaveBeenCalledWith(15); // Adjust based on slider min value
+ });
+
+ test('Should handle maximum slider value correctly', async () => {
+ const mockOnValueChange = jest.fn();
+
+ render(
+
+
+ ,
+ );
+
+ const slider = await screen.findByTestId('slider-thumb');
+
+ // Simulate dragging to maximum value
+ userEvent.click(slider, {
+ // Simulate clicking on the slider to focus
+ clientX: 999, // Adjust the clientX to simulate different slider positions
+ });
+
+ expect(mockOnValueChange).toHaveBeenCalledWith(60); // Adjust based on slider max value
+ });
+
+ test('Should not update value if an invalid value is passed', async () => {
+ const mockOnValueChange = jest.fn();
+
+ render(
+
+
+ ,
+ );
+
+ const slider = await screen.findByTestId('slider-thumb');
+
+ // Simulate invalid value handling
+ userEvent.click(slider, {
+ // Simulate clicking on the slider to focus
+ clientX: 0, // Adjust the clientX to simulate different slider positions
+ });
+
+ // Ensure onValueChange is not called with invalid values
+ expect(mockOnValueChange).not.toHaveBeenCalled();
+ });
+
+ test('Should update slider value on user interaction', async () => {
+ const mockOnValueChange = jest.fn();
+
+ render(
+
+
+ ,
+ );
+
+ // Wait for the slider to be present
+ const slider = await screen.findByTestId('slider-thumb');
+
+ // Simulate slider interaction
+ userEvent.type(slider, '45'); // Simulate typing value
+
+ // Assert that the callback was called with the expected value
+ expect(mockOnValueChange).toHaveBeenCalledWith(expect.any(Number)); // Adjust as needed
+ });
+
+ test('Components should render properly', async () => {
+ render(
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ // Use getAllByText to get all elements with "Update Timeout" text
+ const updateTimeoutElements = screen.getAllByText(/Update Timeout/i);
+ expect(updateTimeoutElements).toHaveLength(1); // Check if there are exactly 2 elements with this text
+
+ expect(screen.getByText(/Current Timeout/i)).toBeInTheDocument();
+ expect(screen.getByText(/15 min/i)).toBeInTheDocument();
+
+ // Locate the parent element first
+ const sliderLabelsContainer = screen.getByTestId('slider-labels');
+
+ // Use within to query inside the parent element
+ const sliderLabels = within(sliderLabelsContainer);
+
+ // Check for the specific text within the parent element
+ expect(sliderLabels.getByText('30 min')).toBeInTheDocument();
+
+ expect(screen.getByText(/45 min/i)).toBeInTheDocument();
+ expect(screen.getByText(/60 min/i)).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /Update/i })).toBeInTheDocument();
+ });
+
+ test('Should update session timeout', async () => {
+ render(
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const submitButton = screen.getByTestId('update-button');
+ userEvent.click(submitButton);
+
+ // Wait for the toast success call
+
+ await wait();
+
+ expect(toast.success).toHaveBeenCalledWith(
+ expect.stringContaining('Successfully updated the Profile Details.'),
+ );
+ });
+
+ test('Should handle query errors', async () => {
+ const errorMocks = [
+ {
+ request: {
+ query: GET_COMMUNITY_SESSION_TIMEOUT_DATA,
+ },
+ error: new Error('An error occurred'),
+ },
+ ];
+
+ render(
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ expect(errorHandler).toHaveBeenCalled();
+ });
+
+ test('Should handle update errors', async () => {
+ const errorMocks = [
+ {
+ request: {
+ query: GET_COMMUNITY_SESSION_TIMEOUT_DATA,
+ },
+ result: {
+ data: {
+ getCommunityData: {
+ timeout: 30,
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: GET_COMMUNITY_SESSION_TIMEOUT_DATA,
+ },
+ result: {
+ data: {
+ getCommunityData: null,
+ },
+ },
+ },
+ {
+ request: {
+ query: UPDATE_SESSION_TIMEOUT,
+ variables: { timeout: 30 },
+ },
+ error: new Error('An error occurred'),
+ },
+ ];
+
+ render(
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ const submitButton = screen.getByTestId('update-button');
+ userEvent.click(submitButton);
+
+ await wait();
+
+ expect(errorHandler).toHaveBeenCalled();
+ });
+
+ test('Should handle null community object gracefully', async () => {
+ render(
+
+
+
+
+
+
+ ,
+ );
+
+ await wait();
+
+ // Assertions to verify the component handles null community object correctly
+ // Use getAllByText to get all elements with "Update Timeout" text
+ const updateTimeoutElements = screen.getAllByText(/Update Timeout/i);
+ expect(updateTimeoutElements).toHaveLength(1); // Check if there are exactly 2 elements with this text
+
+ expect(screen.getByText(/Current Timeout/i)).toBeInTheDocument();
+
+ // Locate the parent element first
+ const sliderLabelsContainer = screen.getByTestId('slider-labels');
+
+ // Use within to query inside the parent element
+ const sliderLabels = within(sliderLabelsContainer);
+
+ // Check for the specific text within the parent element
+ expect(sliderLabels.getByText('15 min')).toBeInTheDocument();
+
+ expect(screen.getByText(/30 min/i)).toBeInTheDocument();
+ expect(screen.getByText(/45 min/i)).toBeInTheDocument();
+ expect(screen.getByText(/60 min/i)).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /Update/i })).toBeInTheDocument();
+
+ // Check if the component displays a default value or handles the null state appropriately
+ expect(screen.getByText(/No timeout set/i)).toBeInTheDocument();
+ });
+});
diff --git a/src/components/UpdateSession/UpdateSession.tsx b/src/components/UpdateSession/UpdateSession.tsx
new file mode 100644
index 0000000000..f49970ebaa
--- /dev/null
+++ b/src/components/UpdateSession/UpdateSession.tsx
@@ -0,0 +1,202 @@
+import React, { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Card, Button, Form } from 'react-bootstrap';
+import Box from '@mui/material/Box';
+import Slider from '@mui/material/Slider';
+import { useMutation, useQuery } from '@apollo/client';
+import { GET_COMMUNITY_SESSION_TIMEOUT_DATA } from 'GraphQl/Queries/Queries';
+import { toast } from 'react-toastify';
+import { errorHandler } from 'utils/errorHandler';
+import { UPDATE_SESSION_TIMEOUT } from 'GraphQl/Mutations/mutations';
+import './UpdateSession.css';
+import Loader from 'components/Loader/Loader';
+
+/**
+ * Component for updating the session timeout for a community.
+ *
+ * This component fetches the current session timeout value from the server
+ * and allows the user to update it using a slider.
+ *
+ * The component also handles form submission, making a mutation request to update the session timeout.
+ *
+ * @returns JSX.Element - The rendered component.
+ */
+
+interface TestInterfaceUpdateTimeoutProps {
+ onValueChange?: (value: number) => void;
+}
+
+const UpdateTimeout: React.FC = ({
+ onValueChange,
+}): JSX.Element => {
+ const { t } = useTranslation('translation', {
+ keyPrefix: 'communityProfile',
+ });
+
+ const [timeout, setTimeout] = useState(30);
+ const [communityTimeout, setCommunityTimeout] = useState(
+ 30,
+ ); // Timeout from database for the community
+
+ const {
+ data,
+ loading,
+ error: queryError,
+ } = useQuery(GET_COMMUNITY_SESSION_TIMEOUT_DATA);
+ const [uploadSessionTimeout] = useMutation(UPDATE_SESSION_TIMEOUT);
+
+ type TimeoutDataType = {
+ timeout: number;
+ };
+
+ /**
+ * Effect that fetches the current session timeout from the server and sets the initial state.
+ * If there is an error in fetching the data, it is handled using the error handler.
+ */
+ React.useEffect(() => {
+ if (queryError) {
+ errorHandler(t, queryError as Error);
+ }
+
+ const SessionTimeoutData: TimeoutDataType | undefined =
+ data?.getCommunityData;
+
+ if (SessionTimeoutData && SessionTimeoutData.timeout !== null) {
+ setCommunityTimeout(SessionTimeoutData.timeout);
+ setTimeout(SessionTimeoutData.timeout);
+ } else {
+ setCommunityTimeout(undefined); // Handle null or undefined data
+ }
+ }, [data, queryError]);
+
+ /**
+ * Handles changes to the slider value and updates the timeout state.
+ *
+ * @param e - The event triggered by slider movement.
+ */
+ const handleOnChange = (
+ e: Event | React.ChangeEvent,
+ ): void => {
+ if ('target' in e && e.target) {
+ const target = e.target as HTMLInputElement;
+ // Ensure the value is a number and not NaN
+ const value = parseInt(target.value, 10);
+ if (!Number.isNaN(value)) {
+ setTimeout(value);
+ if (onValueChange) {
+ onValueChange(value);
+ }
+ } else {
+ console.warn('Invalid timeout value:', target.value);
+ }
+ }
+ };
+
+ /**
+ * Handles form submission to update the session timeout.
+ * It makes a mutation request to update the timeout value on the server.
+ * If the update is successful, a success toast is shown, and the state is updated.
+ *
+ * @param e - The event triggered by form submission.
+ */
+ const handleOnSubmit = async (
+ e: React.FormEvent,
+ ): Promise => {
+ e.preventDefault();
+ try {
+ await uploadSessionTimeout({
+ variables: {
+ timeout: timeout,
+ },
+ });
+
+ toast.success(t('profileChangedMsg'));
+ setCommunityTimeout(timeout);
+ } catch (error: unknown) {
+ /* istanbul ignore next */
+ errorHandler(t, error as Error);
+ }
+ };
+
+ // Show a loader while the data is being fetched
+ if (loading) {
+ return ;
+ }
+
+ return (
+ <>
+
+
+ Login Session Timeout
+
+
+
+
+
+ >
+ );
+};
+
+export default UpdateTimeout;
diff --git a/src/components/UserPortal/ChatRoom/ChatRoom.module.css b/src/components/UserPortal/ChatRoom/ChatRoom.module.css
index 21f76f2a3e..5fc98351cd 100644
--- a/src/components/UserPortal/ChatRoom/ChatRoom.module.css
+++ b/src/components/UserPortal/ChatRoom/ChatRoom.module.css
@@ -24,6 +24,7 @@
padding-bottom: 5px;
align-items: center;
margin-top: 5px;
+ gap: 10px;
}
.contactImage {
diff --git a/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx b/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx
index 1d7a3d0efc..cfe430a589 100644
--- a/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx
+++ b/src/components/UserPortal/ChatRoom/ChatRoom.test.tsx
@@ -9,30 +9,20 @@ import {
} from '@testing-library/react';
import { MockSubscriptionLink, MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
-
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 {
- DIRECT_CHAT_BY_ID,
- GROUP_CHAT_BY_ID,
-} from 'GraphQl/Queries/PlugInQueries';
+import { CHATS_LIST, CHAT_BY_ID } from 'GraphQl/Queries/PlugInQueries';
import {
- MESSAGE_SENT_TO_DIRECT_CHAT,
- MESSAGE_SENT_TO_GROUP_CHAT,
- SEND_MESSAGE_TO_DIRECT_CHAT,
- SEND_MESSAGE_TO_GROUP_CHAT,
+ MESSAGE_SENT_TO_CHAT,
+ SEND_MESSAGE_TO_CHAT,
} from 'GraphQl/Mutations/OrganizationMutations';
-import userEvent from '@testing-library/user-event';
import ChatRoom from './ChatRoom';
import { useLocalStorage } from 'utils/useLocalstorage';
const { setItem } = useLocalStorage();
-const link = new StaticMockLink([], true);
-
async function wait(ms = 100): Promise {
await act(() => {
return new Promise((resolve) => {
@@ -41,453 +31,25 @@ async function wait(ms = 100): Promise {
});
}
-const SEND_MESSAGE_TO_DIRECT_CHAT_MOCK = [
- {
- request: {
- query: SEND_MESSAGE_TO_DIRECT_CHAT,
- variables: {
- messageContent: 'Hello',
- chatId: '1',
- },
- },
- result: {
- data: {
- sendMessageToDirectChat: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_DIRECT_CHAT,
- variables: {
- chatId: '1',
- replyTo: '3',
- messageContent: 'Test reply message',
- },
- },
- result: {
- data: {
- sendMessageToDirectChat: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_DIRECT_CHAT,
- variables: {
- chatId: '1',
- replyTo: '4',
- messageContent: 'Test reply message',
- },
- },
- result: {
- data: {
- sendMessageToDirectChat: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_DIRECT_CHAT,
- variables: {
- chatId: '1',
- replyTo: '1',
- messageContent: 'Test reply message',
- },
- },
- result: {
- data: {
- sendMessageToDirectChat: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- receiver: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
-];
-
-const SEND_MESSAGE_TO_GROUP_CHAT_MOCK = [
- {
- request: {
- query: SEND_MESSAGE_TO_GROUP_CHAT,
- variables: {
- messageContent: 'Test message',
- chatId: '1',
- },
- },
- result: {
- data: {
- sendMessageToGroupChat: {
- _id: '123',
- createdAt: '',
- messageContent: 'Test Message',
- replyTo: null,
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_GROUP_CHAT,
- variables: { chatId: '1', replyTo: undefined, messageContent: 'Hello' },
- },
- result: {
- data: {
- sendMessageToGroupChat: {
- _id: '123',
- createdAt: '',
- messageContent: 'Test Message',
- replyTo: null,
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_GROUP_CHAT,
- variables: {
- messageContent: 'Test reply message',
- replyTo: '3',
- chatId: '1',
- },
- },
- result: {
- data: {
- sendMessageToGroupChat: {
- _id: '2',
- createdAt: '',
- messageContent: 'Test reply message',
- replyTo: {
- _id: '3',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- updatedAt: '345678908765',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_GROUP_CHAT,
- variables: {
- messageContent: 'Test reply message',
- replyTo: '4',
- chatId: '1',
- },
- },
- result: {
- data: {
- sendMessageToGroupChat: {
- _id: '2',
- createdAt: '',
- messageContent: 'Test reply message',
- replyTo: {
- _id: '3',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- updatedAt: '345678908765',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
- {
- request: {
- query: SEND_MESSAGE_TO_GROUP_CHAT,
- variables: {
- messageContent: 'Test reply message',
- replyTo: '1',
- chatId: '1',
- },
- },
- result: {
- data: {
- sendMessageToGroupChat: {
- _id: '2',
- createdAt: '',
- messageContent: 'Test reply message',
- replyTo: {
- _id: '3',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- updatedAt: '345678908765',
- },
- sender: {
- _id: '',
- firstName: '',
- lastName: '',
- },
- updatedAt: '',
- },
- },
- },
- },
-];
-
-const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
- {
- request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
- variables: {
- userId: null,
- },
- },
- result: {
- data: {
- messageSentToGroupChat: {
- _id: '123',
- createdAt: '2024-07-10T17:16:33.248Z',
- groupChatMessageBelongsTo: {
- _id: '',
- },
- messageContent: 'Test message',
- replyTo: null,
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
- variables: {
- userId: null,
- },
- },
- result: {
- data: {
- messageSentToGroupChat: {
- _id: '1',
- createdAt: '2024-07-10T17:16:33.248Z',
- groupChatMessageBelongsTo: {
- _id: '',
- },
- messageContent: 'Test message',
- replyTo: {
- _id: '123',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test message',
- replyTo: null,
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
+const MESSAGE_SENT_TO_CHAT_MOCK = [
{
request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
userId: null,
},
},
result: {
data: {
- messageSentToGroupChat: {
+
+ messageSentToChat: {
_id: '668ec1f1364e03ac47a151',
createdAt: '2024-07-10T17:16:33.248Z',
- groupChatMessageBelongsTo: {
- _id: '',
+ chatMessageBelongsTo: {
+ _id: '1',
},
messageContent: 'Test ',
+ type: 'STRING',
replyTo: null,
sender: {
_id: '64378abd85008f171cf2990d',
@@ -502,21 +64,22 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
},
{
request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
userId: '2',
},
},
result: {
data: {
- messageSentToGroupChat: {
+ messageSentToChat: {
_id: '668ec1f1df364e03ac47a151',
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
- groupChatMessageBelongsTo: {
- _id: '',
+ chatMessageBelongsTo: {
+ _id: '1',
},
replyTo: null,
+ type: 'STRING',
sender: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -530,679 +93,67 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
},
{
request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
- variables: {
- userId: '1',
- },
- },
- result: {
- data: {
- messageSentToGroupChat: {
- _id: '668ec1f13603ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- groupChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: {
- _id: '668ec1f1df364e03ac47a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- groupChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
-];
-
-const MESSAGE_SENT_TO_DIRECT_CHAT_MOCK = [
- {
- request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
- variables: {
- userId: '1',
- },
- },
- result: {
- data: {
- messageSentToDirectChat: {
- _id: '668ec1f1364e03ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
- variables: {
- userId: '2',
- },
- },
- result: {
- data: {
- messageSentToDirectChat: {
- _id: '668ec1f1364e03ac4697vgfa151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
- {
- request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
- variables: {
- userId: null,
- },
- },
- result: {
- data: {
- messageSentToDirectChat: {
- _id: '6ec1f1364e03ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- directChatMessageBelongsTo: {
- _id: '',
- },
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
-];
-
-const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '1',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '4',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '1',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '4',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '1',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '4',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '1',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '4',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '1',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '3',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- updatedAt: '345678908765',
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '2',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '2',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '1',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '1',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- 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 GROUP_CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: GROUP_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '4',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
+ query: MESSAGE_SENT_TO_CHAT,
+ variables: {
+ userId: '1',
+ },
+ },
+ result: {
+ data: {
+ messageSentToChat: {
+ _id: '668ec1f13603ac4697a151',
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ chatMessageBelongsTo: {
+ _id: '1',
+ },
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
},
},
},
},
+];
+
+const CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
id: '1',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
+ chatById: {
+ _id: '1',
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ 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: '4',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1227,27 +178,6 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
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: '',
- },
],
},
},
@@ -1255,23 +185,35 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
id: '1',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
+ 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',
- title: 'Test Group Chat',
messages: [
{
_id: '4',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1296,27 +238,6 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
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: '',
- },
],
},
},
@@ -1324,23 +245,35 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
- id: '1',
+ id: '',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
+ 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',
- title: 'Test Group Chat',
messages: [
{
_id: '4',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1365,51 +298,525 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
email: 'test@example.com',
image: '',
},
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
],
},
},
},
},
+];
+
+const CHATS_LIST_MOCK = [
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: null,
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844ghjefc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: 'ujhgtrdtyuiop',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: CHATS_LIST,
+ variables: {
+ id: '1',
+ },
+ },
+ result: {
+ data: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
+ },
+ },
+ },
+];
+
+const GROUP_CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
- id: '1',
+ id: '',
},
},
result: {
data: {
- groupChatById: {
- _id: '1',
+ chatById: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
- _id: '3',
+ _id: '2',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1417,7 +824,6 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
email: 'test@example.com',
image: '',
},
- updatedAt: '345678908765',
},
],
users: [
@@ -1463,23 +869,38 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
- id: '2',
+ id: '1',
},
},
result: {
data: {
- groupChatById: {
+ chatById: {
_id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
- _id: '2',
+ _id: '1',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1532,23 +953,38 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
- id: '',
+ id: '1',
},
},
result: {
data: {
- groupChatById: {
+ chatById: {
_id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
_id: '1',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1599,71 +1035,92 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
},
},
+];
+
+const SEND_MESSAGE_TO_CHAT_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: SEND_MESSAGE_TO_CHAT,
variables: {
- id: '',
+ chatId: '1',
+ replyTo: undefined,
+ messageContent: 'Hello',
+ type: 'STRING',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '1',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- {
- _id: '3',
- firstName: 'Test',
- lastName: 'User1',
- email: 'test1@example.com',
- image: '',
- },
- {
- _id: '4',
- firstName: 'Test',
- lastName: 'User2',
- email: 'test2@example.com',
- image: '',
- },
- {
- _id: '5',
- firstName: 'Test',
- lastName: 'User4',
- email: 'test4@example.com',
- image: '',
- },
- ],
+ sendMessageToChat: {
+ _id: '668ec1f1364e03ac47a151',
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ type: 'STRING',
+ replyTo: null,
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: SEND_MESSAGE_TO_CHAT,
+ variables: {
+ chatId: '1',
+ replyTo: '345678',
+ messageContent: 'Test reply message',
+ type: 'STRING',
+ },
+ },
+ result: {
+ data: {
+ sendMessageToChat: {
+ _id: '668ec1f1364e03ac47a151',
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ type: 'STRING',
+ replyTo: null,
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
+ },
+ },
+ },
+ },
+ {
+ request: {
+ query: SEND_MESSAGE_TO_CHAT,
+ variables: {
+ chatId: '1',
+ replyTo: undefined,
+ messageContent: 'Test message',
+ type: 'STRING',
+ },
+ },
+ result: {
+ data: {
+ sendMessageToChat: {
+ _id: '668ec1f1364e03ac47a151',
+ createdAt: '2024-07-10T17:16:33.248Z',
+ messageContent: 'Test ',
+ type: 'STRING',
+ replyTo: null,
+ sender: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: '',
+ },
+ updatedAt: '2024-07-10',
},
},
},
@@ -1675,17 +1132,17 @@ describe('Testing Chatroom Component [User Portal]', () => {
test('Chat room should display fallback content if no chat is active', async () => {
const mocks = [
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
+ ...SEND_MESSAGE_TO_CHAT_MOCK,
];
render(
-
+
@@ -1698,17 +1155,17 @@ describe('Testing Chatroom Component [User Portal]', () => {
test('Selected contact is direct chat', async () => {
const link = new MockSubscriptionLink();
const mocks = [
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
+ ...SEND_MESSAGE_TO_CHAT_MOCK,
];
render(
-
+
@@ -1720,11 +1177,11 @@ describe('Testing Chatroom Component [User Portal]', () => {
test('send message direct chat', async () => {
setItem('userId', '2');
const mocks = [
- ...SEND_MESSAGE_TO_DIRECT_CHAT_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...SEND_MESSAGE_TO_CHAT_MOCK,
];
const link2 = new StaticMockLink(mocks, true);
render(
@@ -1817,7 +1274,7 @@ describe('Testing Chatroom Component [User Portal]', () => {
-
+
@@ -1889,17 +1346,17 @@ describe('Testing Chatroom Component [User Portal]', () => {
test('Selected contact is group chat', async () => {
const mocks = [
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
+ ...SEND_MESSAGE_TO_CHAT_MOCK,
];
render(
-
+
@@ -1910,19 +1367,17 @@ describe('Testing Chatroom Component [User Portal]', () => {
test('send message group chat', async () => {
const mocks = [
- ...SEND_MESSAGE_TO_GROUP_CHAT_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_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(
-
+
-
+
@@ -1949,7 +1404,7 @@ describe('Testing Chatroom Component [User Portal]', () => {
expect(input.value).toBeFalsy();
});
- const messages = await screen.findAllByTestId('groupChatMsg');
+ const messages = await screen.findAllByTestId('message');
expect(messages.length).not.toBe(0);
@@ -1957,9 +1412,7 @@ describe('Testing Chatroom Component [User Portal]', () => {
fireEvent.mouseOver(messages[0]);
});
- await waitFor(async () => {
- expect(await screen.findByTestId('moreOptions')).toBeInTheDocument();
- });
+ expect(await screen.findByTestId('moreOptions')).toBeInTheDocument();
const moreOptionsBtn = await screen.findByTestId('dropdown');
act(() => {
@@ -1983,44 +1436,44 @@ describe('Testing Chatroom Component [User Portal]', () => {
});
expect(input.value).toBe('Test reply message');
- // act(() => {
- fireEvent.click(sendBtn);
- // })
+ const closeReplyBtn = await screen.findByTestId('closeReply');
- await wait(400);
+ expect(closeReplyBtn).toBeInTheDocument();
+
+ fireEvent.click(closeReplyBtn);
+
+ await wait(500);
});
- test('remove reply msg', async () => {
+ test('reply to message', async () => {
const mocks = [
- ...SEND_MESSAGE_TO_GROUP_CHAT_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_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(
-
+
,
);
- await wait(500);
+ await wait();
const input = (await screen.findByTestId(
'messageInput',
)) as HTMLInputElement;
act(() => {
- fireEvent.change(input, { target: { value: 'Hello' } });
+ fireEvent.change(input, { target: { value: 'Test message' } });
});
- expect(input.value).toBe('Hello');
+ expect(input.value).toBe('Test message');
const sendBtn = await screen.findByTestId('sendMessage');
@@ -2032,7 +1485,7 @@ describe('Testing Chatroom Component [User Portal]', () => {
expect(input.value).toBeFalsy();
});
- const messages = await screen.findAllByTestId('groupChatMsg');
+ const messages = await screen.findAllByTestId('message');
expect(messages.length).not.toBe(0);
@@ -2040,9 +1493,7 @@ describe('Testing Chatroom Component [User Portal]', () => {
fireEvent.mouseOver(messages[0]);
});
- await waitFor(async () => {
- expect(await screen.findByTestId('moreOptions')).toBeInTheDocument();
- });
+ expect(await screen.findByTestId('moreOptions')).toBeInTheDocument();
const moreOptionsBtn = await screen.findByTestId('dropdown');
act(() => {
@@ -2061,35 +1512,15 @@ describe('Testing Chatroom Component [User Portal]', () => {
expect(replyMsg).toBeInTheDocument();
});
- await waitFor(async () => {
- expect(await screen.findByTestId('closeReplyMsg')).toBeInTheDocument();
- expect(await screen.findByTestId('closeReplyMsg')).toBeInTheDocument();
+ act(() => {
+ fireEvent.change(input, { target: { value: 'Test reply message' } });
});
+ expect(input.value).toBe('Test reply message');
- await act(async () => {
- fireEvent.click(await screen.findByTestId('closeReplyMsg'));
+ act(() => {
+ fireEvent.click(sendBtn);
});
- });
- test('websocket subscription', async () => {
- const mocks = [
- ...SEND_MESSAGE_TO_GROUP_CHAT_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
- ];
- render(
-
-
-
-
-
-
-
-
- ,
- );
- await wait(500);
+ await wait(400);
});
});
diff --git a/src/components/UserPortal/ChatRoom/ChatRoom.tsx b/src/components/UserPortal/ChatRoom/ChatRoom.tsx
index b38391d1d5..1c431bda84 100644
--- a/src/components/UserPortal/ChatRoom/ChatRoom.tsx
+++ b/src/components/UserPortal/ChatRoom/ChatRoom.tsx
@@ -5,25 +5,18 @@ import { Button, Dropdown, Form, InputGroup } from 'react-bootstrap';
import styles from './ChatRoom.module.css';
import PermContactCalendarIcon from '@mui/icons-material/PermContactCalendar';
import { useTranslation } from 'react-i18next';
-import {
- DIRECT_CHAT_BY_ID,
- GROUP_CHAT_BY_ID,
-} from 'GraphQl/Queries/PlugInQueries';
+import { CHAT_BY_ID } from 'GraphQl/Queries/PlugInQueries';
import { useMutation, useQuery, useSubscription } from '@apollo/client';
import {
- MESSAGE_SENT_TO_DIRECT_CHAT,
- MESSAGE_SENT_TO_GROUP_CHAT,
- SEND_MESSAGE_TO_DIRECT_CHAT,
- SEND_MESSAGE_TO_GROUP_CHAT,
+ MESSAGE_SENT_TO_CHAT,
+ SEND_MESSAGE_TO_CHAT,
} from 'GraphQl/Mutations/OrganizationMutations';
import useLocalStorage from 'utils/useLocalstorage';
import Avatar from 'components/Avatar/Avatar';
import { MoreVert, Close } from '@mui/icons-material';
-import type { InterfaceUser } from 'components/CheckIn/types';
interface InterfaceChatRoomProps {
selectedContact: string;
- selectedChatType: string;
}
/**
@@ -66,15 +59,14 @@ type DirectMessage = {
}
| undefined;
messageContent: string;
- receiver: {
- _id: string;
- firstName: string;
- lastName: string;
- };
+ type: string;
};
type Chat = {
_id: string;
+ isGroup: boolean;
+ name?: string;
+ image?: string;
messages: DirectMessage[];
users: {
_id: string;
@@ -102,8 +94,7 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
const [chatTitle, setChatTitle] = useState('');
const [chatSubtitle, setChatSubtitle] = useState('');
const [newMessage, setNewMessage] = useState('');
- const [directChat, setDirectChat] = useState();
- const [groupChat, setGroupChat] = useState();
+ const [chat, setChat] = useState();
const [replyToDirectMessage, setReplyToDirectMessage] =
useState(null);
@@ -119,103 +110,61 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
setNewMessage(newMessageValue);
};
- const [sendMessageToDirectChat] = useMutation(SEND_MESSAGE_TO_DIRECT_CHAT, {
- variables: {
- chatId: props.selectedContact,
- replyTo: replyToDirectMessage?._id,
- messageContent: newMessage,
- },
- });
-
- const [sendMessageToGroupChat] = useMutation(SEND_MESSAGE_TO_GROUP_CHAT, {
+ const [sendMessageToChat] = useMutation(SEND_MESSAGE_TO_CHAT, {
variables: {
chatId: props.selectedContact,
replyTo: replyToDirectMessage?._id,
messageContent: newMessage,
+ type: 'STRING',
},
});
- const {
- data: chatData,
- loading: chatLoading,
- refetch: chatRefetch,
- } = useQuery(DIRECT_CHAT_BY_ID, {
- variables: {
- id: props.selectedContact,
- },
- });
- const {
- data: chatDataGorup,
- loading: groupChatLoading,
- refetch: groupChatRefresh,
- } = useQuery(GROUP_CHAT_BY_ID, {
+ const { data: chatData, refetch: chatRefetch } = useQuery(CHAT_BY_ID, {
variables: {
id: props.selectedContact,
},
});
useEffect(() => {
- if (props.selectedChatType == 'direct') {
- chatRefetch();
- } else if (props.selectedChatType == 'group') {
- groupChatRefresh();
- }
+ chatRefetch();
}, [props.selectedContact]);
useEffect(() => {
- if (
- props.selectedChatType === 'direct' &&
- chatData &&
- isMountedRef.current
- ) {
- const directChatData = chatData.directChatById;
- setDirectChat(directChatData);
- const otherUser = directChatData.users.find(
- (user: InterfaceUser) => user._id !== userId,
- );
- if (otherUser) {
- setChatTitle(`${otherUser.firstName} ${otherUser.lastName}`);
- setChatSubtitle(otherUser.email);
+ if (chatData) {
+ const chat = chatData.chatById;
+ setChat(chat);
+ if (chat.isGroup) {
+ setChatTitle(chat.name);
+ setChatSubtitle(`${chat.users.length} members`);
+ } else {
+ const otherUser = chat.users.find(
+ (user: { _id: string }) => user._id !== userId,
+ );
+ if (otherUser) {
+ setChatTitle(`${otherUser.firstName} ${otherUser.lastName}`);
+ setChatSubtitle(otherUser.email);
+ }
}
}
}, [chatData]);
- useEffect(() => {
- if (
- props.selectedChatType === 'group' &&
- chatDataGorup &&
- isMountedRef.current
- ) {
- const groupChatData = chatDataGorup.groupChatById;
- setGroupChat(groupChatData);
- setChatTitle(groupChatData.title);
- setChatSubtitle(`${groupChatData.users.length} members`);
- }
- }, [chatDataGorup]);
-
const sendMessage = async (): Promise => {
- if (props.selectedChatType === 'direct') {
- await sendMessageToDirectChat();
- await chatRefetch();
- setReplyToDirectMessage(null);
- } else if (props.selectedChatType === 'group') {
- await sendMessageToGroupChat();
- await groupChatRefresh();
- setReplyToDirectMessage(null);
- }
+ await sendMessageToChat();
+ await chatRefetch();
+ setReplyToDirectMessage(null);
setNewMessage('');
};
- useSubscription(MESSAGE_SENT_TO_DIRECT_CHAT, {
+ useSubscription(MESSAGE_SENT_TO_CHAT, {
variables: {
userId: userId,
},
- onData: (directMessageSubscriptionData) => {
+ onData: (messageSubscriptionData) => {
if (
- directMessageSubscriptionData?.data.data.messageSentToDirectChat &&
- directMessageSubscriptionData?.data.data.messageSentToDirectChat
- .directChatMessageBelongsTo['_id'] == props.selectedContact
+ messageSubscriptionData?.data.data.messageSentToChat &&
+ messageSubscriptionData?.data.data.messageSentToChat
+ .chatMessageBelongsTo['_id'] == props.selectedContact
) {
chatRefetch();
} else {
@@ -227,28 +176,6 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
},
});
- useSubscription(MESSAGE_SENT_TO_GROUP_CHAT, {
- variables: {
- userId: userId,
- },
- onData: (groupMessageSubscriptionData) => {
- if (
- groupMessageSubscriptionData?.data.data.messageSentToGroupChat &&
- groupMessageSubscriptionData?.data.data.messageSentToGroupChat
- .groupChatMessageBelongsTo['_id'] == props.selectedContact
- ) {
- groupChatRefresh({
- id: props.selectedContact,
- });
- } else {
- groupChatRefresh({
- id: groupMessageSubscriptionData?.data.data.messageSentToGroupChat
- .groupChatMessageBelongsTo['_id'],
- });
- }
- },
- });
-
useEffect(() => {
document
.getElementById('chat-area')
@@ -278,197 +205,115 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
/>
{chatTitle}
-
- {chatSubtitle}{' '}
- {props.selectedChatType == 'direct' ? '' : 'members'}
-
+
{chatSubtitle}
- {!!(
- directChat?.messages.length || groupChat?.messages.length
- ) && (
+ {!!chat?.messages.length && (
- {props.selectedChatType == 'direct'
- ? directChat?.messages.map((message: DirectMessage) => {
- return (
-
-
- );
- })
- : groupChat?.messages.map((message: DirectMessage) => {
- return (
-
- {message.sender._id !== userId ? (
- message.sender?.image ? (
-
- ) : (
-
- )
- ) : (
- ''
- )}
-
-
- {message.sender._id !== userId && (
+ avatarStyle={styles.contactImage}
+ />
+ ))}
+
+
+ {chat.isGroup && message.sender._id !== userId && (
+
+ {message.sender.firstName +
+ ' ' +
+ message.sender.lastName}
+
+ )}
+ {message.replyTo && (
+
+
-
-
- {message.replyTo.messageContent}
+
+
+ )}
+ {message.messageContent}
+
+
+
+
+
+
+
+ {
+ setReplyToDirectMessage(message);
+ }}
+ data-testid="replyBtn"
>
-
-
-
-
- {
- setReplyToDirectMessage(message);
- }}
- data-testid="replyBtn"
- >
- Reply
-
-
-
-
- {new Date(
- message?.createdAt,
- ).toLocaleTimeString('it-IT', {
- hour: '2-digit',
- minute: '2-digit',
- })}
-
-
-
+ Reply
+
+
+
+
+ {new Date(message?.createdAt).toLocaleTimeString(
+ 'it-IT',
+ {
+ hour: '2-digit',
+ minute: '2-digit',
+ },
+ )}
+
- );
- })}
+
+
+ );
+ })}
)}
@@ -501,9 +346,9 @@ export default function chatRoom(props: InterfaceChatRoomProps): JSX.Element {
diff --git a/src/components/UserPortal/ContactCard/ContactCard.test.tsx b/src/components/UserPortal/ContactCard/ContactCard.test.tsx
index 03136387a7..05a6a0a530 100644
--- a/src/components/UserPortal/ContactCard/ContactCard.test.tsx
+++ b/src/components/UserPortal/ContactCard/ContactCard.test.tsx
@@ -26,6 +26,7 @@ let props = {
title: 'Disha Talreja',
subtitle: 'disha@example.com',
email: 'noble@mittal.com',
+ isGroup: false,
image: '',
selectedContact: '',
type: '',
@@ -95,6 +96,7 @@ describe('Testing ContactCard Component [User Portal]', () => {
props = {
...props,
selectedContact: '1',
+ isGroup: true,
};
render(
diff --git a/src/components/UserPortal/ContactCard/ContactCard.tsx b/src/components/UserPortal/ContactCard/ContactCard.tsx
index cd135a9e01..ef6bf2c9d5 100644
--- a/src/components/UserPortal/ContactCard/ContactCard.tsx
+++ b/src/components/UserPortal/ContactCard/ContactCard.tsx
@@ -5,12 +5,10 @@ import Avatar from 'components/Avatar/Avatar';
interface InterfaceContactCardProps {
id: string;
title: string;
- subtitle: string;
image: string;
selectedContact: string;
setSelectedContact: React.Dispatch>;
- type: string;
- setSelectedChatType: React.Dispatch>;
+ isGroup: boolean;
}
/**
@@ -33,18 +31,9 @@ interface InterfaceContactCardProps {
* @returns The rendered contact card component.
*/
function contactCard(props: InterfaceContactCardProps): JSX.Element {
- // Full name of the contact
-
- /**
- * Updates the selected contact and its name when the card is clicked.
- */
-
const handleSelectedContactChange = (): void => {
props.setSelectedContact(props.id);
- props.setSelectedChatType(props.type);
};
-
- // State to track if the contact card is selected
const [isSelected, setIsSelected] = React.useState(
props.selectedContact === props.id,
);
@@ -78,7 +67,6 @@ function contactCard(props: InterfaceContactCardProps): JSX.Element {
)}
{props.title}
- {props.subtitle}
>
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx
index dc7f57adc6..e3e2eae75c 100644
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx
+++ b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.test.tsx
@@ -8,924 +8,20 @@ import {
} from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider, useTranslation } from 'react-i18next';
-
-import {
- DIRECT_CHATS_LIST,
- USERS_CONNECTION_LIST,
-} from 'GraphQl/Queries/Queries';
-import { BrowserRouter } from 'react-router-dom';
-import { Provider } from 'react-redux';
-import { store } from 'state/store';
-import i18nForTest from 'utils/i18nForTest';
-import Chat from '../../../screens/UserPortal/Chat/Chat';
-import {
- CREATE_DIRECT_CHAT,
- MESSAGE_SENT_TO_DIRECT_CHAT,
- MESSAGE_SENT_TO_GROUP_CHAT,
-} from 'GraphQl/Mutations/OrganizationMutations';
-import {
- DIRECT_CHAT_BY_ID,
- GROUP_CHAT_BY_ID,
- GROUP_CHAT_LIST,
-} from 'GraphQl/Queries/PlugInQueries';
-import useLocalStorage from 'utils/useLocalstorage';
-
-const { setItem } = useLocalStorage();
-
-const MOCKS = [
- {
- request: {
- query: GROUP_CHAT_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- groupChatsByUserId: [
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- {
- _id: '2',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: GROUP_CHAT_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- groupChatsByUserId: [
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- {
- _id: '2',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: GROUP_CHAT_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- groupChatsByUserId: [
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
-];
+import { USERS_CONNECTION_LIST } from 'GraphQl/Queries/Queries';
+import { BrowserRouter } from 'react-router-dom';
+import { Provider } from 'react-redux';
+import { store } from 'state/store';
+import i18nForTest from 'utils/i18nForTest';
+import Chat from '../../../screens/UserPortal/Chat/Chat';
+import {
+ CREATE_CHAT,
+ MESSAGE_SENT_TO_CHAT,
+} from 'GraphQl/Mutations/OrganizationMutations';
+import { CHATS_LIST, CHAT_BY_ID } from 'GraphQl/Queries/PlugInQueries';
+import useLocalStorage from 'utils/useLocalstorage';
+
+const { setItem } = useLocalStorage();
const UserConnectionListMock = [
{
@@ -1222,99 +318,23 @@ const UserConnectionListMock = [
},
},
},
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: '',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: {
- user: [
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- ],
- },
- },
- },
- },
];
-const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
+const MESSAGE_SENT_TO_CHAT_MOCK = [
{
request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
userId: null,
},
},
result: {
data: {
- messageSentToGroupChat: {
+ messageSentToChat: {
_id: '668ec1f1364e03ac47a151',
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
+ type: 'STRING',
replyTo: null,
sender: {
_id: '64378abd85008f171cf2990d',
@@ -1329,7 +349,7 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
},
{
request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
userId: '2',
},
@@ -1341,6 +361,7 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1354,7 +375,7 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
},
{
request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
userId: '1',
},
@@ -1366,6 +387,7 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1379,114 +401,90 @@ const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
},
];
-const MESSAGE_SENT_TO_DIRECT_CHAT_MOCK = [
- {
- request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
- variables: {
- userId: '1',
- },
- },
- result: {
- data: {
- messageSentToDirectChat: {
- _id: '668ec1f1364e03ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
- },
- updatedAt: '2024-07-10',
- },
- },
- },
- },
+const CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
+ query: CHAT_BY_ID,
variables: {
- userId: '2',
+ id: '1',
},
},
result: {
data: {
- messageSentToDirectChat: {
- _id: '668ec1f1364e03ac4697vgfa151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
- sender: {
+ chatById: {
+ _id: '1',
+ createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
lastName: 'Shepherd',
- image: '',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- updatedAt: '2024-07-10',
+ organization: null,
+ name: '',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ ],
},
},
},
},
{
request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
+ query: CHAT_BY_ID,
variables: {
- userId: null,
+ id: '1',
},
},
result: {
data: {
- messageSentToDirectChat: {
- _id: '6ec1f1364e03ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
- sender: {
+ chatById: {
+ _id: '1',
+ isGroup: false,
+ creator: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
lastName: 'Shepherd',
- image: '',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- updatedAt: '2024-07-10',
- },
- },
- },
- },
-];
-
-const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '1',
+ organization: null,
+ name: '',
createdAt: '2345678903456',
messages: [
{
@@ -1494,13 +492,7 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1532,15 +524,27 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
- id: '1',
+ id: '',
},
},
result: {
data: {
- directChatById: {
+ 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: [
{
@@ -1548,13 +552,7 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1584,397 +582,678 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
},
},
},
+];
+
+const CHATS_LIST_MOCK = [
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
- id: '',
+ id: null,
},
},
result: {
data: {
- directChatById: {
- _id: '1',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
_id: '1',
firstName: 'Disha',
lastName: 'Talreja',
email: 'disha@example.com',
image: '',
},
- sender: {
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
},
},
},
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
- id: '2',
+ id: '',
},
},
result: {
data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
+ chatsByUserId: [
+ {
+ _id: '65844ghjefc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
_id: '1',
firstName: 'Disha',
lastName: 'Talreja',
email: 'disha@example.com',
image: '',
},
- sender: {
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: 'ujhgtrdtyuiop',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
},
- ],
- },
- },
- },
- },
- {
- request: {
- query: DIRECT_CHAT_BY_ID,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
_id: '1',
firstName: 'Disha',
lastName: 'Talreja',
email: 'disha@example.com',
image: '',
},
- sender: {
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
- },
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
- },
- ],
- },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
},
},
},
-];
-
-const GROUP_CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
id: '1',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- ],
- 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: '',
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
},
- ],
- },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
},
},
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
id: '1',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- ],
- 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: '',
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
},
- ],
- },
- },
- },
- },
- {
- request: {
- query: GROUP_CHAT_BY_ID,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- groupChatById: {
- _id: '1',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
- },
- ],
- 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: '',
+ },
+ ],
+ },
+ ],
},
},
},
+];
+
+const GROUP_CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
- id: '2',
+ id: '',
},
},
result: {
data: {
- groupChatById: {
+ chatById: {
_id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
_id: '345678',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -2025,25 +1304,42 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
},
},
+];
+
+const CREATE_CHAT_MUTATION_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CREATE_CHAT,
variables: {
- id: null,
+ organizationId: undefined,
+ userIds: ['1', '6589389d2caa9d8d69087487'],
+ isGroup: false,
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
+ createChat: {
+ _id: '1',
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
messages: [
{
_id: '345678',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -2068,27 +1364,6 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
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: '',
- },
],
},
},
@@ -2096,24 +1371,6 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
];
-const CREATE_DIRECT_CHAT_MOCK = {
- request: {
- query: CREATE_DIRECT_CHAT,
- variables: {
- userIds: ['1', '6589389d2caa9d8d69087487'],
- organizationId: undefined,
- },
- },
- result: {
- data: {
- createDirectChat: {
- _id: '669394c180e96b740ba1c0ce',
- __typename: 'DirectChat',
- },
- },
- },
-};
-
async function wait(ms = 100): Promise
{
await act(() => {
return new Promise((resolve) => {
@@ -2139,14 +1396,14 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
})),
});
- test('open and close create new direct chat modal', async () => {
+ test('Open and close create new direct chat modal', async () => {
const mock = [
...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
...UserConnectionListMock,
- ...MOCKS,
+ ...CHATS_LIST_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CREATE_CHAT_MUTATION_MOCK,
];
render(
@@ -2192,13 +1449,12 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
test('create new direct chat', async () => {
setItem('userId', '1');
const mock = [
- CREATE_DIRECT_CHAT_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
...UserConnectionListMock,
- ...MOCKS,
+ ...CHATS_LIST_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CREATE_CHAT_MUTATION_MOCK,
];
render(
@@ -2232,5 +1488,9 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
expect(closeButton).toBeInTheDocument();
fireEvent.click(closeButton);
+
+ await new Promise(process.nextTick);
+
+ await wait();
});
});
diff --git a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
index 2f16dd4b0f..e0ee9613c3 100644
--- a/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
+++ b/src/components/UserPortal/CreateDirectChat/CreateDirectChat.tsx
@@ -5,7 +5,10 @@ import styles from './CreateDirectChat.module.css';
import type { ApolloQueryResult } from '@apollo/client';
import { useMutation, useQuery } from '@apollo/client';
import useLocalStorage from 'utils/useLocalstorage';
-import { CREATE_DIRECT_CHAT } from 'GraphQl/Mutations/OrganizationMutations';
+import {
+ CREATE_CHAT,
+ CREATE_DIRECT_CHAT,
+} from 'GraphQl/Mutations/OrganizationMutations';
import Table from '@mui/material/Table';
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
@@ -19,19 +22,10 @@ import { Search } from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
-/**
- * Props for the CreateDirectChat component.
- */
interface InterfaceCreateDirectChatProps {
toggleCreateDirectChatModal: () => void;
createDirectChatModalisOpen: boolean;
- /**
- * Function to refetch the contact list.
- *
- * @param variables - Optional variables to filter the contact list.
- * @returns Promise with ApolloQueryResult.
- */
- contactRefetch: (
+ chatsListRefetch: (
variables?:
| Partial<{
id: any;
@@ -43,6 +37,7 @@ interface InterfaceCreateDirectChatProps {
/**
* Styled table cell with custom styles.
*/
+
const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: {
backgroundColor: ['#31bb6b', '!important'],
@@ -56,6 +51,7 @@ const StyledTableCell = styled(TableCell)(({ theme }) => ({
/**
* Styled table row with custom styles.
*/
+
const StyledTableRow = styled(TableRow)(() => ({
'&:last-child td, &:last-child th': {
border: 0,
@@ -64,16 +60,10 @@ const StyledTableRow = styled(TableRow)(() => ({
const { getItem } = useLocalStorage();
-/**
- * Component for creating a direct chat with a selected user.
- *
- * @param props - The props for the CreateDirectChat component.
- * @returns JSX.Element
- */
-export default function groupChat({
+export default function createDirectChatModal({
toggleCreateDirectChatModal,
createDirectChatModalisOpen,
- contactRefetch,
+ chatsListRefetch,
}: InterfaceCreateDirectChatProps): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'userChat',
@@ -85,23 +75,17 @@ export default function groupChat({
const [userName, setUserName] = useState('');
- const [createDirectChat] = useMutation(CREATE_DIRECT_CHAT);
+ const [createChat] = useMutation(CREATE_CHAT);
- /**
- * Handles the creation of a direct chat with a selected user.
- *
- * @param id - The ID of the user to start a direct chat with.
- * @returns Promise
- */
const handleCreateDirectChat = async (id: string): Promise => {
- console.log(organizationId);
- await createDirectChat({
+ await createChat({
variables: {
organizationId,
userIds: [userId, id],
+ isGroup: false,
},
});
- contactRefetch();
+ await chatsListRefetch();
toggleCreateDirectChatModal();
};
@@ -116,12 +100,6 @@ export default function groupChat({
},
});
- /**
- * Handles changes in the user search input and refetches the user list.
- *
- * @param e - The form event.
- * @returns void
- */
const handleUserModalSearchChange = (e: React.FormEvent): void => {
e.preventDefault();
/* istanbul ignore next */
diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx
index 9babcd3cef..fda0594b01 100644
--- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx
+++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.test.tsx
@@ -2,9 +2,11 @@ import React from 'react';
import {
act,
fireEvent,
+ prettyDOM,
render,
screen,
waitFor,
+ within,
} from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
@@ -21,915 +23,237 @@ 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 useLocalStorage from 'utils/useLocalstorage';
+import userEvent from '@testing-library/user-event';
const { setItem } = useLocalStorage();
-const MOCKS = [
- {
- request: {
- query: GROUP_CHAT_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- groupChatsByUserId: [
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- {
- _id: '2',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: GROUP_CHAT_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- groupChatsByUserId: [
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- {
- _id: '2',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: GROUP_CHAT_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- groupChatsByUserId: [
- {
- _id: '1',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- {
- _id: '2',
- creator: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- },
- messages: {
- _id: '1',
- createdAt: '',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@email.com',
- },
- },
- title: 'Test GroupChat',
- organization: {
- _id: '1',
- name: 'Test Org',
- },
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@email.com',
- image: 'img',
- },
- ],
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
+const USER_JOINED_ORG_MOCK = [
{
request: {
- query: DIRECT_CHATS_LIST,
+ query: USER_JOINED_ORGANIZATIONS,
variables: {
id: '1',
},
},
result: {
data: {
- directChatsByUserID: [
- {
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
- },
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- ],
- },
- },
- },
- {
- request: {
- query: DIRECT_CHATS_LIST,
- variables: {
- id: '',
- },
- },
- result: {
- data: {
- directChatsByUserID: [
+ users: [
{
- _id: '666c88dd92e995354d98527c',
- creator: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '668930bae43ce54e6e302cf1',
- createdAt: '2024-07-06T11:55:38.933Z',
- messageContent: 'hJnkank',
- replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- __typename: 'User',
+ user: {
+ joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
},
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
},
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
- },
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- email: 'testadmin1@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
- },
- {
- _id: '666f09c892e995354d98a5ee',
- creator: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
- },
- messages: [
- {
- _id: '6676932692e995354d98ab7f',
- createdAt: '2024-06-22T09:02:30.776Z',
- messageContent: 'hii',
- replyTo: null,
- receiver: {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- __typename: 'User',
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
},
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- __typename: 'User',
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8f07af2',
+ name: 'Test Org 1',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
},
- __typename: 'DirectChatMessage',
- },
- ],
- organization: {
- _id: '6737904485008f171cf29924',
- name: 'Unity Foundation',
- __typename: 'Organization',
+ ],
},
- users: [
- {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- email: 'testsuperadmin@example.com',
- image: null,
- __typename: 'User',
- },
- {
- _id: '67378abd85008f171cf2990d',
- firstName: 'Darcy',
- lastName: 'Wilf',
- email: 'testadmin3@example.com',
- image: null,
- __typename: 'User',
- },
- ],
- __typename: 'DirectChat',
},
],
},
},
},
-];
-
-const USER_JOINED_ORG_MOCK = [
{
request: {
query: USER_JOINED_ORGANIZATIONS,
@@ -946,7 +270,55 @@ const USER_JOINED_ORG_MOCK = [
{
__typename: 'Organization',
_id: '6401ff65ce8e8406b8f07af2',
- name: 'Test Org 1',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: 'qsxhgjhbmnbkhlk,njgjfhgv',
+ name: 'Any Organization',
image: '',
description: 'New Desc',
address: {
@@ -1013,7 +385,55 @@ const USER_JOINED_ORG_MOCK = [
joinedOrganizations: [
{
__typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
+ _id: '6401ff65ce8e8406b8fhgjhnm07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8egfhbn8406b8f07af2',
name: 'Any Organization',
image: '',
description: 'New Desc',
@@ -1070,7 +490,7 @@ const USER_JOINED_ORG_MOCK = [
request: {
query: USER_JOINED_ORGANIZATIONS,
variables: {
- id: '1',
+ id: null,
},
},
result: {
@@ -1081,7 +501,55 @@ const USER_JOINED_ORG_MOCK = [
joinedOrganizations: [
{
__typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
+ _id: '6401ff65fghce8e8406b8f07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
+ {
+ __typename: 'Organization',
+ _id: '6401ff65ce8e8406b8jygjgf07af2',
name: 'Any Organization',
image: '',
description: 'New Desc',
@@ -1147,6 +615,54 @@ const USER_JOINED_ORG_MOCK = [
{
user: {
joinedOrganizations: [
+ {
+ __typename: 'Organization',
+ _id: '6401ff65cehgh8e8406b8f07af2',
+ name: 'Test org',
+ image: '',
+ description: 'New Desc',
+ address: {
+ city: 'abc',
+ countryCode: '123',
+ postalCode: '456',
+ state: 'def',
+ dependentLocality: 'ghi',
+ line1: 'asdfg',
+ line2: 'dfghj',
+ sortingCode: '4567',
+ },
+ createdAt: '1234567890',
+ userRegistrationRequired: true,
+ creator: {
+ __typename: 'User',
+ firstName: 'John',
+ lastName: 'Doe',
+ },
+ members: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ admins: [
+ {
+ _id: '45gj5678jk45678fvgbhnr4rtgh',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ membershipRequests: [
+ {
+ _id: '56gheqyr7deyfuiwfewifruy8',
+ user: {
+ _id: '45ydeg2yet721rtgdu32ry',
+ },
+ },
+ ],
+ },
{
__typename: 'Organization',
_id: '6401ff65ce8e8406b8f07af2',
@@ -1217,8 +733,8 @@ const USER_JOINED_ORG_MOCK = [
joinedOrganizations: [
{
__typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
- name: 'Any Organization',
+ _id: '6401ff65ce8e8406nbmnmb8f07af2',
+ name: 'Test org',
image: '',
description: 'New Desc',
address: {
@@ -1263,29 +779,9 @@ const USER_JOINED_ORG_MOCK = [
},
],
},
- ],
- },
- },
- ],
- },
- },
- },
- {
- request: {
- query: USER_JOINED_ORGANIZATIONS,
- variables: {
- id: null,
- },
- },
- result: {
- data: {
- users: [
- {
- user: {
- joinedOrganizations: [
{
__typename: 'Organization',
- _id: '6401ff65ce8e8406b8f07af2',
+ _id: '6401ff65ce8e8406b8fnnmm07af2',
name: 'Any Organization',
image: '',
description: 'New Desc',
@@ -1488,6 +984,83 @@ const UserConnectionListMock = [
},
},
},
+ {
+ request: {
+ query: USERS_CONNECTION_LIST,
+ variables: {
+ firstName_contains: '',
+ lastName_contains: '',
+ },
+ },
+ result: {
+ data: {
+ users: {
+ user: [
+ {
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ image: 'img',
+ _id: '1',
+ email: 'disha@email.com',
+ createdAt: '',
+ appUserProfile: {
+ _id: '12',
+ isSuperAdmin: 'false',
+ createdOrganizations: {
+ _id: '345678',
+ },
+ createdEvents: {
+ _id: '34567890',
+ },
+ },
+ organizationsBlockedBy: [],
+ joinedOrganizations: [],
+ },
+ {
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ image: 'img',
+ _id: '1',
+ email: 'disha@email.com',
+ createdAt: '',
+ appUserProfile: {
+ _id: '12',
+ isSuperAdmin: 'false',
+ createdOrganizations: {
+ _id: '345678',
+ },
+ createdEvents: {
+ _id: '34567890',
+ },
+ },
+ organizationsBlockedBy: [],
+ joinedOrganizations: [],
+ },
+ {
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ image: 'img',
+ _id: '1',
+ email: 'disha@email.com',
+ createdAt: '',
+ appUserProfile: {
+ _id: '12',
+ isSuperAdmin: 'false',
+ createdOrganizations: {
+ _id: '345678',
+ },
+ createdEvents: {
+ _id: '34567890',
+ },
+ },
+ organizationsBlockedBy: [],
+ joinedOrganizations: [],
+ },
+ ],
+ },
+ },
+ },
+ },
{
request: {
query: USERS_CONNECTION_LIST,
@@ -1626,193 +1199,33 @@ const UserConnectionListMock = [
isSuperAdmin: false,
createdOrganizations: [],
createdEvents: [],
- eventAdmin: [],
- __typename: 'AppUserProfile',
- },
- __typename: 'UserData',
- },
- ],
- },
- },
- },
- {
- request: {
- query: USERS_CONNECTION_LIST,
- variables: {
- firstName_contains: '',
- lastName_contains: '',
- },
- },
- result: {
- data: {
- users: {
- user: [
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '1',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '2',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- {
- firstName: 'Disha',
- lastName: 'Talreja',
- image: 'img',
- _id: '3',
- email: 'disha@email.com',
- createdAt: '',
- appUserProfile: {
- _id: '12',
- isSuperAdmin: 'false',
- createdOrganizations: {
- _id: '345678',
- },
- createdEvents: {
- _id: '34567890',
- },
- },
- organizationsBlockedBy: [],
- joinedOrganizations: [],
- },
- ],
- },
- },
- },
- },
-];
-
-const MESSAGE_SENT_TO_GROUP_CHAT_MOCK = [
- {
- request: {
- query: MESSAGE_SENT_TO_GROUP_CHAT,
- variables: {
- userId: null,
- },
- },
- result: {
- data: {
- messageSentToGroupChat: {
- _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: MESSAGE_SENT_TO_GROUP_CHAT,
- variables: {
- userId: '2',
- },
- },
- result: {
- data: {
- messageSentToGroupChat: {
- _id: '668ec1f1df364e03ac47a151',
- 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: MESSAGE_SENT_TO_GROUP_CHAT,
- variables: {
- userId: '1',
- },
- },
- result: {
- data: {
- messageSentToGroupChat: {
- _id: '668ec1f13603ac4697a151',
- createdAt: '2024-07-10T17:16:33.248Z',
- messageContent: 'Test ',
- replyTo: null,
- sender: {
- _id: '64378abd85008f171cf2990d',
- firstName: 'Wilt',
- lastName: 'Shepherd',
- image: '',
+ eventAdmin: [],
+ __typename: 'AppUserProfile',
+ },
+ __typename: 'UserData',
},
- updatedAt: '2024-07-10',
- },
+ ],
},
},
},
];
-const MESSAGE_SENT_TO_DIRECT_CHAT_MOCK = [
+const MESSAGE_SENT_TO_CHAT_MOCK = [
{
request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
- userId: '1',
+ userId: null,
},
},
result: {
data: {
- messageSentToDirectChat: {
- _id: '668ec1f1364e03ac4697a151',
+ messageSentToChat: {
+ _id: '668ec1f1364e03ac47a151',
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
+ type: 'STRING',
replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
sender: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1826,24 +1239,19 @@ const MESSAGE_SENT_TO_DIRECT_CHAT_MOCK = [
},
{
request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
userId: '2',
},
},
result: {
data: {
- messageSentToDirectChat: {
- _id: '668ec1f1364e03ac4697vgfa151',
+ messageSentToGroupChat: {
+ _id: '668ec1f1df364e03ac47a151',
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1857,24 +1265,19 @@ const MESSAGE_SENT_TO_DIRECT_CHAT_MOCK = [
},
{
request: {
- query: MESSAGE_SENT_TO_DIRECT_CHAT,
+ query: MESSAGE_SENT_TO_CHAT,
variables: {
- userId: null,
+ userId: '1',
},
},
result: {
data: {
- messageSentToDirectChat: {
- _id: '6ec1f1364e03ac4697a151',
+ messageSentToGroupChat: {
+ _id: '668ec1f13603ac4697a151',
createdAt: '2024-07-10T17:16:33.248Z',
messageContent: 'Test ',
replyTo: null,
- receiver: {
- _id: '65378abd85008f171cf2990d',
- firstName: 'Vyvyan',
- lastName: 'Kerry',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '64378abd85008f171cf2990d',
firstName: 'Wilt',
@@ -1888,32 +1291,38 @@ const MESSAGE_SENT_TO_DIRECT_CHAT_MOCK = [
},
];
-const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
+const CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
id: '1',
},
},
result: {
data: {
- directChatById: {
+ chatById: {
_id: '1',
createdAt: '2345678903456',
+ isGroup: false,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: null,
+ name: '',
messages: [
{
_id: '345678',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1945,15 +1354,27 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
id: '1',
},
},
result: {
data: {
- directChatById: {
+ 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: [
{
@@ -1961,13 +1382,7 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -1999,15 +1414,27 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
id: '',
},
},
result: {
data: {
- directChatById: {
+ 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: [
{
@@ -2015,13 +1442,7 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
- receiver: {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -2051,274 +1472,520 @@ const DIRECT_CHAT_BY_ID_QUERY_MOCK = [
},
},
},
+];
+
+const CHATS_LIST_MOCK = [
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
- id: '2',
+ id: null,
},
},
result: {
data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dd40fgh03db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
_id: '1',
firstName: 'Disha',
lastName: 'Talreja',
email: 'disha@example.com',
image: '',
},
- sender: {
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844efc814ddgh4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
},
- ],
- },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
},
},
},
{
request: {
- query: DIRECT_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
- id: null,
+ id: '',
},
},
result: {
data: {
- directChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- receiver: {
+ chatsByUserId: [
+ {
+ _id: '65844ghjefc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
_id: '1',
firstName: 'Disha',
lastName: 'Talreja',
email: 'disha@example.com',
image: '',
},
- sender: {
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: 'ujhgtrdtyuiop',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- ],
- users: [
- {
- _id: '1',
- firstName: 'Disha',
- lastName: 'Talreja',
- email: 'disha@example.com',
- image: '',
- },
- {
- _id: '2',
- firstName: 'Test',
- lastName: 'User',
- email: 'test@example.com',
- image: '',
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
},
- ],
- },
- },
- },
- },
-];
-
-const GROUP_CHAT_BY_ID_QUERY_MOCK = [
- {
- request: {
- query: GROUP_CHAT_BY_ID,
- variables: {
- id: '1',
- },
- },
- result: {
- data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
- },
- ],
- 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: '',
+ },
+ ],
+ },
+ ],
},
},
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHATS_LIST,
variables: {
id: '1',
},
},
result: {
data: {
- groupChatById: {
- _id: '65844efc814dd4003db811c4',
- createdAt: '2345678903456',
- title: 'Test Group Chat',
- messages: [
- {
- _id: '345678',
- createdAt: '345678908765',
- messageContent: 'Hello',
- replyTo: null,
- sender: {
+ chatsByUserId: [
+ {
+ _id: '65844efc814dhjmkdftyd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
_id: '2',
firstName: 'Test',
lastName: 'User',
email: 'test@example.com',
image: '',
},
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ {
+ _id: '65844ewsedrffc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
},
- ],
- 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: '',
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
},
- ],
- },
+ createdAt: '2345678903456',
+ name: 'Test Group Chat',
+ messages: [
+ {
+ _id: '345678',
+ createdAt: '345678908765',
+ messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
+ sender: {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ },
+ ],
+ users: [
+ {
+ _id: '1',
+ firstName: 'Disha',
+ lastName: 'Talreja',
+ email: 'disha@example.com',
+ image: '',
+ },
+ {
+ _id: '2',
+ firstName: 'Test',
+ lastName: 'User',
+ email: 'test@example.com',
+ image: '',
+ },
+ {
+ _id: '3',
+ firstName: 'Test',
+ lastName: 'User1',
+ email: 'test1@example.com',
+ image: '',
+ },
+ {
+ _id: '4',
+ firstName: 'Test',
+ lastName: 'User2',
+ email: 'test2@example.com',
+ image: '',
+ },
+ {
+ _id: '5',
+ firstName: 'Test',
+ lastName: 'User4',
+ email: 'test4@example.com',
+ image: '',
+ },
+ ],
+ },
+ ],
},
},
},
+];
+
+const GROUP_CHAT_BY_ID_QUERY_MOCK = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CHAT_BY_ID,
variables: {
id: '',
},
},
result: {
data: {
- groupChatById: {
- _id: '1',
+ chatById: {
+ _id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
_id: '345678',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -2369,25 +2036,46 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
},
},
+];
+
+const CREATE_CHAT_MUTATION = [
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CREATE_CHAT,
variables: {
- id: '2',
+ organizationId: '6401ff65ce8e8406b8jygjgf07af2',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
},
},
result: {
data: {
- groupChatById: {
+ createChat: {
_id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
_id: '345678',
createdAt: '345678908765',
messageContent: 'Hello',
replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -2440,22 +2128,41 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
{
request: {
- query: GROUP_CHAT_BY_ID,
+ query: CREATE_CHAT,
variables: {
- id: null,
+ organizationId: '',
+ userIds: [null],
+ name: 'Test Group',
+ isGroup: true,
},
},
result: {
data: {
- groupChatById: {
+ createChat: {
_id: '65844efc814dd4003db811c4',
+ isGroup: true,
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ image: null,
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ organization: {
+ _id: 'pw3ertyuiophgfre45678',
+ name: 'rtyu',
+ },
createdAt: '2345678903456',
- title: 'Test Group Chat',
+ name: 'Test Group Chat',
messages: [
{
_id: '345678',
createdAt: '345678908765',
messageContent: 'Hello',
+ replyTo: null,
+ type: 'STRING',
sender: {
_id: '2',
firstName: 'Test',
@@ -2508,47 +2215,6 @@ const GROUP_CHAT_BY_ID_QUERY_MOCK = [
},
];
-const CREATE_GROUP_CHAT_MOCK = [
- {
- request: {
- query: CREATE_GROUP_CHAT,
- variables: {
- organizationId: '6401ff65ce8e8406b8f07af2',
- userIds: [null],
- title: 'Test Group',
- },
- },
- result: {
- data: {
- createGroupChat: {
- _id: '669394c180e96b740ba1c0ce',
- __typename: 'GroupChat',
- },
- },
- },
- },
- {
- request: {
- query: CREATE_GROUP_CHAT,
- variables: {
- organizationId: '',
- userIds: [null],
- title: 'Test Group',
- },
- },
- result: {
- data: {
- createGroupChat: {
- _id: '669394c180e96b740ba1c0ce',
- __typename: 'GroupChat',
- },
- },
- },
- },
-];
-
-const link = new StaticMockLink(MOCKS, true);
-
async function wait(ms = 100): Promise {
await act(() => {
return new Promise((resolve) => {
@@ -2557,7 +2223,7 @@ async function wait(ms = 100): Promise {
});
}
-describe('Testing Create Direct Chat Modal [User Portal]', () => {
+describe('Testing Create Group Chat Modal [User Portal]', () => {
window.HTMLElement.prototype.scrollIntoView = jest.fn();
Object.defineProperty(window, 'matchMedia', {
@@ -2574,15 +2240,16 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
})),
});
- test('open and close create new direct chat modal', async () => {
+ test('Test open and close create new direct chat modal', async () => {
const mock = [
...USER_JOINED_ORG_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
...UserConnectionListMock,
- ...MOCKS,
+ ...CREATE_CHAT_MUTATION,
+ ...CHATS_LIST_MOCK,
];
render(
@@ -2611,16 +2278,16 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
fireEvent.click(closeButton);
});
- test('create new group chat', async () => {
+ test('Test create new group chat', async () => {
const mock = [
- ...CREATE_GROUP_CHAT_MOCK,
...USER_JOINED_ORG_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
...UserConnectionListMock,
- ...MOCKS,
+ ...CREATE_CHAT_MUTATION,
+ ...CHATS_LIST_MOCK,
];
render(
@@ -2662,12 +2329,35 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
expect(groupTitleInput.value).toBe('Test Group');
});
- const orgSelect = screen.getByLabelText('Select Organization');
+ 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' },
+ // });
- 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(() => {
@@ -2683,22 +2373,22 @@ describe('Testing Create Direct Chat Modal [User Portal]', () => {
fireEvent.click(await screen.findByTestId('createBtn'));
});
- await waitFor(() => {
- expect(createBtn).not.toBeInTheDocument();
- });
+ // await waitFor(() => {
+ // expect(createBtn).not.toBeInTheDocument();
+ // });
}, 3000);
- test('add and remove user', async () => {
+ test('Test add and remove user ', async () => {
setItem('userId', '1');
const mock = [
...USER_JOINED_ORG_MOCK,
- ...CREATE_GROUP_CHAT_MOCK,
...GROUP_CHAT_BY_ID_QUERY_MOCK,
- ...DIRECT_CHAT_BY_ID_QUERY_MOCK,
- ...MESSAGE_SENT_TO_DIRECT_CHAT_MOCK,
- ...MESSAGE_SENT_TO_GROUP_CHAT_MOCK,
+ ...MESSAGE_SENT_TO_CHAT_MOCK,
+ ...CHAT_BY_ID_QUERY_MOCK,
+ ...CHATS_LIST_MOCK,
...UserConnectionListMock,
- ...MOCKS,
+ ...CREATE_CHAT_MUTATION,
+ ...CHATS_LIST_MOCK,
];
render(
diff --git a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx
index e085220d12..099a42310a 100644
--- a/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx
+++ b/src/components/UserPortal/CreateGroupChat/CreateGroupChat.tsx
@@ -1,4 +1,12 @@
-import { Paper, TableBody } from '@mui/material';
+import {
+ FormControl,
+ InputLabel,
+ MenuItem,
+ Paper,
+ Select,
+ TableBody,
+} from '@mui/material';
+import type { SelectChangeEvent } from '@mui/material/Select';
import React, { useEffect, useState } from 'react';
import { Button, Form, Modal } from 'react-bootstrap';
import styles from './CreateGroupChat.module.css';
@@ -6,7 +14,7 @@ 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_GROUP_CHAT } from 'GraphQl/Mutations/OrganizationMutations';
+import { CREATE_CHAT } from 'GraphQl/Mutations/OrganizationMutations';
import Table from '@mui/material/Table';
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
@@ -22,7 +30,7 @@ import { useTranslation } from 'react-i18next';
interface InterfaceCreateGroupChatProps {
toggleCreateGroupChatModal: () => void;
createGroupChatModalisOpen: boolean;
- groupChatListRefetch: (
+ chatsListRefetch: (
variables?:
| Partial<{
id: string;
@@ -55,6 +63,10 @@ interface InterfaceOrganization {
}[];
}
+/**
+ * Styled table cell with custom styles.
+ */
+
const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: {
backgroundColor: ['#31bb6b', '!important'],
@@ -65,6 +77,10 @@ const StyledTableCell = styled(TableCell)(({ theme }) => ({
},
}));
+/**
+ * Styled table row with custom styles.
+ */
+
const StyledTableRow = styled(TableRow)(() => ({
'&:last-child td, &:last-child th': {
border: 0,
@@ -73,17 +89,10 @@ const StyledTableRow = styled(TableRow)(() => ({
const { getItem } = useLocalStorage();
-/**
- *
- * @param toggleCreateGroupChatModal - function to toggle the create group chat modal
- * @param createGroupChatModalisOpen - boolean to check if the create group chat modal is open
- * @param groupChatListRefetch - function to refetch the group chat list
- * @returns - returns the create group chat modal
- */
export default function CreateGroupChat({
toggleCreateGroupChatModal,
createGroupChatModalisOpen,
- groupChatListRefetch,
+ chatsListRefetch,
}: InterfaceCreateGroupChatProps): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'userChat',
@@ -91,7 +100,7 @@ export default function CreateGroupChat({
const userId: string | null = getItem('userId');
- const [createGroupChat] = useMutation(CREATE_GROUP_CHAT);
+ const [createChat] = useMutation(CREATE_CHAT);
const [organizations, setOrganizations] = useState([]);
const [selectedOrganization, setSelectedOrganization] = useState('');
@@ -107,7 +116,7 @@ export default function CreateGroupChat({
const toggleAddUserModal = /* istanbul ignore next */ (): void =>
setAddUserModalisOpen(!addUserModalisOpen);
- const handleChange = (event: React.ChangeEvent): void => {
+ const handleChange = (event: SelectChangeEvent): void => {
setSelectedOrganization(event.target.value as string);
};
@@ -129,14 +138,15 @@ export default function CreateGroupChat({
}, [userIds]);
async function handleCreateGroupChat(): Promise {
- await createGroupChat({
+ await createChat({
variables: {
organizationId: selectedOrganization,
userIds: [userId, ...userIds],
- title,
+ name: title,
+ isGroup: true,
},
});
- groupChatListRefetch();
+ chatsListRefetch();
toggleAddUserModal();
toggleCreateGroupChatModal();
reset();
@@ -175,7 +185,6 @@ export default function CreateGroupChat({
const organizations =
joinedOrganizationsData.users[0]?.user?.joinedOrganizations || [];
setOrganizations(organizations);
- setSelectedOrganization(organizations[0]?._id);
}
}, [joinedOrganizationsData]);
@@ -192,50 +201,51 @@ export default function CreateGroupChat({
- Select Organization
-
+ Select Organization
+
+ */}
+
+ Select Organization
+
-
-
- {/*
- Select Organization
-
- */}
+
+
Group name
{
fireEvent.click(screen.getByTestId('joinBtn'));
await wait();
- expect(toast.success).toHaveBeenCalledWith('users.MembershipRequestSent');
+ expect(toast.success).toHaveBeenCalledWith('MembershipRequestSent');
});
test('send membership request to public org', async () => {
diff --git a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx
index abad27dbad..34022fcfcf 100644
--- a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx
+++ b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import styles from './OrganizationNavbar.module.css';
-import TalawaImage from 'assets/images/talawa-logo-200x200.png';
+import TalawaImage from 'assets/images/talawa-logo-600x600.png';
import { Container, Dropdown, Nav, Navbar, Offcanvas } from 'react-bootstrap';
import { languages } from 'utils/languages';
import i18next from 'i18next';
diff --git a/src/components/UserPortal/UserNavbar/UserNavbar.tsx b/src/components/UserPortal/UserNavbar/UserNavbar.tsx
index 25b3bd2578..4160b00aad 100644
--- a/src/components/UserPortal/UserNavbar/UserNavbar.tsx
+++ b/src/components/UserPortal/UserNavbar/UserNavbar.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import styles from './UserNavbar.module.css';
-import TalawaImage from 'assets/images/talawa-logo-200x200.png';
+import TalawaImage from 'assets/images/talawa-logo-600x600.png';
import { Container, Dropdown, Navbar } from 'react-bootstrap';
import { languages } from 'utils/languages';
import i18next from 'i18next';
diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.tsx
index 25086d24b2..5e258f8a8e 100644
--- a/src/components/UserPortal/UserSidebar/UserSidebar.tsx
+++ b/src/components/UserPortal/UserSidebar/UserSidebar.tsx
@@ -2,10 +2,10 @@ import React from 'react';
import Button from 'react-bootstrap/Button';
import { useTranslation } from 'react-i18next';
import { NavLink } from 'react-router-dom';
-import { ReactComponent as OrganizationsIcon } from 'assets/svgs/organizations.svg';
-import { ReactComponent as SettingsIcon } from 'assets/svgs/settings.svg';
-import { ReactComponent as ChatIcon } from 'assets/svgs/chat.svg';
-import { ReactComponent as TalawaLogo } from 'assets/svgs/talawa.svg';
+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';
export interface InterfaceUserSidebarProps {
diff --git a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx
index c187dabb55..2f28d9afd1 100644
--- a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx
+++ b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx
@@ -331,7 +331,7 @@ describe('Testing LeftDrawerOrg component for SUPERADMIN', () => {
);
await wait();
resizeWindow(800);
- expect(screen.getByText(/People/i)).toBeInTheDocument();
+ expect(screen.getAllByText(/People/i)[0]).toBeInTheDocument();
const peopelBtn = screen.getByTestId(/People/i);
userEvent.click(peopelBtn);
diff --git a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx
index 19866ee2e4..19036b2307 100644
--- a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx
+++ b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.tsx
@@ -9,8 +9,8 @@ import { useTranslation } from 'react-i18next';
import { NavLink } from 'react-router-dom';
import type { TargetsType } from 'state/reducers/routesReducer';
import type { InterfaceQueryOrganizationsListObject } from 'utils/interfaces';
-import { ReactComponent as AngleRightIcon } from 'assets/svgs/angleRight.svg';
-import { ReactComponent as TalawaLogo } from 'assets/svgs/talawa.svg';
+import AngleRightIcon from 'assets/svgs/angleRight.svg?react';
+import TalawaLogo from 'assets/svgs/talawa.svg?react';
import styles from './UserSidebarOrg.module.css';
import Avatar from 'components/Avatar/Avatar';
diff --git a/src/components/Venues/VenueCard.tsx b/src/components/Venues/VenueCard.tsx
index f9f50cace8..752ac95139 100644
--- a/src/components/Venues/VenueCard.tsx
+++ b/src/components/Venues/VenueCard.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import { Card, Button } from 'react-bootstrap';
import defaultImg from 'assets/images/defaultImg.png';
-import { ReactComponent as PeopleIcon } from 'assets/svgs/people.svg';
+import PeopleIcon from 'assets/svgs/people.svg?react';
import styles from 'screens/OrganizationVenues/OrganizationVenues.module.css';
import { useTranslation } from 'react-i18next';
import type { InterfaceQueryVenueListItem } from 'utils/interfaces';
diff --git a/src/index.tsx b/src/index.tsx
index 7a1bbeba59..ec1d45ae69 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -44,6 +44,7 @@ const theme = createTheme({
});
import useLocalStorage from 'utils/useLocalstorage';
import i18n from './utils/i18n';
+import { requestMiddleware, responseMiddleware } from 'utils/timezoneUtils';
const { getItem } = useLocalStorage();
const authLink = setContext((_, { headers }) => {
@@ -123,7 +124,13 @@ const splitLink = split(
httpLink,
);
-const combinedLink = ApolloLink.from([errorLink, authLink, splitLink]);
+const combinedLink = ApolloLink.from([
+ errorLink,
+ authLink,
+ requestMiddleware,
+ responseMiddleware,
+ splitLink,
+]);
const client: ApolloClient = new ApolloClient({
cache: new InMemoryCache(),
diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts
deleted file mode 100644
index 6431bc5fc6..0000000000
--- a/src/react-app-env.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-///
diff --git a/src/screens/CommunityProfile/CommunityProfile.tsx b/src/screens/CommunityProfile/CommunityProfile.tsx
index 02f8b8aca4..d96c923eb3 100644
--- a/src/screens/CommunityProfile/CommunityProfile.tsx
+++ b/src/screens/CommunityProfile/CommunityProfile.tsx
@@ -20,6 +20,7 @@ import {
import convertToBase64 from 'utils/convertToBase64';
import styles from './CommunityProfile.module.css';
import { errorHandler } from 'utils/errorHandler';
+import UpdateSession from '../../components/UpdateSession/UpdateSession';
/**
* `CommunityProfile` component allows users to view and update their community profile details.
@@ -208,212 +209,218 @@ const CommunityProfile = (): JSX.Element => {
}
return (
-
-
-
- {t('communityProfileInfo')}
-
-
- {t('communityName')}
-
-
-
-
-
- {t('wesiteLink')}
-
-
-
-
- {t('logo')}
- ,
- ): Promise => {
- setProfileVariable((prevInput) => ({
- ...prevInput,
- logo: '',
- }));
- const target = e.target as HTMLInputElement;
- const file = target.files && target.files[0];
- const base64file = file && (await convertToBase64(file));
- setProfileVariable({
- ...profileVariable,
- logoUrl: base64file ?? '',
- });
- }}
- className="mb-3"
- autoComplete="off"
- required
- />
-
-
- {t('social')}
- {/* Social media inputs */}
-
-
+ <>
+
+
+
+ {t('communityProfileInfo')}
+
+
+ {t('communityName')}
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ {t('wesiteLink')}
+
-
-
-
+
+
+ {t('logo')}
,
+ ): Promise => {
+ setProfileVariable((prevInput) => ({
+ ...prevInput,
+ logo: '',
+ }));
+ const target = e.target as HTMLInputElement;
+ const file = target.files?.[0];
+ const base64file = file && (await convertToBase64(file));
+ setProfileVariable({
+ ...profileVariable,
+ logoUrl: base64file ?? '',
+ });
+ }}
+ className="mb-3"
autoComplete="off"
+ required
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ >
);
};
diff --git a/src/screens/EventManagement/EventManagement.module.css b/src/screens/EventManagement/EventManagement.module.css
deleted file mode 100644
index f7e911887c..0000000000
--- a/src/screens/EventManagement/EventManagement.module.css
+++ /dev/null
@@ -1,8 +0,0 @@
-.content {
- width: 100%;
- height: 100%;
- min-height: 80vh;
- box-sizing: border-box;
- background: #ffffff;
- border-radius: 1rem;
-}
diff --git a/src/screens/EventManagement/EventManagement.tsx b/src/screens/EventManagement/EventManagement.tsx
index 74dfc806ce..8a5b685855 100644
--- a/src/screens/EventManagement/EventManagement.tsx
+++ b/src/screens/EventManagement/EventManagement.tsx
@@ -1,18 +1,16 @@
import React, { useState } from 'react';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
-import styles from './EventManagement.module.css';
import { Navigate, useNavigate, useParams } from 'react-router-dom';
-import { ReactComponent as AngleLeftIcon } from 'assets/svgs/angleLeft.svg';
-import { ReactComponent as EventDashboardIcon } from 'assets/svgs/eventDashboard.svg';
-import { ReactComponent as EventRegistrantsIcon } from 'assets/svgs/people.svg';
-import { ReactComponent as EventActionsIcon } from 'assets/svgs/settings.svg';
-import { ReactComponent as EventAgendaItemsIcon } from 'assets/svgs/agenda-items.svg';
-import { ReactComponent as EventStatisticsIcon } from 'assets/svgs/eventStats.svg';
+import { FaChevronLeft, FaTasks } from 'react-icons/fa';
+import { MdOutlineDashboard } from 'react-icons/md';
+import EventRegistrantsIcon from 'assets/svgs/people.svg?react';
+import { IoMdStats } from 'react-icons/io';
+import EventAgendaItemsIcon from 'assets/svgs/agenda-items.svg?react';
import { useTranslation } from 'react-i18next';
-import { Button } from 'react-bootstrap';
+import { Button, Dropdown } from 'react-bootstrap';
import EventDashboard from 'components/EventManagement/Dashboard/EventDashboard';
-import EventActionItems from 'components/EventManagement/EventActionItems/EventActionItems';
+import OrganizationActionItems from 'screens/OrganizationActionItems/OrganizationActionItems';
import EventAgendaItems from 'components/EventManagement/EventAgendaItems/EventAgendaItems';
import useLocalStorage from 'utils/useLocalstorage';
@@ -27,7 +25,7 @@ const eventDashboardTabs: {
}[] = [
{
value: 'dashboard',
- icon: ,
+ icon: ,
},
{
value: 'registrants',
@@ -35,7 +33,7 @@ const eventDashboardTabs: {
},
{
value: 'eventActions',
- icon: ,
+ icon: ,
},
{
value: 'eventAgendas',
@@ -43,7 +41,7 @@ const eventDashboardTabs: {
},
{
value: 'eventStats',
- icon: ,
+ icon: ,
},
];
@@ -107,15 +105,6 @@ const EventManagement = (): JSX.Element => {
// State hook for managing the currently selected tab
const [tab, setTab] = useState('dashboard');
- /**
- * Handles tab button clicks to update the selected tab.
- *
- * @param value - The value representing the tab to select
- */
- const handleClick = (value: TabOptions): void => {
- setTab(value);
- };
-
/**
* Renders a button for each tab with the appropriate icon and label.
*
@@ -133,14 +122,16 @@ const EventManagement = (): JSX.Element => {
const selected = tab === value;
const variant = selected ? 'success' : 'light';
const translatedText = t(value);
+
const className = selected
- ? 'px-4'
- : 'text-secondary border-secondary-subtle px-4';
+ ? 'px-4 d-flex align-items-center shadow'
+ : 'text-secondary bg-white px-4 d-flex align-items-center rounded shadow';
const props = {
variant,
className,
+ style: { height: '2.5rem' },
size: 'sm' as 'sm' | 'lg',
- onClick: () => handleClick(value),
+ onClick: () => setTab(value),
'data-testid': `${value}Btn`,
};
@@ -152,66 +143,102 @@ const EventManagement = (): JSX.Element => {
);
};
+ const handleBack = (): void => {
+ /*istanbul ignore next*/
+ userRole === 'USER'
+ ? navigate(`/user/events/${orgId}`)
+ : navigate(`/orgevents/${orgId}`);
+ };
+
return (
-
-
-
{
- /*istanbul ignore next*/
- userRole === 'USER'
- ? navigate(`/user/events/${orgId}`)
- : navigate(`/orgevents/${orgId}`);
- }}
- className="mt-1"
- />
-
- {eventDashboardTabs.map(renderButton)}
-
-
-
-
- {/* Render content based on the selected tab */}
- {(() => {
- switch (tab) {
- case 'dashboard':
- return (
-
-
-
- );
- case 'registrants':
- return (
-
-
Event Registrants
-
- );
- case 'eventActions':
- return (
-
-
-
- );
- case 'eventAgendas':
- return (
-
-
-
- );
- case 'eventStats':
- return (
-
-
Event Statistics
-
- );
- }
- })()}
+
+
+
+
+
+
+
+ {eventDashboardTabs.map(renderButton)}
+
+
+
+
+ {t(tab)}
+
+
+ {/* Render dropdown items for each settings category */}
+ {eventDashboardTabs.map(({ value, icon }, index) => (
+ setTab(value)
+ }
+ className={`d-flex gap-2 ${tab === value && 'text-secondary'}`}
+ >
+ {icon} {t(value)}
+
+ ))}
+
+
+
+
+
+
+
+ {/* Render content based on the selected settings category */}
+ {(() => {
+ switch (tab) {
+ case 'dashboard':
+ return (
+
+
+
+ );
+ case 'registrants':
+ return (
+
+
Event Registrants
+
+ );
+ case 'eventActions':
+ return (
+
+
+
+ );
+ case 'eventAgendas':
+ return (
+
+
+
+ );
+ case 'eventStats':
+ return (
+
+
Event Statistics
+
+ );
+ }
+ })()}
);
};
diff --git a/src/screens/ForgotPassword/ForgotPassword.test.tsx b/src/screens/ForgotPassword/ForgotPassword.test.tsx
index b20dfbf767..be1b1706f8 100644
--- a/src/screens/ForgotPassword/ForgotPassword.test.tsx
+++ b/src/screens/ForgotPassword/ForgotPassword.test.tsx
@@ -1,13 +1,13 @@
-import React, { act } from 'react';
+import React from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { render, screen } from '@testing-library/react';
+import { act, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import 'jest-localstorage-mock';
import 'jest-location-mock';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
-import { ToastContainer } from 'react-toastify';
+import { toast, ToastContainer } from 'react-toastify';
import { GENERATE_OTP_MUTATION } from 'GraphQl/Mutations/mutations';
import { store } from 'state/store';
@@ -19,6 +19,14 @@ import useLocalStorage from 'utils/useLocalstorage';
const { setItem, removeItem } = useLocalStorage();
+jest.mock('react-toastify', () => ({
+ toast: {
+ success: jest.fn(),
+ error: jest.fn(),
+ warn: jest.fn(),
+ },
+}));
+
const MOCKS = [
{
request: {
@@ -159,7 +167,9 @@ describe('Testing Forgot Password screen', () => {
);
userEvent.click(screen.getByText('Get OTP'));
- await wait();
+ await waitFor(() => {
+ expect(toast.success).toHaveBeenCalled();
+ });
});
test('Testing forgot password functionality', async () => {
@@ -294,7 +304,6 @@ describe('Testing Forgot Password screen', () => {
-
@@ -310,11 +319,9 @@ describe('Testing Forgot Password screen', () => {
);
userEvent.click(screen.getByText('Get OTP'));
- await wait();
-
- expect(
- await screen.findByText(translations.emailNotRegistered),
- ).toBeInTheDocument();
+ await waitFor(() => {
+ expect(toast.warn).toHaveBeenCalledWith(translations.emailNotRegistered);
+ });
});
test('Testing forgot password functionality, when there is an error except unregistered email and api failure', async () => {
@@ -323,7 +330,6 @@ describe('Testing Forgot Password screen', () => {
-
@@ -331,11 +337,9 @@ describe('Testing Forgot Password screen', () => {
,
);
userEvent.click(screen.getByText('Get OTP'));
- await wait();
-
- expect(
- await screen.findByText(translations.errorSendingMail),
- ).toBeInTheDocument();
+ await waitFor(() => {
+ expect(toast.error).toHaveBeenCalledWith(translations.errorSendingMail);
+ });
});
test('Testing forgot password functionality, when talawa api failed', async () => {
@@ -347,7 +351,6 @@ describe('Testing Forgot Password screen', () => {
-
@@ -362,11 +365,11 @@ describe('Testing Forgot Password screen', () => {
formData.email,
);
userEvent.click(screen.getByText('Get OTP'));
- await wait();
-
- expect(
- await screen.findByText(translations.talawaApiUnavailable),
- ).toBeInTheDocument();
+ await waitFor(() => {
+ expect(toast.error).toHaveBeenCalledWith(
+ translations.talawaApiUnavailable,
+ );
+ });
});
test('Testing forgot password functionality, when otp token is not present', async () => {
diff --git a/src/screens/ForgotPassword/ForgotPassword.tsx b/src/screens/ForgotPassword/ForgotPassword.tsx
index a2e638fd59..663960572b 100644
--- a/src/screens/ForgotPassword/ForgotPassword.tsx
+++ b/src/screens/ForgotPassword/ForgotPassword.tsx
@@ -8,7 +8,7 @@ import {
FORGOT_PASSWORD_MUTATION,
GENERATE_OTP_MUTATION,
} from 'GraphQl/Mutations/mutations';
-import { ReactComponent as KeyLogo } from 'assets/svgs/key.svg';
+import KeyLogo from 'assets/svgs/key.svg?react';
import ArrowRightAlt from '@mui/icons-material/ArrowRightAlt';
import Loader from 'components/Loader/Loader';
@@ -90,20 +90,16 @@ const ForgotPassword = (): JSX.Element => {
},
});
- if (data) {
- setItem('otpToken', data.otp.otpToken);
- toast.success(t('OTPsent') as string);
- setShowEnterEmail(false);
- }
+ setItem('otpToken', data.otp.otpToken);
+ toast.success(t('OTPsent'));
+ setShowEnterEmail(false);
} catch (error: unknown) {
- if (error instanceof Error) {
- if (error.message === 'User not found') {
- toast.warn(tErrors('emailNotRegistered') as string);
- } else if (error.message === 'Failed to fetch') {
- toast.error(tErrors('talawaApiUnavailable') as string);
- } else {
- toast.error(tErrors('errorSendingMail') as string);
- }
+ if ((error as Error).message === 'User not found') {
+ toast.warn(tErrors('emailNotRegistered'));
+ } else if ((error as Error).message === 'Failed to fetch') {
+ toast.error(tErrors('talawaApiUnavailable'));
+ } else {
+ toast.error(tErrors('errorSendingMail'));
}
}
};
diff --git a/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx b/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx
index 25e049e19d..3fb5993775 100644
--- a/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx
+++ b/src/screens/FundCampaignPledge/FundCampaignPledge.test.tsx
@@ -85,17 +85,6 @@ describe('Testing Campaign Pledge Screen', () => {
jest.clearAllMocks();
});
- afterEach(() => {
- cleanup();
- });
-
- it('should render the Campaign Pledge screen', async () => {
- renderFundCampaignPledge(link1);
- await waitFor(() => {
- expect(screen.getByTestId('searchPledger')).toBeInTheDocument();
- });
- });
-
it('should redirect to fallback URL if URL params are undefined', async () => {
render(
@@ -122,6 +111,13 @@ describe('Testing Campaign Pledge Screen', () => {
});
});
+ it('should render the Campaign Pledge screen', async () => {
+ renderFundCampaignPledge(link1);
+ await waitFor(() => {
+ expect(screen.getByTestId('searchPledger')).toBeInTheDocument();
+ });
+ });
+
it('open and closes Create Pledge modal', async () => {
renderFundCampaignPledge(link1);
@@ -213,6 +209,19 @@ describe('Testing Campaign Pledge Screen', () => {
await waitFor(() => {
expect(screen.getByTestId('searchPledger')).toBeInTheDocument();
});
+ const searchPledger = await screen.findByTestId('searchPledger');
+ expect(searchPledger).toBeInTheDocument();
+
+ fireEvent.click(screen.getByTestId('filter'));
+ await waitFor(() => {
+ expect(screen.getByTestId('amount_DESC')).toBeInTheDocument();
+ });
+ fireEvent.click(screen.getByTestId('amount_DESC'));
+
+ await waitFor(() => {
+ expect(screen.getByText('John Doe')).toBeInTheDocument();
+ expect(screen.queryByText('Jane Doe')).toBeInTheDocument();
+ });
expect(screen.getByText('John Doe')).toBeInTheDocument();
expect(screen.getByText('John Doe2')).toBeInTheDocument();
diff --git a/src/screens/FundCampaignPledge/FundCampaignPledge.tsx b/src/screens/FundCampaignPledge/FundCampaignPledge.tsx
index 9b593f2951..f7e339dc89 100644
--- a/src/screens/FundCampaignPledge/FundCampaignPledge.tsx
+++ b/src/screens/FundCampaignPledge/FundCampaignPledge.tsx
@@ -130,7 +130,7 @@ const fundCampaignPledge = (): JSX.Element => {
'YYYY-MM-DD',
).toDate();
- const { pledges, totalPledged } = useMemo(() => {
+ const { pledges, totalPledged, fundName } = useMemo(() => {
let totalPledged = 0;
const pledges =
pledgeData?.getFundraisingCampaigns[0].pledges.filter((pledge) => {
@@ -141,7 +141,9 @@ const fundCampaignPledge = (): JSX.Element => {
return fullName.toLowerCase().includes(search);
});
}) ?? [];
- return { pledges, totalPledged };
+ const fundName =
+ pledgeData?.getFundraisingCampaigns[0].fundId.name ?? tCommon('Funds');
+ return { pledges, totalPledged, fundName };
}, [pledgeData, searchTerm]);
useEffect(() => {
@@ -392,7 +394,7 @@ const fundCampaignPledge = (): JSX.Element => {
() => history.go(-2)
}
>
- {tCommon('Funds')}
+ {fundName}
{
() => history.back()
}
>
- {t('campaigns')}
+ {campaignInfo?.name}
{t('pledges')}
diff --git a/src/screens/FundCampaignPledge/PledgesMocks.ts b/src/screens/FundCampaignPledge/PledgesMocks.ts
index 0dc9c10e56..2a583fa887 100644
--- a/src/screens/FundCampaignPledge/PledgesMocks.ts
+++ b/src/screens/FundCampaignPledge/PledgesMocks.ts
@@ -6,7 +6,48 @@ import {
import { MEMBERS_LIST } from 'GraphQl/Queries/Queries';
import { FUND_CAMPAIGN_PLEDGE } from 'GraphQl/Queries/fundQueries';
+const memberList = {
+ request: {
+ query: MEMBERS_LIST,
+ variables: {
+ id: 'orgId',
+ },
+ },
+ result: {
+ data: {
+ organizations: [
+ {
+ _id: 'orgId',
+ members: [
+ {
+ createdAt: '2023-04-13T04:53:17.742Z',
+ email: 'testuser4@example.com',
+ firstName: 'John',
+ image: 'img-url',
+ lastName: 'Doe',
+ organizationsBlockedBy: [],
+ __typename: 'User',
+ _id: '1',
+ },
+ {
+ createdAt: '2024-04-13T04:53:17.742Z',
+ email: 'testuser2@example.com',
+ firstName: 'Anna',
+ image: null,
+ lastName: 'Bradley',
+ organizationsBlockedBy: [],
+ __typename: 'User',
+ _id: '2',
+ },
+ ],
+ },
+ ],
+ },
+ },
+};
+
export const MOCKS = [
+ memberList,
{
request: {
query: FUND_CAMPAIGN_PLEDGE,
@@ -21,6 +62,9 @@ export const MOCKS = [
data: {
getFundraisingCampaigns: [
{
+ fundId: {
+ name: 'Fund 1',
+ },
name: 'Campaign Name',
fundingGoal: 1000,
currency: 'USD',
@@ -40,60 +84,6 @@ export const MOCKS = [
lastName: 'Doe',
image: 'img-url',
},
- {
- _id: '2',
- firstName: 'John',
- lastName: 'Doe2',
- image: 'img-url2',
- },
- {
- _id: '3',
- firstName: 'John',
- lastName: 'Doe3',
- image: 'img-url3',
- },
- {
- _id: '4',
- firstName: 'John',
- lastName: 'Doe4',
- image: 'img-url4',
- },
- {
- _id: '5',
- firstName: 'John',
- lastName: 'Doe5',
- image: 'img-url5',
- },
- {
- _id: '6',
- firstName: 'John',
- lastName: 'Doe6',
- image: 'img-url6',
- },
- {
- _id: '7',
- firstName: 'John',
- lastName: 'Doe7',
- image: 'img-url7',
- },
- {
- _id: '8',
- firstName: 'John',
- lastName: 'Doe8',
- image: 'img-url8',
- },
- {
- _id: '9',
- firstName: 'John',
- lastName: 'Doe9',
- image: 'img-url9',
- },
- {
- _id: '10',
- firstName: 'John',
- lastName: 'Doe10',
- image: null,
- },
],
},
{
@@ -131,6 +121,9 @@ export const MOCKS = [
data: {
getFundraisingCampaigns: [
{
+ fundId: {
+ name: 'Fund 1',
+ },
name: 'Campaign Name',
fundingGoal: 1000,
currency: 'USD',
@@ -187,6 +180,9 @@ export const MOCKS = [
data: {
getFundraisingCampaigns: [
{
+ fundId: {
+ name: 'Fund 1',
+ },
name: 'Campaign Name',
fundingGoal: 1000,
currency: 'USD',
@@ -206,6 +202,60 @@ export const MOCKS = [
lastName: 'Doe',
image: null,
},
+ {
+ _id: '2',
+ firstName: 'John',
+ lastName: 'Doe2',
+ image: 'img-url2',
+ },
+ {
+ _id: '3',
+ firstName: 'John',
+ lastName: 'Doe3',
+ image: 'img-url3',
+ },
+ {
+ _id: '4',
+ firstName: 'John',
+ lastName: 'Doe4',
+ image: 'img-url4',
+ },
+ {
+ _id: '5',
+ firstName: 'John',
+ lastName: 'Doe5',
+ image: 'img-url5',
+ },
+ {
+ _id: '6',
+ firstName: 'John',
+ lastName: 'Doe6',
+ image: 'img-url6',
+ },
+ {
+ _id: '7',
+ firstName: 'John',
+ lastName: 'Doe7',
+ image: 'img-url7',
+ },
+ {
+ _id: '8',
+ firstName: 'John',
+ lastName: 'Doe8',
+ image: 'img-url8',
+ },
+ {
+ _id: '9',
+ firstName: 'John',
+ lastName: 'Doe9',
+ image: 'img-url9',
+ },
+ {
+ _id: '10',
+ firstName: 'John',
+ lastName: 'Doe10',
+ image: null,
+ },
],
},
{
@@ -243,6 +293,9 @@ export const MOCKS = [
data: {
getFundraisingCampaigns: [
{
+ fundId: {
+ name: 'Fund 1',
+ },
name: 'Campaign Name',
fundingGoal: 1000,
currency: 'USD',
@@ -303,6 +356,7 @@ export const MOCKS = [
];
export const MOCKS_FUND_CAMPAIGN_PLEDGE_ERROR = [
+ memberList,
{
request: {
query: FUND_CAMPAIGN_PLEDGE,
@@ -318,6 +372,7 @@ export const MOCKS_FUND_CAMPAIGN_PLEDGE_ERROR = [
];
export const MOCKS_DELETE_PLEDGE_ERROR = [
+ memberList,
{
request: {
query: DELETE_PLEDGE,
@@ -330,6 +385,7 @@ export const MOCKS_DELETE_PLEDGE_ERROR = [
];
export const EMPTY_MOCKS = [
+ memberList,
{
request: {
query: FUND_CAMPAIGN_PLEDGE,
@@ -344,6 +400,9 @@ export const EMPTY_MOCKS = [
data: {
getFundraisingCampaigns: [
{
+ fundId: {
+ name: 'Fund 1',
+ },
name: 'Campaign Name',
fundingGoal: 1000,
currency: 'USD',
@@ -358,45 +417,7 @@ export const EMPTY_MOCKS = [
];
export const PLEDGE_MODAL_MOCKS = [
- {
- request: {
- query: MEMBERS_LIST,
- variables: {
- id: 'orgId',
- },
- },
- result: {
- data: {
- organizations: [
- {
- _id: 'orgId',
- members: [
- {
- createdAt: '2023-04-13T04:53:17.742Z',
- email: 'testuser4@example.com',
- firstName: 'John',
- image: 'img-url',
- lastName: 'Doe',
- organizationsBlockedBy: [],
- __typename: 'User',
- _id: '1',
- },
- {
- createdAt: '2024-04-13T04:53:17.742Z',
- email: 'testuser2@example.com',
- firstName: 'Anna',
- image: null,
- lastName: 'Bradley',
- organizationsBlockedBy: [],
- __typename: 'User',
- _id: '2',
- },
- ],
- },
- ],
- },
- },
- },
+ memberList,
{
request: {
query: UPDATE_PLEDGE,
diff --git a/src/screens/LoginPage/LoginPage.tsx b/src/screens/LoginPage/LoginPage.tsx
index 56b9012ee8..2ed1e71c13 100644
--- a/src/screens/LoginPage/LoginPage.tsx
+++ b/src/screens/LoginPage/LoginPage.tsx
@@ -23,8 +23,8 @@ import {
SIGNUP_MUTATION,
} from 'GraphQl/Mutations/mutations';
import { GET_COMMUNITY_DATA, ORGANIZATION_LIST } from 'GraphQl/Queries/Queries';
-import { ReactComponent as PalisadoesLogo } from 'assets/svgs/palisadoes.svg';
-import { ReactComponent as TalawaLogo } from 'assets/svgs/talawa.svg';
+import PalisadoesLogo from 'assets/svgs/palisadoes.svg?react';
+import TalawaLogo from 'assets/svgs/talawa.svg?react';
import ChangeLanguageDropDown from 'components/ChangeLanguageDropdown/ChangeLanguageDropDown';
import LoginPortalToggle from 'components/LoginPortalToggle/LoginPortalToggle';
import { errorHandler } from 'utils/errorHandler';
@@ -33,6 +33,7 @@ import { socialMediaLinks } from '../../constants';
import styles from './LoginPage.module.css';
import type { InterfaceQueryOrganizationListObject } from 'utils/interfaces';
import { Autocomplete, TextField } from '@mui/material';
+import useSession from 'utils/useSession';
import i18n from 'utils/i18n';
/**
@@ -41,6 +42,7 @@ import i18n from 'utils/i18n';
* register form.
*
*/
+
const loginPage = (): JSX.Element => {
const { t } = useTranslation('translation', { keyPrefix: 'loginPage' });
const { t: tCommon } = useTranslation('common');
@@ -110,6 +112,7 @@ const loginPage = (): JSX.Element => {
const isLoggedIn = getItem('IsLoggedIn');
if (isLoggedIn == 'TRUE') {
navigate(getItem('userId') !== null ? '/user/organizations' : '/orglist');
+ extendSession();
}
}, []);
@@ -126,7 +129,7 @@ const loginPage = (): JSX.Element => {
const [signup, { loading: signinLoading }] = useMutation(SIGNUP_MUTATION);
const [recaptcha] = useMutation(RECAPTCHA_MUTATION);
const { data: orgData } = useQuery(ORGANIZATION_LIST);
-
+ const { startSession, extendSession } = useSession();
useEffect(() => {
if (orgData) {
const options = orgData.organizations.map(
@@ -325,6 +328,7 @@ const loginPage = (): JSX.Element => {
}
navigate(role === 'admin' ? '/orglist' : '/user/organizations');
+ startSession();
} else {
toast.warn(tErrors('notFound') as string);
}
diff --git a/src/screens/OrgSettings/OrgSettings.mocks.ts b/src/screens/OrgSettings/OrgSettings.mocks.ts
new file mode 100644
index 0000000000..02748dbf70
--- /dev/null
+++ b/src/screens/OrgSettings/OrgSettings.mocks.ts
@@ -0,0 +1,143 @@
+import {
+ ACTION_ITEM_CATEGORY_LIST,
+ AGENDA_ITEM_CATEGORY_LIST,
+ IS_SAMPLE_ORGANIZATION_QUERY,
+ ORGANIZATION_CUSTOM_FIELDS,
+ ORGANIZATIONS_LIST,
+} from 'GraphQl/Queries/Queries';
+
+export const MOCKS = [
+ {
+ request: {
+ query: ORGANIZATIONS_LIST,
+ variables: {
+ id: 'orgId',
+ },
+ },
+ result: {
+ data: {
+ organizations: [
+ {
+ _id: 'orgId',
+ image: null,
+ creator: {
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ email: 'testsuperadmin@example.com',
+ __typename: 'User',
+ },
+ name: 'Unity Foundation',
+ description:
+ 'A foundation aimed at uniting the world and making it a better place for all.',
+ address: {
+ city: 'Bronx',
+ countryCode: 'US',
+ dependentLocality: 'Some Dependent Locality',
+ line1: '123 Random Street',
+ line2: 'Apartment 456',
+ postalCode: '10451',
+ sortingCode: 'ABC-123',
+ state: 'NYC',
+ __typename: 'Address',
+ },
+ userRegistrationRequired: false,
+ visibleInSearch: true,
+ members: [
+ {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ email: 'testsuperadmin@example.com',
+ __typename: 'User',
+ },
+ ],
+ admins: [
+ {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ email: 'testsuperadmin@example.com',
+ createdAt: '2023-04-13T04:53:17.742Z',
+ __typename: 'User',
+ },
+ ],
+ membershipRequests: [],
+ blockedUsers: [],
+ __typename: 'Organization',
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: ORGANIZATION_CUSTOM_FIELDS,
+ variables: { customFieldsByOrganizationId: 'orgId' },
+ },
+ result: {
+ data: {
+ customFieldsByOrganization: [
+ {
+ _id: 'adsdasdsa334343yiu423434',
+ type: 'fieldType',
+ name: 'fieldName',
+ },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: IS_SAMPLE_ORGANIZATION_QUERY,
+ variables: { isSampleOrganizationId: 'orgId' },
+ },
+ result: {
+ data: {
+ isSampleOrganization: false,
+ },
+ },
+ },
+
+ {
+ request: {
+ query: AGENDA_ITEM_CATEGORY_LIST,
+ variables: { organizationId: 'orgId' },
+ },
+ result: {
+ data: {
+ agendaItemCategoriesByOrganization: [],
+ },
+ },
+ },
+ {
+ request: {
+ query: ACTION_ITEM_CATEGORY_LIST,
+ variables: {
+ organizationId: 'orgId',
+ where: {
+ name_contains: '',
+ },
+ orderBy: 'createdAt_DESC',
+ },
+ },
+ result: {
+ data: {
+ actionItemCategoriesByOrganization: [
+ {
+ _id: 'actionItemCategoryId1',
+ name: 'Test 3',
+ isDisabled: false,
+ createdAt: '2024-08-25',
+ creator: {
+ _id: '64378abd85008f171cf2990d',
+ firstName: 'Wilt',
+ lastName: 'Shepherd',
+ __typename: 'User',
+ },
+ __typename: 'ActionItemCategory',
+ },
+ ],
+ },
+ },
+ },
+];
diff --git a/src/screens/OrgSettings/OrgSettings.module.css b/src/screens/OrgSettings/OrgSettings.module.css
index 6910ff49ad..9952a9a459 100644
--- a/src/screens/OrgSettings/OrgSettings.module.css
+++ b/src/screens/OrgSettings/OrgSettings.module.css
@@ -1,3 +1,6 @@
+.headerBtn {
+ box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 2px;
+}
.settingsContainer {
min-height: 100vh;
}
diff --git a/src/screens/OrgSettings/OrgSettings.test.tsx b/src/screens/OrgSettings/OrgSettings.test.tsx
index efe764da2f..a9aec5f33d 100644
--- a/src/screens/OrgSettings/OrgSettings.test.tsx
+++ b/src/screens/OrgSettings/OrgSettings.test.tsx
@@ -1,170 +1,107 @@
-import React, { act } from 'react';
+import React from 'react';
import { MockedProvider } from '@apollo/react-testing';
+import type { RenderResult } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import 'jest-location-mock';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
-import { BrowserRouter } from 'react-router-dom';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
-import { DELETE_ORGANIZATION_MUTATION } from 'GraphQl/Mutations/mutations';
import { store } from 'state/store';
import { StaticMockLink } from 'utils/StaticMockLink';
import i18nForTest from 'utils/i18nForTest';
import OrgSettings from './OrgSettings';
-import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
import userEvent from '@testing-library/user-event';
-import useLocalStorage from 'utils/useLocalstorage';
-
-const { setItem } = useLocalStorage();
-
-const MOCKS = [
- {
- request: {
- query: ORGANIZATIONS_LIST,
- },
- result: {
- data: {
- organizations: [
- {
- _id: '123',
- image: null,
- name: 'Palisadoes',
- description: 'Equitable Access to STEM Education Jobs',
- location: 'Jamaica',
- isPublic: true,
- visibleInSearch: false,
- creator: {
- firstName: 'John',
- lastName: 'Doe',
- email: 'johndoe@example.com',
- },
- members: {
- _id: '123',
- firstName: 'John',
- lastName: 'Doe',
- email: 'johndoe@gmail.com',
- },
- admins: [
- {
- _id: '123',
- firstName: 'John',
- lastName: 'Doe',
- email: 'johndoe@gmail.com',
- },
- ],
- membershipRequests: {
- _id: '456',
- user: {
- firstName: 'Sam',
- lastName: 'Smith',
- email: 'samsmith@gmail.com',
- },
- },
- blockedUsers: [],
- },
- ],
- },
- },
- },
- {
- request: {
- query: DELETE_ORGANIZATION_MUTATION,
- },
- result: {
- data: {
- removeOrganization: [
- {
- _id: 123,
- },
- ],
- },
- },
- },
-];
-
-const link = new StaticMockLink(MOCKS, true);
+import type { ApolloLink } from '@apollo/client';
+import { LocalizationProvider } from '@mui/x-date-pickers';
+import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
+import { MOCKS } from './OrgSettings.mocks';
+
+const link1 = new StaticMockLink(MOCKS);
+
+const renderOrganisationSettings = (link: ApolloLink): RenderResult => {
+ return render(
+
+
+
+
+
+
+ } />
+
}
+ />
+
+
+
+
+
+ ,
+ );
+};
-async function wait(ms = 100): Promise {
- await act(() => {
- return new Promise((resolve) => {
- setTimeout(resolve, ms);
- });
+describe('Organisation Settings Page', () => {
+ beforeAll(() => {
+ jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useParams: () => ({ orgId: 'orgId' }),
+ }));
});
-}
-const translations = JSON.parse(
- JSON.stringify(i18nForTest.getDataByLanguage('en')?.translation.orgSettings),
-);
-
-afterEach(() => {
- localStorage.clear();
-});
-
-describe('Organisation Settings Page', () => {
- test('correct mock data should be queried', async () => {
- const dataQuery1 = MOCKS[1]?.result?.data?.removeOrganization;
- expect(dataQuery1).toEqual([
- {
- _id: 123,
- },
- ]);
+ afterAll(() => {
+ jest.clearAllMocks();
});
- test('should render props and text elements test for the screen', async () => {
- window.location.assign('/orgsetting/123');
- setItem('SuperAdmin', true);
+ it('should redirect to fallback URL if URL params are undefined', async () => {
render(
-
-
+
+
-
+
+ } />
+ }
+ />
+
-
+
,
);
-
- await wait();
-
- expect(screen.getAllByText(/Delete Organization/i)).toHaveLength(3);
- expect(
- screen.getByText(
- /By clicking on Delete Organization button the organization will be permanently deleted along with its events, tags and all related data/i,
- ),
- ).toBeInTheDocument();
- expect(screen.getByText(/Other Settings/i)).toBeInTheDocument();
- expect(screen.getByText(/Change Language/i)).toBeInTheDocument();
- expect(window.location).toBeAt('/orgsetting/123');
+ await waitFor(() => {
+ expect(screen.getByTestId('paramsError')).toBeInTheDocument();
+ });
});
- test('should render appropriate settings based on the orgSetting state', async () => {
- window.location.assign('/orgsetting/123');
- setItem('SuperAdmin', true);
+ test('should render the organisation settings page', async () => {
+ renderOrganisationSettings(link1);
- const { getAllByText, queryByText } = render(
-
,
- );
+ await waitFor(() => {
+ expect(screen.getByTestId('generalSettings')).toBeInTheDocument();
+ expect(
+ screen.getByTestId('actionItemCategoriesSettings'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByTestId('agendaItemCategoriesSettings'),
+ ).toBeInTheDocument();
+ });
+ userEvent.click(screen.getByTestId('generalSettings'));
- await wait();
+ await waitFor(() => {
+ expect(screen.getByTestId('generalTab')).toBeInTheDocument();
+ });
+ userEvent.click(screen.getByTestId('actionItemCategoriesSettings'));
await waitFor(() => {
- userEvent.click(screen.getByTestId('actionItemCategoriesSettings'));
- const elements = getAllByText(translations.actionItemCategories);
- expect(elements[2]).toBeInTheDocument();
+ expect(screen.getByTestId('actionItemCategoriesTab')).toBeInTheDocument();
});
+ userEvent.click(screen.getByTestId('agendaItemCategoriesSettings'));
await waitFor(() => {
- userEvent.click(screen.getByTestId('generalSettings'));
- expect(queryByText(translations.updateOrganization)).toBeInTheDocument();
+ expect(screen.getByTestId('agendaItemCategoriesTab')).toBeInTheDocument();
});
});
});
diff --git a/src/screens/OrgSettings/OrgSettings.tsx b/src/screens/OrgSettings/OrgSettings.tsx
index 336c4eb427..e4ae5424a6 100644
--- a/src/screens/OrgSettings/OrgSettings.tsx
+++ b/src/screens/OrgSettings/OrgSettings.tsx
@@ -1,18 +1,21 @@
import React, { useState } from 'react';
-import ChangeLanguageDropDown from 'components/ChangeLanguageDropdown/ChangeLanguageDropDown';
-import DeleteOrg from 'components/DeleteOrg/DeleteOrg';
-import OrgUpdate from 'components/OrgUpdate/OrgUpdate';
-import { Button, Card, Dropdown, Form } from 'react-bootstrap';
-import Col from 'react-bootstrap/Col';
-import Row from 'react-bootstrap/Row';
+import { Button, Dropdown, Row, Col } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import styles from './OrgSettings.module.css';
-import OrgProfileFieldSettings from 'components/OrgProfileFieldSettings/OrgProfileFieldSettings';
-import OrgActionItemCategories from 'components/OrgActionItemCategories/OrgActionItemCategories';
-import { useParams } from 'react-router-dom';
+import OrgActionItemCategories from 'components/OrgSettings/ActionItemCategories/OrgActionItemCategories';
+import OrganizationAgendaCategory from 'components/OrgSettings/AgendaItemCategories/OrganizationAgendaCategory';
+import { Navigate, useParams } from 'react-router-dom';
+import GeneralSettings from 'components/OrgSettings/General/GeneralSettings';
// Type representing the different settings categories available
-type SettingType = 'general' | 'actionItemCategories';
+type SettingType = 'general' | 'actionItemCategories' | 'agendaItemCategories';
+
+// List of available settings categories
+const settingtabs: SettingType[] = [
+ 'general',
+ 'actionItemCategories',
+ 'agendaItemCategories',
+];
/**
* The `orgSettings` component provides a user interface for managing various settings related to an organization.
@@ -29,11 +32,7 @@ function orgSettings(): JSX.Element {
keyPrefix: 'orgSettings',
});
- // List of available settings categories
- const orgSettings: SettingType[] = ['general', 'actionItemCategories'];
-
- // State to manage the currently selected settings category
- const [orgSetting, setOrgSetting] = useState