-
- Teams
-
-
+
+
+
+
diff --git a/tests/other-tests/AdminDashboard.test.tsx b/tests/other-tests/AdminDashboard.test.tsx
index 98110d90..ec0f3ee9 100644
--- a/tests/other-tests/AdminDashboard.test.tsx
+++ b/tests/other-tests/AdminDashboard.test.tsx
@@ -9,14 +9,26 @@ import {
waitFor,
waitForElementToBeRemoved,
} from '@testing-library/react';
-import '@testing-library/jest-dom'
+import '@testing-library/jest-dom';
import { act } from 'react-dom/test-utils';
import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client';
import AdminDashboard from '../../src/pages/AdminDashboard';
+beforeAll(() => {
+ global.ResizeObserver = class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ };
+});
+
const client = new ApolloClient({ cache: new InMemoryCache() });
describe('
', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
test('should render account component', async () => {
act(() => {
render(
@@ -36,7 +48,8 @@ describe('
', () => {
expect(inviteBtn).toBeInTheDocument();
expect(removeInviteModel).toBeInTheDocument();
- act(() => {
+ // Simulate user interactions
+ await act(async () => {
fireEvent.change(inviteInput, {
target: { value: 'admin@devpulse.co' },
});
diff --git a/tests/other-tests/DashboardCard.test.tsx b/tests/other-tests/DashboardCard.test.tsx
new file mode 100644
index 00000000..a4c7d69e
--- /dev/null
+++ b/tests/other-tests/DashboardCard.test.tsx
@@ -0,0 +1,91 @@
+import { render, screen, waitFor } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import DashboardCards from '../../src/components/DashboardCards';
+import ThemeProvider, { ThemeContext } from '../../src/hook/ThemeProvider';
+import { GET_TEAMS_CARDS } from '../../src/components/CoordinatorCard';
+import GET_TICKETS from '../../src/queries/tickets.queries';
+import { GET_EVENTS } from '../../src/queries/event.queries';
+import { GET_ALL_INVITATIONS } from '../../src/queries/invitation.queries';
+import React from 'react';
+import { MockedProvider } from '@apollo/client/testing';
+
+global.ResizeObserver = class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+};
+
+const mocks = [
+ {
+ request: {
+ query: GET_TICKETS,
+ },
+ result: {
+ data: {
+ getAllTickets: [
+ { id: '1', status: 'active' },
+ { id: '2', status: 'closed' },
+ ],
+ },
+ },
+ },
+ {
+ request: {
+ query: GET_TEAMS_CARDS,
+ variables: {
+ orgToken: localStorage.getItem('orgToken'),
+ },
+ },
+ result: {
+ data: {
+ getAllTeams: [
+ { id: 'team1', name: 'Team One' },
+ { id: 'team2', name: 'Team Two' },
+ ],
+ },
+ },
+ },
+];
+
+const mocksEmptyState = [
+ {
+ request: {
+ query: GET_TICKETS,
+ },
+ result: {
+ data: {
+ getAllTickets: [],
+ },
+ },
+ },
+ {
+ request: {
+ query: GET_TEAMS_CARDS,
+ variables: {
+ orgToken: localStorage.getItem('orgToken'),
+ },
+ },
+ result: {
+ data: {
+ getAllTeams: [],
+ },
+ },
+ },
+];
+
+test('renders DashboardCards and shows loading skeletons', async () => {
+ render(
+
+
+
+ );
+
+ expect(screen.getByText(/tickets overview/i)).toBeInTheDocument();
+ expect(screen.getByText(/invitations overview/i)).toBeInTheDocument();
+ expect(screen.getByText(/upcoming events/i)).toBeInTheDocument();
+
+ await waitFor(() => {
+ expect(screen.getByText(/teams/i)).toBeInTheDocument();
+ expect(screen.getByText(/2/i)).toBeInTheDocument();
+ });
+});
\ No newline at end of file