diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index e1cfbfd8ea..091a8637ea 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,4 +1,3 @@ - + + +**Snapshots/Videos:** + + + **If relevant, did you update the documentation?** diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 18f273adc1..ea26616b00 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -217,7 +217,6 @@ jobs: npx tsc --noEmit "$file" fi done - - name: Present and Upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}} uses: codecov/codecov-action@v4 with: @@ -247,7 +246,6 @@ jobs: - name: resolve dependency run: npm install -g @graphql-inspector/cli - - name: Clone API Repository run: | # Retrieve the complete branch name directly from the GitHub context diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603fea..0000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549ea8..0000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 120e01d8b4..0000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/talawa-admin.iml b/.idea/talawa-admin.iml deleted file mode 100644 index 24643cc374..0000000000 --- a/.idea/talawa-admin.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfbb..0000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c21e0f1809..f409f3d909 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,7 +79,7 @@ "@babel/preset-typescript": "^7.26.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", - "@testing-library/user-event": "^12.1.10", + "@testing-library/user-event": "^13.5.0", "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", @@ -5315,10 +5315,11 @@ } }, "node_modules/@testing-library/user-event": { - "version": "12.8.3", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.8.3.tgz", - "integrity": "sha512-IR0iWbFkgd56Bu5ZI/ej8yQwrkCv8Qydx6RzwbKz9faXazR/+5tvYKsZQgyXJiwgpcva127YO6JcWy7YlCfofQ==", + "version": "13.5.0", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.5.0.tgz", + "integrity": "sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg==", "dev": true, + "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5" }, diff --git a/package.json b/package.json index 6ee5e22e4a..5de38f7181 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "@babel/preset-typescript": "^7.26.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", - "@testing-library/user-event": "^12.1.10", + "@testing-library/user-event": "^13.5.0", "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", diff --git a/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.test.tsx b/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.test.tsx index d3698bf346..327b4a9bce 100644 --- a/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.test.tsx +++ b/src/components/OrgSettings/ActionItemCategories/OrgActionItemCategories.test.tsx @@ -61,10 +61,10 @@ const renderActionItemCategories = ( describe('Testing Organisation Action Item Categories', () => { it('should render the Action Item Categories Screen', async () => { renderActionItemCategories(link1, 'orgId'); - await waitFor(() => { + await waitFor(async () => { expect(screen.getByTestId('searchByName')).toBeInTheDocument(); - expect(screen.getByText('Category 1')).toBeInTheDocument(); - expect(screen.getByText('Category 2')).toBeInTheDocument(); + expect(await screen.findByText('Category 1')).toBeInTheDocument(); + expect(await screen.findByText('Category 2')).toBeInTheDocument(); }); }); diff --git a/src/components/OrganizationScreen/OrganizationScreen.test.tsx b/src/components/OrganizationScreen/OrganizationScreen.test.tsx index cd039cc3ca..69237c6fd8 100644 --- a/src/components/OrganizationScreen/OrganizationScreen.test.tsx +++ b/src/components/OrganizationScreen/OrganizationScreen.test.tsx @@ -81,14 +81,16 @@ describe('Testing OrganizationScreen', () => { fireEvent.click(closeButton); // Check for contract class after closing - expect(screen.getByTestId('mainpageright')).toHaveClass('_expand_ccl5z_8'); + expect(screen.getByTestId('mainpageright')).toHaveClass( + '_pageContainer_ccl5z_1 _expand_ccl5z_15', + ); const openButton = screen.getByTestId('openMenu'); fireEvent.click(openButton); // Check for expand class after opening expect(screen.getByTestId('mainpageright')).toHaveClass( - '_contract_ccl5z_61', + '_pageContainer_ccl5z_1 _contract_ccl5z_121', ); }); diff --git a/src/components/Pagination/Pagination.test.tsx b/src/components/Pagination/Pagination.test.tsx index 40ac2ed19a..6b794c59e3 100644 --- a/src/components/Pagination/Pagination.test.tsx +++ b/src/components/Pagination/Pagination.test.tsx @@ -1,11 +1,10 @@ import React, { act } from 'react'; -import { render, screen } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { Provider } from 'react-redux'; import { BrowserRouter } from 'react-router-dom'; import { createTheme, ThemeProvider } from '@mui/material/styles'; import Pagination from './Pagination'; import { store } from 'state/store'; -import userEvent from '@testing-library/user-event'; describe('Testing Pagination component', () => { const props = { @@ -26,8 +25,8 @@ describe('Testing Pagination component', () => { , ); await act(async () => { - userEvent.click(screen.getByTestId(/nextPage/i)); - userEvent.click(screen.getByTestId(/previousPage/i)); + fireEvent.click(screen.getByTestId(/nextPage/i)); + fireEvent.click(screen.getByTestId(/previousPage/i)); }); }); }); @@ -58,7 +57,7 @@ test('Component should be rendered properly', async () => { ); await act(async () => { - userEvent.click(screen.getByTestId(/nextPage/i)); - userEvent.click(screen.getByTestId(/previousPage/i)); + fireEvent.click(screen.getByTestId(/nextPage/i)); + fireEvent.click(screen.getByTestId(/previousPage/i)); }); }); diff --git a/src/screens/Requests/Requests.test.tsx b/src/screens/Requests/Requests.test.tsx index 4606fdae08..3d5efa812c 100644 --- a/src/screens/Requests/Requests.test.tsx +++ b/src/screens/Requests/Requests.test.tsx @@ -53,18 +53,20 @@ afterEach(() => { describe('Testing Requests screen', () => { test('Component should be rendered properly', async () => { - const loadMoreRequests = jest.fn(); - render( - - - - - - - - - , - ); + jest.fn(); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); expect(screen.getByTestId('testComp')).toBeInTheDocument(); @@ -76,67 +78,75 @@ describe('Testing Requests screen', () => { setItem('id', ''); removeItem('AdminFor'); removeItem('SuperAdmin'); - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); }); test('Component should be rendered properly when user is Admin', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); }); test('Redirecting on error', async () => { setItem('SuperAdmin', true); - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); expect(window.location.href).toEqual('http://localhost/'); }); test('Testing Search requests functionality', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); const searchBtn = screen.getByTestId('searchButton'); @@ -158,62 +168,68 @@ describe('Testing Requests screen', () => { const search5 = 'Xe'; userEvent.type(screen.getByTestId(/searchByName/i), search5); userEvent.clear(screen.getByTestId(/searchByName/i)); - userEvent.type(screen.getByTestId(/searchByName/i), ''); + expect(screen.getByTestId(/searchByName/i)).toHaveValue(''); userEvent.click(searchBtn); await wait(); }); test('Testing search not found', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); const search = 'hello{enter}'; - await act(() => - userEvent.type(screen.getByTestId(/searchByName/i), search), - ); + await act(async () => { + userEvent.type(screen.getByTestId(/searchByName/i), search); + }); }); test('Testing Request data is not present', async () => { - render( - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + , + ); + }); await wait(); expect(screen.getByText(/No Membership Requests Found/i)).toBeTruthy(); }); test('Should render warning alert when there are no organizations', async () => { - render( - - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + + , + ); + }); await wait(200); expect(screen.queryByText('Organizations Not Found')).toBeInTheDocument(); @@ -223,17 +239,19 @@ describe('Testing Requests screen', () => { }); test('Should not render warning alert when there are organizations present', async () => { - const { container } = render( - - - - - - - - - - , + const { container } = await act(() => + render( + + + + + + + + + + , + ), ); await wait(); @@ -244,49 +262,55 @@ describe('Testing Requests screen', () => { }); test('Should render properly when there are no organizations present in requestsData', async () => { - render( - - - - - - - - - - , - ); + await act(async () => { + render( + + + + + + + + + + , + ); + }); await wait(); }); test('check for rerendering', async () => { - const { rerender } = render( - - - - - - - - - - , + const { rerender } = await act(() => + render( + + + + + + + + + + , + ), ); await wait(); - rerender( - - - - - - - - - - , - ); + await act(async () => { + rerender( + + + + + + + + + + , + ); + }); await wait(); }); }); diff --git a/src/screens/UserPortal/People/People.test.tsx b/src/screens/UserPortal/People/People.test.tsx index c978a0a5a3..12f6769abf 100644 --- a/src/screens/UserPortal/People/People.test.tsx +++ b/src/screens/UserPortal/People/People.test.tsx @@ -188,7 +188,9 @@ describe('Testing People Screen [User Portal]', () => { await wait(); const searchBtn = screen.getByTestId('searchBtn'); - userEvent.type(screen.getByTestId('searchInput'), ''); + const searchInput = screen.getByTestId('searchInput'); + // Check that the input is initially empty + expect(searchInput).toHaveValue(''); userEvent.click(searchBtn); await wait(); userEvent.type(screen.getByTestId('searchInput'), 'j'); diff --git a/src/screens/UserPortal/Pledges/Pledge.test.tsx b/src/screens/UserPortal/Pledges/Pledge.test.tsx index 3d5eef94c2..422f602165 100644 --- a/src/screens/UserPortal/Pledges/Pledge.test.tsx +++ b/src/screens/UserPortal/Pledges/Pledge.test.tsx @@ -88,10 +88,10 @@ describe('Testing User Pledge Screen', () => { it('should render the Campaign Pledge screen', async () => { renderMyPledges(link1); - await waitFor(() => { + await waitFor(async () => { expect(screen.getByTestId('searchPledges')).toBeInTheDocument(); - expect(screen.getByText('Harve Lance')).toBeInTheDocument(); - expect(screen.getByText('John Doe')).toBeInTheDocument(); + expect(await screen.findByText('Harve Lance')).toBeInTheDocument(); + expect(await screen.findByText('John Doe')).toBeInTheDocument(); }); }); diff --git a/src/screens/UserPortal/Posts/Posts.test.tsx b/src/screens/UserPortal/Posts/Posts.test.tsx index aa5f03fdcf..e768b4ca15 100644 --- a/src/screens/UserPortal/Posts/Posts.test.tsx +++ b/src/screens/UserPortal/Posts/Posts.test.tsx @@ -1,7 +1,7 @@ import React, { act } from 'react'; import { MockedProvider } from '@apollo/react-testing'; import type { RenderResult } from '@testing-library/react'; -import { render, screen, waitFor, within } from '@testing-library/react'; +import { render, screen, within } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import userEvent from '@testing-library/user-event'; import { @@ -287,7 +287,7 @@ describe('Testing Home Screen: User Portal', () => { }); test('Check if HomeScreen renders properly', async () => { - renderHomeScreen(); + await act(() => renderHomeScreen()); await wait(); const startPostBtn = await screen.findByTestId('postBtn'); @@ -295,7 +295,7 @@ describe('Testing Home Screen: User Portal', () => { }); test('StartPostModal should render on click of StartPost btn', async () => { - renderHomeScreen(); + await act(() => renderHomeScreen()); await wait(); const startPostBtn = await screen.findByTestId('postBtn'); @@ -307,7 +307,7 @@ describe('Testing Home Screen: User Portal', () => { }); test('StartPostModal should close on clicking the close button', async () => { - renderHomeScreen(); + await act(() => renderHomeScreen()); await wait(); userEvent.upload( @@ -344,7 +344,7 @@ describe('Testing Home Screen: User Portal', () => { test('Check whether Posts render in PostCard', async () => { setItem('userId', '640d98d9eb6a743d75341067'); - renderHomeScreen(); + await act(() => renderHomeScreen()); await wait(); const postCardContainers = screen.findAllByTestId('postCardContainer'); diff --git a/src/screens/Users/Users.test.tsx b/src/screens/Users/Users.test.tsx index 65558e6ea7..d43a23bafb 100644 --- a/src/screens/Users/Users.test.tsx +++ b/src/screens/Users/Users.test.tsx @@ -410,7 +410,7 @@ describe('Testing Users screen', () => { const search5 = 'Xe'; userEvent.type(screen.getByTestId(/searchByName/i), search5); userEvent.clear(screen.getByTestId(/searchByName/i)); - userEvent.type(screen.getByTestId(/searchByName/i), ''); + expect(screen.getByTestId(/searchByName/i)).toHaveValue(''); userEvent.click(searchBtn); await wait(); });