- {props.image ? (
-
- ) : (
-
- )}
-
-
{props.name}
-
- Owner:
- {props.firstName}
-
-
- {props.lastName}
-
-
-
+
+
+
+ {props.image ? (
+
+ ) : (
+
+ )}
+
+
{props.name}
+
+ Owner:
+ {props.firstName}
+
+
+ {props.lastName}
+
+
-
-
- >
+
+
+
);
}
-export {};
-export default organizationCard;
+export default OrganizationCard;
diff --git a/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx b/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx
index 2a9f03a9be..dd65c8649e 100644
--- a/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx
+++ b/src/components/OrganizationCardStart/OrganizationCardStart.test.tsx
@@ -6,12 +6,11 @@ describe('Testing the Organization Cards', () => {
test('should render props and text elements test for the page component', () => {
const props = {
id: '123',
- key: '456',
image: 'https://via.placeholder.com/80',
name: 'Sample',
};
- render(
);
+ render(
);
expect(screen.getByText(props.name)).toBeInTheDocument();
});
@@ -19,12 +18,11 @@ describe('Testing the Organization Cards', () => {
test('Should render text elements when props value is not passed', () => {
const props = {
id: '123',
- key: '456',
image: '',
name: 'Sample',
};
- render(
);
+ render(
);
expect(screen.getByText(props.name)).toBeInTheDocument();
});
diff --git a/src/components/ProfileDropdown/ProfileDropdown.test.tsx b/src/components/ProfileDropdown/ProfileDropdown.test.tsx
index 0efef50591..82ce420aea 100644
--- a/src/components/ProfileDropdown/ProfileDropdown.test.tsx
+++ b/src/components/ProfileDropdown/ProfileDropdown.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { BrowserRouter } from 'react-router-dom';
import ProfileDropdown from './ProfileDropdown';
diff --git a/src/components/RequestsTableItem/RequestsTableItem.test.tsx b/src/components/RequestsTableItem/RequestsTableItem.test.tsx
index 866abc7f68..bbd895300b 100644
--- a/src/components/RequestsTableItem/RequestsTableItem.test.tsx
+++ b/src/components/RequestsTableItem/RequestsTableItem.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { act, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { StaticMockLink } from 'utils/StaticMockLink';
import i18nForTest from 'utils/i18nForTest';
diff --git a/src/components/RequestsTableItem/RequestsTableItem.tsx b/src/components/RequestsTableItem/RequestsTableItem.tsx
index 2b647a9ce2..07feb5d289 100644
--- a/src/components/RequestsTableItem/RequestsTableItem.tsx
+++ b/src/components/RequestsTableItem/RequestsTableItem.tsx
@@ -67,7 +67,7 @@ const RequestsTableItem = (props: Props): JSX.Element => {
});
/* istanbul ignore next */
if (data) {
- toast.success(t('acceptedSuccessfully'));
+ toast.success(t('acceptedSuccessfully') as string);
resetAndRefetch();
}
} catch (error: unknown) {
@@ -95,7 +95,7 @@ const RequestsTableItem = (props: Props): JSX.Element => {
});
/* istanbul ignore next */
if (data) {
- toast.success(t('rejectedSuccessfully'));
+ toast.success(t('rejectedSuccessfully') as string);
resetAndRefetch();
}
} catch (error: unknown) {
diff --git a/src/components/UserListCard/UserListCard.test.tsx b/src/components/UserListCard/UserListCard.test.tsx
index 9f59bb92ce..e2ad552507 100644
--- a/src/components/UserListCard/UserListCard.test.tsx
+++ b/src/components/UserListCard/UserListCard.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import userEvent from '@testing-library/user-event';
import { I18nextProvider } from 'react-i18next';
@@ -14,7 +14,7 @@ const MOCKS = [
{
request: {
query: ADD_ADMIN_MUTATION,
- variable: { userid: '784', orgid: '554' },
+ variables: { userid: '784', orgid: '554' },
},
result: {
data: {
@@ -28,6 +28,7 @@ const MOCKS = [
},
];
const link = new StaticMockLink(MOCKS, true);
+
async function wait(ms = 100): Promise
{
await act(() => {
return new Promise((resolve) => {
@@ -41,7 +42,6 @@ describe('Testing User List Card', () => {
test('Should render props and text elements test for the page component', async () => {
const props = {
- key: 123,
id: '456',
};
@@ -49,7 +49,7 @@ describe('Testing User List Card', () => {
-
+
,
@@ -62,7 +62,6 @@ describe('Testing User List Card', () => {
test('Should render text elements when props value is not passed', async () => {
const props = {
- key: 123,
id: '456',
};
@@ -70,7 +69,7 @@ describe('Testing User List Card', () => {
-
+
,
diff --git a/src/components/UserListCard/UserListCard.tsx b/src/components/UserListCard/UserListCard.tsx
index 193569424f..76ad110ea1 100644
--- a/src/components/UserListCard/UserListCard.tsx
+++ b/src/components/UserListCard/UserListCard.tsx
@@ -47,7 +47,7 @@ function userListCard(props: InterfaceUserListCardProps): JSX.Element {
/* istanbul ignore next */
if (data) {
- toast.success(t('addedAsAdmin'));
+ toast.success(t('addedAsAdmin') as string);
setTimeout(() => {
window.location.reload();
}, 2000);
diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx
index 4fcbb18070..65f5e40f76 100644
--- a/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx
+++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import userEvent from '@testing-library/user-event';
import { I18nextProvider } from 'react-i18next';
@@ -20,7 +20,7 @@ const MOCKS = [
{
request: {
query: UPDATE_USER_PASSWORD_MUTATION,
- variable: {
+ variables: {
previousPassword: 'anshgoyal',
newPassword: 'anshgoyalansh',
confirmNewPassword: 'anshgoyalansh',
@@ -49,15 +49,10 @@ async function wait(ms = 5): Promise {
}
describe('Testing User Password Update', () => {
- const props = {
- key: '123',
- id: '1',
- };
-
const formData = {
previousPassword: 'Palisadoes',
newPassword: 'ThePalisadoesFoundation',
- wrongPassword: 'This is wrong passoword',
+ wrongPassword: 'This is wrong password',
confirmNewPassword: 'ThePalisadoesFoundation',
};
@@ -67,7 +62,7 @@ describe('Testing User Password Update', () => {
render(
-
+
,
);
@@ -102,7 +97,7 @@ describe('Testing User Password Update', () => {
render(
-
+
,
);
@@ -117,7 +112,7 @@ describe('Testing User Password Update', () => {
render(
-
+
,
);
diff --git a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx
index e1f8c64f0b..1ea75811c1 100644
--- a/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx
+++ b/src/components/UserPasswordUpdate/UserPasswordUpdate.tsx
@@ -45,12 +45,12 @@ const UserUpdate: React.FC<
!formState.newPassword ||
!formState.confirmNewPassword
) {
- toast.error(t('passCantBeEmpty'));
+ toast.error(t('passCantBeEmpty') as string);
return;
}
if (formState.newPassword !== formState.confirmNewPassword) {
- toast.error(t('passNoMatch'));
+ toast.error(t('passNoMatch') as string);
return;
}
@@ -64,7 +64,9 @@ const UserUpdate: React.FC<
});
/* istanbul ignore next */
if (data) {
- toast.success(tCommon('updatedSuccessfully', { item: 'Password' }));
+ toast.success(
+ tCommon('updatedSuccessfully', { item: 'Password' }) as string,
+ );
setTimeout(() => {
window.location.reload();
}, 2000);
diff --git a/src/components/UserPortal/CommentCard/CommentCard.test.tsx b/src/components/UserPortal/CommentCard/CommentCard.test.tsx
index 35b81167fc..f02e5a606a 100644
--- a/src/components/UserPortal/CommentCard/CommentCard.test.tsx
+++ b/src/components/UserPortal/CommentCard/CommentCard.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { act, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
diff --git a/src/components/UserPortal/CommentCard/CommentCard.tsx b/src/components/UserPortal/CommentCard/CommentCard.tsx
index 026c2f1af3..9e8c46d241 100644
--- a/src/components/UserPortal/CommentCard/CommentCard.tsx
+++ b/src/components/UserPortal/CommentCard/CommentCard.tsx
@@ -92,7 +92,7 @@ function commentCard(props: InterfaceCommentCardProps): JSX.Element {
}
} catch (error: unknown) {
/* istanbul ignore next */
- toast.error(error);
+ toast.error(error as string);
}
} else {
try {
@@ -109,7 +109,7 @@ function commentCard(props: InterfaceCommentCardProps): JSX.Element {
}
} catch (error: unknown) {
/* istanbul ignore next */
- toast.error(error);
+ toast.error(error as string);
}
}
};
diff --git a/src/components/UserPortal/ContactCard/ContactCard.test.tsx b/src/components/UserPortal/ContactCard/ContactCard.test.tsx
index 7f55196bb0..03136387a7 100644
--- a/src/components/UserPortal/ContactCard/ContactCard.test.tsx
+++ b/src/components/UserPortal/ContactCard/ContactCard.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/DonationCard/DonationCard.test.tsx b/src/components/UserPortal/DonationCard/DonationCard.test.tsx
index 4e49ed8b26..cddf62dd6c 100644
--- a/src/components/UserPortal/DonationCard/DonationCard.test.tsx
+++ b/src/components/UserPortal/DonationCard/DonationCard.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render } from '@testing-library/react';
+import React, { act } from 'react';
+import { render } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/EventCard/EventCard.tsx b/src/components/UserPortal/EventCard/EventCard.tsx
index 3b9d328154..e93138ce42 100644
--- a/src/components/UserPortal/EventCard/EventCard.tsx
+++ b/src/components/UserPortal/EventCard/EventCard.tsx
@@ -103,7 +103,7 @@ function eventCard(props: InterfaceEventCardProps): JSX.Element {
}
} catch (error: unknown) {
/* istanbul ignore next */
- toast.error(error);
+ toast.error(error as string);
}
}
};
diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx
index dba4286290..5546166b9a 100644
--- a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx
+++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, fireEvent, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { fireEvent, render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
index b88e17ae95..e1c2c23beb 100644
--- a/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
+++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.tsx
@@ -110,23 +110,23 @@ function organizationCard(props: InterfaceOrganizationCardProps): JSX.Element {
organizationId: props.id,
},
});
- toast.success(t('MembershipRequestSent'));
+ toast.success(t('MembershipRequestSent') as string);
} else {
await joinPublicOrganization({
variables: {
organizationId: props.id,
},
});
- toast.success(t('orgJoined'));
+ toast.success(t('orgJoined') as string);
}
refetch();
} catch (error: unknown) {
/* istanbul ignore next */
if (error instanceof Error) {
if (error.message === 'User is already a member') {
- toast.error(t('AlreadyJoined'));
+ toast.error(t('AlreadyJoined') as string);
} else {
- toast.error(t('errorOccured'));
+ toast.error(t('errorOccured') as string);
}
}
}
diff --git a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx
index 027234b641..038ff626df 100644
--- a/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx
+++ b/src/components/UserPortal/OrganizationNavbar/OrganizationNavbar.test.tsx
@@ -1,7 +1,7 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
import 'jest-localstorage-mock';
-import { act, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter, Router } from 'react-router-dom';
diff --git a/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx b/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx
index c5fbcf335e..c08240462a 100644
--- a/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx
+++ b/src/components/UserPortal/OrganizationSidebar/OrganizationSidebar.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx b/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx
index 5cadfa923b..fd5d6c7f93 100644
--- a/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx
+++ b/src/components/UserPortal/PeopleCard/PeopleCard.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render } from '@testing-library/react';
+import React, { act } from 'react';
+import { render } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/PostCard/PostCard.test.tsx b/src/components/UserPortal/PostCard/PostCard.test.tsx
index 64f6670223..f7d9217308 100644
--- a/src/components/UserPortal/PostCard/PostCard.test.tsx
+++ b/src/components/UserPortal/PostCard/PostCard.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { act, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
diff --git a/src/components/UserPortal/PostCard/PostCard.tsx b/src/components/UserPortal/PostCard/PostCard.tsx
index 3eed167f65..f8fcdaebca 100644
--- a/src/components/UserPortal/PostCard/PostCard.tsx
+++ b/src/components/UserPortal/PostCard/PostCard.tsx
@@ -128,7 +128,7 @@ export default function postCard(props: InterfacePostCard): JSX.Element {
}
} catch (error: unknown) {
/* istanbul ignore next */
- toast.error(error);
+ toast.error(error as string);
}
} else {
try {
@@ -144,7 +144,7 @@ export default function postCard(props: InterfacePostCard): JSX.Element {
}
} catch (error: unknown) {
/* istanbul ignore next */
- toast.error(error);
+ toast.error(error as string);
}
}
};
@@ -245,7 +245,7 @@ export default function postCard(props: InterfacePostCard): JSX.Element {
props.fetchPosts(); // Refresh the posts
toggleEditPost();
- toast.success(tCommon('updatedSuccessfully', { item: 'Post' }));
+ toast.success(tCommon('updatedSuccessfully', { item: 'Post' }) as string);
} catch (error: unknown) {
/* istanbul ignore next */
errorHandler(t, error);
diff --git a/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx b/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx
index b5d753551c..6ec8ec5de7 100644
--- a/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx
+++ b/src/components/UserPortal/PromotedPost/PromotedPost.test.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { act, render, waitFor } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, waitFor } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/Register/Register.test.tsx b/src/components/UserPortal/Register/Register.test.tsx
index cdcfb9ebc0..f9929a0588 100644
--- a/src/components/UserPortal/Register/Register.test.tsx
+++ b/src/components/UserPortal/Register/Register.test.tsx
@@ -1,6 +1,6 @@
import type { SetStateAction } from 'react';
-import React from 'react';
-import { act, render, screen } from '@testing-library/react';
+import React, { act } from 'react';
+import { render, screen } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import userEvent from '@testing-library/user-event';
import { I18nextProvider } from 'react-i18next';
diff --git a/src/components/UserPortal/Register/Register.tsx b/src/components/UserPortal/Register/Register.tsx
index 952acf7987..11a810c955 100644
--- a/src/components/UserPortal/Register/Register.tsx
+++ b/src/components/UserPortal/Register/Register.tsx
@@ -57,11 +57,11 @@ export default function register(props: InterfaceRegisterProps): JSX.Element {
registerVariables.lastName
)
) {
- toast.error(t('invalidDetailsMessage')); // Error if fields are missing
+ toast.error(t('invalidDetailsMessage') as string); // Error if fields are missing
} else if (
registerVariables.password !== registerVariables.confirmPassword
) {
- toast.error(t('passwordNotMatch')); // Error if passwords do not match
+ toast.error(t('passwordNotMatch') as string); // Error if passwords do not match
} else {
try {
await registerMutation({
@@ -73,7 +73,7 @@ export default function register(props: InterfaceRegisterProps): JSX.Element {
},
});
- toast.success(t('afterRegister')); // Success message
+ toast.success(t('afterRegister') as string); // Success message
// Reset form fields
/* istanbul ignore next */
diff --git a/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx b/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx
index 5a2e815af4..5c436705cd 100644
--- a/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx
+++ b/src/components/UserPortal/StartPostModal/StartPostModal.test.tsx
@@ -1,7 +1,7 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
import type { RenderResult } from '@testing-library/react';
-import { act, fireEvent, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import userEvent from '@testing-library/user-event';
import { CREATE_POST_MUTATION } from 'GraphQl/Mutations/mutations';
diff --git a/src/components/UserPortal/StartPostModal/StartPostModal.tsx b/src/components/UserPortal/StartPostModal/StartPostModal.tsx
index 060963865a..d48b8425fa 100644
--- a/src/components/UserPortal/StartPostModal/StartPostModal.tsx
+++ b/src/components/UserPortal/StartPostModal/StartPostModal.tsx
@@ -93,7 +93,7 @@ const startPostModal = ({
/* istanbul ignore next */
if (data) {
toast.dismiss();
- toast.success(t('postNowVisibleInFeed'));
+ toast.success(t('postNowVisibleInFeed') as string);
fetchPosts();
handleHide();
}
diff --git a/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx b/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx
index 59e3585aa0..8c3447f25a 100644
--- a/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx
+++ b/src/components/UserPortal/UserNavbar/UserNavbar.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { act, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
diff --git a/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx b/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx
index 2984604951..7218bc745c 100644
--- a/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx
+++ b/src/components/UserPortal/UserSidebar/UserSidebar.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import type { RenderResult } from '@testing-library/react';
-import { act, fireEvent, render, screen } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { I18nextProvider } from 'react-i18next';
@@ -19,14 +19,17 @@ import useLocalStorage from 'utils/useLocalstorage';
const { setItem } = useLocalStorage();
const resizeWindow = (width: number): void => {
- window.innerWidth = width;
- fireEvent(window, new Event('resize'));
+ act(() => {
+ window.innerWidth = width;
+ fireEvent(window, new Event('resize'));
+ });
};
const props = {
hideDrawer: true,
setHideDrawer: jest.fn(),
};
+
const MOCKS = [
{
request: {
@@ -366,38 +369,48 @@ describe('Testing UserSidebar Component [User Portal]', () => {
});
test('Component should be rendered properly', async () => {
- renderUserSidebar('properId', link);
- await wait();
+ await act(async () => {
+ renderUserSidebar('properId', link);
+ await wait();
+ });
});
test('Component should be rendered properly when userImage is present', async () => {
- renderUserSidebar('imagePresent', link);
- await wait();
+ await act(async () => {
+ renderUserSidebar('imagePresent', link);
+ await wait();
+ });
});
test('Component should be rendered properly when organizationImage is present', async () => {
- renderUserSidebar('imagePresent', link);
- await wait();
+ await act(async () => {
+ renderUserSidebar('imagePresent', link);
+ await wait();
+ });
});
test('Component should be rendered properly when joinedOrganizations list is empty', async () => {
- renderUserSidebar('orgEmpty', link);
- await wait();
+ await act(async () => {
+ renderUserSidebar('orgEmpty', link);
+ await wait();
+ });
});
- test('Testing Drawer when the screen size is less than or equal to 820px', () => {
- resizeWindow(800);
- render(
-
-
-
-
-
-
-
-
- ,
- );
+ test('Testing Drawer when the screen size is less than or equal to 820px', async () => {
+ await act(async () => {
+ resizeWindow(800);
+ render(
+
+
+
+
+
+
+
+
+ ,
+ );
+ });
expect(screen.getByText('My Organizations')).toBeInTheDocument();
expect(screen.getByText('Settings')).toBeInTheDocument();
expect(screen.getByText('Talawa User Portal')).toBeInTheDocument();
@@ -405,13 +418,21 @@ describe('Testing UserSidebar Component [User Portal]', () => {
const orgsBtn = screen.getAllByTestId(/orgsBtn/i);
- orgsBtn[0].click();
- expect(
- orgsBtn[0].className.includes('text-white btn btn-success'),
- ).toBeTruthy();
- settingsBtn.click();
- expect(
- settingsBtn.className.includes('text-white btn btn-success'),
- ).toBeTruthy();
+ act(() => {
+ orgsBtn[0].click();
+ });
+ await waitFor(() =>
+ expect(
+ orgsBtn[0].className.includes('text-white btn btn-success'),
+ ).toBeTruthy(),
+ );
+ act(() => {
+ settingsBtn.click();
+ });
+ await waitFor(() =>
+ expect(
+ settingsBtn.className.includes('text-white btn btn-success'),
+ ).toBeTruthy(),
+ );
});
});
diff --git a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx
index d9d70478b3..c187dabb55 100644
--- a/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx
+++ b/src/components/UserPortal/UserSidebarOrg/UserSidebarOrg.test.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { act } from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import 'jest-localstorage-mock';
@@ -12,7 +12,6 @@ import { Provider } from 'react-redux';
import { MockedProvider } from '@apollo/react-testing';
import { store } from 'state/store';
import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
-import { act } from 'react-dom/test-utils';
import { StaticMockLink } from 'utils/StaticMockLink';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import useLocalStorage from 'utils/useLocalstorage';
diff --git a/src/components/UsersTableItem/UserTableItem.test.tsx b/src/components/UsersTableItem/UserTableItem.test.tsx
index bfa0a31c86..e87b41f7f2 100644
--- a/src/components/UsersTableItem/UserTableItem.test.tsx
+++ b/src/components/UsersTableItem/UserTableItem.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { act, fireEvent, render, screen } from '@testing-library/react';
+import { fireEvent, render, screen } from '@testing-library/react';
import { I18nextProvider } from 'react-i18next';
import { toast } from 'react-toastify';
import { StaticMockLink } from 'utils/StaticMockLink';
diff --git a/src/components/UsersTableItem/UsersTableItem.tsx b/src/components/UsersTableItem/UsersTableItem.tsx
index 9d6ec65187..9e94b8a9f5 100644
--- a/src/components/UsersTableItem/UsersTableItem.tsx
+++ b/src/components/UsersTableItem/UsersTableItem.tsx
@@ -56,7 +56,9 @@ const UsersTableItem = (props: Props): JSX.Element => {
},
});
if (data) {
- toast.success(tCommon('removedSuccessfully', { item: 'User' }));
+ toast.success(
+ tCommon('removedSuccessfully', { item: 'User' }) as string,
+ );
resetAndRefetch();
}
} catch (error: unknown) {
@@ -77,7 +79,7 @@ const UsersTableItem = (props: Props): JSX.Element => {
},
});
if (data) {
- toast.success(t('roleUpdated'));
+ toast.success(t('roleUpdated') as string);
resetAndRefetch();
}
} catch (error: unknown) {
diff --git a/src/components/Venues/VenueModal.test.tsx b/src/components/Venues/VenueModal.test.tsx
index 652816adaf..b299c8ff20 100644
--- a/src/components/Venues/VenueModal.test.tsx
+++ b/src/components/Venues/VenueModal.test.tsx
@@ -1,7 +1,7 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
import type { RenderResult } from '@testing-library/react';
-import { act, render, screen, fireEvent } from '@testing-library/react';
+import { render, screen, fireEvent } from '@testing-library/react';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import 'jest-location-mock';
diff --git a/src/components/Venues/VenueModal.tsx b/src/components/Venues/VenueModal.tsx
index fd672d4ea2..476964b910 100644
--- a/src/components/Venues/VenueModal.tsx
+++ b/src/components/Venues/VenueModal.tsx
@@ -77,13 +77,13 @@ const VenueModal = ({
*/
const handleSubmit = useCallback(async () => {
if (formState.name.trim().length === 0) {
- toast.error(t('venueTitleError'));
+ toast.error(t('venueTitleError') as string);
return;
}
const capacityNum = parseInt(formState.capacity);
if (isNaN(capacityNum) || capacityNum <= 0) {
- toast.error(t('venueCapacityError'));
+ toast.error(t('venueCapacityError') as string);
return;
}
@@ -100,7 +100,9 @@ const VenueModal = ({
});
/* istanbul ignore next */
if (data) {
- toast.success(edit ? t('venueUpdated') : t('venueAdded'));
+ toast.success(
+ edit ? (t('venueUpdated') as string) : (t('venueAdded') as string),
+ );
refetchVenues();
onHide();
setFormState({
diff --git a/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx b/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx
index ae792966fe..e1abb52a1e 100644
--- a/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx
+++ b/src/components/plugins/DummyPlugin/DummyPlugin.test.jsx
@@ -1,15 +1,16 @@
+import React from 'react';
import { MockedProvider } from '@apollo/react-testing';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import { I18nextProvider } from 'react-i18next';
-import React from 'react';
-
import { store } from 'state/store';
import DummyPlugin from './DummyPlugin';
import i18nForTest from 'utils/i18nForTest';
import { StaticMockLink } from 'utils/StaticMockLink';
+
const link = new StaticMockLink([], true);
+
describe('Testing dummy plugin', () => {
test('should render props and text elements test for the page component', () => {
const { getByText } = render(
@@ -21,7 +22,7 @@ describe('Testing dummy plugin', () => {
-
+ ,
);
expect(getByText(/Welcome to the Dummy Plugin!/i)).toBeInTheDocument();
diff --git a/src/components/plugins/DummyPlugin/DummyPlugin.tsx b/src/components/plugins/DummyPlugin/DummyPlugin.tsx
index d3c8ed8d41..5b837ea076 100644
--- a/src/components/plugins/DummyPlugin/DummyPlugin.tsx
+++ b/src/components/plugins/DummyPlugin/DummyPlugin.tsx
@@ -9,7 +9,7 @@ import AddOn from 'components/AddOn/AddOn';
*
* @returns JSX.Element - Renders the `AddOn` component containing a welcome message.
*/
-function dummyPlugin(): JSX.Element {
+function DummyPlugin(): JSX.Element {
return (
Welcome to the Dummy Plugin!
@@ -17,8 +17,4 @@ function dummyPlugin(): JSX.Element {
);
}
-dummyPlugin.defaultProps = {};
-
-dummyPlugin.propTypes = {};
-
-export default dummyPlugin;
+export default DummyPlugin;
diff --git a/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx b/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx
index bcec97367c..c2cfe03a1e 100644
--- a/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx
+++ b/src/components/plugins/DummyPlugin2/DummyPlugin2.test.jsx
@@ -5,14 +5,14 @@ import { BrowserRouter } from 'react-router-dom';
import { store } from 'state/store';
import DummyPlugin2 from './DummyPlugin2';
-describe('Testing dummy plugin 2', () => {
- test('should render props and text elements test for the page component', () => {
+describe('Testing DummyPlugin2', () => {
+ test('should render DummyPlugin2 component', () => {
render(
-
+ ,
);
});
});
diff --git a/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx b/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx
index 9d7e5e4498..dca6d63ee3 100644
--- a/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx
+++ b/src/components/plugins/DummyPlugin2/DummyPlugin2.tsx
@@ -7,12 +7,8 @@ import React from 'react';
* This component currently does not have any additional functionality
* or properties.
*/
-function dummyPlugin2(): JSX.Element {
+function DummyPlugin2(): JSX.Element {
return ;
}
-dummyPlugin2.defaultProps = {};
-
-dummyPlugin2.propTypes = {};
-
-export default dummyPlugin2;
+export default DummyPlugin2;
diff --git a/src/index.tsx b/src/index.tsx
index 44cb0578b6..7a1bbeba59 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,5 +1,5 @@
import React, { Suspense } from 'react';
-import ReactDOM from 'react-dom';
+import { createRoot } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import type { NormalizedCacheObject } from '@apollo/client';
import {
@@ -131,7 +131,10 @@ const client: ApolloClient = new ApolloClient({
});
const fallbackLoader = ;
-ReactDOM.render(
+const container = document.getElementById('root');
+const root = createRoot(container!); // Note the use of '!' is to assert the container is not null
+
+root.render(
@@ -146,5 +149,4 @@ ReactDOM.render(
,
- document.getElementById('root'),
);
diff --git a/src/screens/BlockUser/BlockUser.test.tsx b/src/screens/BlockUser/BlockUser.test.tsx
index bb490fbe3f..c851470d9b 100644
--- a/src/screens/BlockUser/BlockUser.test.tsx
+++ b/src/screens/BlockUser/BlockUser.test.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
+import React, { act } from 'react';
import { MockedProvider } from '@apollo/react-testing';
-import { act, render, screen } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import {
BLOCK_USER_MUTATION,
diff --git a/src/screens/BlockUser/BlockUser.tsx b/src/screens/BlockUser/BlockUser.tsx
index f32ffe6091..1f36257bb1 100644
--- a/src/screens/BlockUser/BlockUser.tsx
+++ b/src/screens/BlockUser/BlockUser.tsx
@@ -1,5 +1,5 @@
import { useMutation, useQuery } from '@apollo/client';
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useState, useCallback } from 'react';
import { Dropdown, Form, Table } from 'react-bootstrap';
import Button from 'react-bootstrap/Button';
import { toast } from 'react-toastify';
@@ -83,90 +83,99 @@ const Requests = (): JSX.Element => {
return;
}
- if (showBlockedMembers == false) {
- setMembersData(memberData?.organizationsMemberConnection.edges);
+ if (!showBlockedMembers) {
+ setMembersData(memberData?.organizationsMemberConnection.edges || []);
} else {
const blockUsers = memberData?.organizationsMemberConnection.edges.filter(
(user: InterfaceMember) =>
user.organizationsBlockedBy.some((org) => org._id === currentUrl),
);
- setMembersData(blockUsers);
+ setMembersData(blockUsers || []);
}
- }, [memberData, showBlockedMembers]);
+ }, [memberData, showBlockedMembers, currentUrl]);
// Handler for blocking a user
- const handleBlockUser = async (userId: string): Promise => {
- try {
- const { data } = await blockUser({
- variables: {
- userId,
- orgId: currentUrl,
- },
- });
- /* istanbul ignore next */
- if (data) {
- toast.success(t('blockedSuccessfully'));
- memberRefetch();
+ const handleBlockUser = useCallback(
+ async (userId: string): Promise => {
+ try {
+ const { data } = await blockUser({
+ variables: {
+ userId,
+ orgId: currentUrl,
+ },
+ });
+ /* istanbul ignore next */
+ if (data) {
+ toast.success(t('blockedSuccessfully') as string);
+ memberRefetch();
+ }
+ } catch (error: unknown) {
+ /* istanbul ignore next */
+ errorHandler(t, error);
}
- } catch (error: unknown) {
- /* istanbul ignore next */
- errorHandler(t, error);
- }
- };
+ },
+ [blockUser, currentUrl, memberRefetch, t],
+ );
// Handler for unblocking a user
- const handleUnBlockUser = async (userId: string): Promise => {
- try {
- const { data } = await unBlockUser({
- variables: {
- userId,
- orgId: currentUrl,
- },
- });
- /* istanbul ignore next */
- if (data) {
- toast.success(t('Un-BlockedSuccessfully'));
- memberRefetch();
+ const handleUnBlockUser = useCallback(
+ async (userId: string): Promise => {
+ try {
+ const { data } = await unBlockUser({
+ variables: {
+ userId,
+ orgId: currentUrl,
+ },
+ });
+ /* istanbul ignore next */
+ if (data) {
+ toast.success(t('Un-BlockedSuccessfully') as string);
+ memberRefetch();
+ }
+ } catch (error: unknown) {
+ /* istanbul ignore next */
+ errorHandler(t, error);
}
- } catch (error: unknown) {
- /* istanbul ignore next */
- errorHandler(t, error);
- }
- };
+ },
+ [unBlockUser, currentUrl, memberRefetch, t],
+ );
// Display error if member query fails
- /* istanbul ignore next */
- if (memberError) {
- toast.error(memberError.message);
- }
+ useEffect(() => {
+ if (memberError) {
+ toast.error(memberError.message);
+ }
+ }, [memberError]);
// Search handler
- const handleSearch = (value: string): void => {
- setSearchByName(value);
- memberRefetch({
- orgId: currentUrl,
- firstName_contains: searchByFirstName ? value : '',
- lastName_contains: searchByFirstName ? '' : value,
- });
- };
+ const handleSearch = useCallback(
+ (value: string): void => {
+ setSearchByName(value);
+ memberRefetch({
+ orgId: currentUrl,
+ firstName_contains: searchByFirstName ? value : '',
+ lastName_contains: searchByFirstName ? '' : value,
+ });
+ },
+ [searchByFirstName, memberRefetch, currentUrl],
+ );
// Search by Enter key
- const handleSearchByEnter = (
- e: React.KeyboardEvent,
- ): void => {
- if (e.key === 'Enter') {
- const { value } = e.currentTarget;
- handleSearch(value);
- }
- };
+ const handleSearchByEnter = useCallback(
+ (e: React.KeyboardEvent): void => {
+ if (e.key === 'Enter') {
+ const { value } = e.currentTarget;
+ handleSearch(value);
+ }
+ },
+ [handleSearch],
+ );
// Search button click handler
- const handleSearchByBtnClick = (): void => {
- const inputValue =
- (document.getElementById('searchBlockedUsers') as HTMLInputElement)
- ?.value || '';
+ const handleSearchByBtnClick = useCallback((): void => {
+ const inputValue = searchByName;
handleSearch(inputValue);
- };
+ }, [handleSearch, searchByName]);
// Header titles for the table
const headerTitles: string[] = [
@@ -195,6 +204,8 @@ const Requests = (): JSX.Element => {
data-testid="searchByName"
autoComplete="off"
required
+ value={searchByName}
+ onChange={(e) => setSearchByName(e.target.value)}
onKeyUp={handleSearchByEnter}
/>