- {sortedPostsList && sortedPostsList.length > 0 ? (
+ {/* {sortedPostsList && sortedPostsList.length > 0 ? (
sortedPostsList.map(
(datas: {
_id: string;
@@ -372,7 +372,7 @@ function orgPost(): JSX.Element {
)
) : (
- )}
+ )} */}
diff --git a/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx b/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx
index 6fd27ce429..6aa346f8fc 100644
--- a/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx
+++ b/src/screens/OrganizationDashboard/OrganizationDashboard.spec.tsx
@@ -1,315 +1,209 @@
import React from 'react';
-import { MockedProvider } from '@apollo/react-testing';
-import { LocalizationProvider } from '@mui/x-date-pickers';
-import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
+import { vi, describe, it, expect, beforeEach } from 'vitest';
import type { RenderResult } from '@testing-library/react';
-import { render, screen, waitFor } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import { I18nextProvider } from 'react-i18next';
-import { Provider } from 'react-redux';
-import { MemoryRouter, Route, Routes, useParams } from 'react-router-dom';
-import { store } from 'state/store';
-import { StaticMockLink } from 'utils/StaticMockLink';
-import i18n from 'utils/i18nForTest';
+import { render, screen, waitFor, fireEvent } from '@testing-library/react';
+import type { MockedResponse } from '@apollo/client/testing';
+import { MockedProvider } from '@apollo/client/testing';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+import { toast } from 'react-toastify';
import OrganizationDashboard from './OrganizationDashboard';
-import type { ApolloLink } from '@apollo/client';
import { MOCKS, EMPTY_MOCKS, ERROR_MOCKS } from './OrganizationDashboardMocks';
-import { toast } from 'react-toastify';
-import { vi } from 'vitest';
-
-/**
- * This file contains unit tests for the OrganizationDashboard component.
- *
- * The tests cover:
- * - Behavior when URL parameters are undefined, including redirection to fallback URLs.
- * - Rendering of key sections, such as dashboard cards, upcoming events, latest posts, membership requests, and volunteer rankings.
- * - Functionality of user interactions with dashboard elements (e.g., navigation via clicks on cards and buttons).
- * - Handling of scenarios with empty data or errors in GraphQL responses.
- * - Integration with mocked GraphQL queries and toast notifications.
- *
- * These tests are implemented using Vitest for test execution and MockedProvider for mocking GraphQL queries.
- */
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (key: string) => key,
+ tCommon: (key: string) => key,
+ tErrors: (key: string) => key,
+ }),
+}));
+
+const mockedNavigate = vi.fn();
+vi.mock('react-router-dom', async () => {
+ const actual = await vi.importActual('react-router-dom');
+ return {
+ ...actual,
+ useNavigate: () => mockedNavigate,
+ };
+});
vi.mock('react-toastify', () => ({
toast: {
- success: vi.fn(),
error: vi.fn(),
+ success: vi.fn(),
},
}));
-const link1 = new StaticMockLink(MOCKS);
-const link2 = new StaticMockLink(ERROR_MOCKS);
-const link3 = new StaticMockLink(EMPTY_MOCKS);
-const t = {
- ...JSON.parse(
- JSON.stringify(i18n.getDataByLanguage('en')?.translation.dashboard ?? {}),
- ),
- ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.common ?? {})),
- ...JSON.parse(JSON.stringify(i18n.getDataByLanguage('en')?.errors ?? {})),
-};
-
-const renderOrganizationDashboard = (link: ApolloLink): RenderResult => {
+interface InterfaceRenderOptions {
+ mocks: MockedResponse[];
+ initialRoute?: string;
+}
+
+function renderWithProviders({
+ mocks,
+ initialRoute = '/orgdash/orgId',
+}: InterfaceRenderOptions): RenderResult {
return render(
-
-
-
-
-
-
- }
- />
- }
- />
-