Skip to content
Merged

Dev #311

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b6a2b4e
feat: Enhance text color for better readability in KYCContent and Bad…
renulucshmi Jul 15, 2025
80d31c1
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
renulucshmi Jul 15, 2025
455a320
feat: Add admin management features including create, edit, and filte…
renulucshmi Jul 16, 2025
30ef387
feat: Refactor SuspendedUsersContent component to improve structure a…
renulucshmi Jul 16, 2025
40d481a
feat: Refactor SuspendedUsersContent component for improved readabili…
renulucshmi Jul 16, 2025
078fc22
feat: Update AdminSidebar to use NotebookTabs icon for Forum Reports
renulucshmi Jul 16, 2025
fbade21
feat: Refactor reporting system with enhanced filtering and email han…
renulucshmi Jul 16, 2025
e52fa13
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
renulucshmi Jul 16, 2025
d32d239
feat: Add hasInstallScript property to package-lock.json
renulucshmi Jul 16, 2025
aec7399
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
renulucshmi Jul 16, 2025
d4127a9
feat: Add ReportDetailsModal component and enhance report filtering f…
renulucshmi Jul 16, 2025
c96d763
feat: Refactor ReportDetailsModal to use string constants for user-vi…
renulucshmi Jul 17, 2025
ef0cd49
feat: Remove "Engagement and Activity Badges" from badge categories a…
renulucshmi Jul 17, 2025
9057afe
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
renulucshmi Jul 17, 2025
f0f5ac6
feat: Enhance badge name validation to require a minimum length of 3 …
renulucshmi Jul 17, 2025
8924fa4
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
renulucshmi Jul 18, 2025
138c0e0
refactor: remove MediaDeviceTips and MediaDeviceWarning components
AdeepaK2 Jul 18, 2025
d7acd20
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
AdeepaK2 Jul 18, 2025
26af02c
Merge pull request #308 from Code102SoftwareProject/test-Adeepa
AdeepaK2 Jul 18, 2025
f8d71b3
chore: update next and related dependencies to version 15.4.1 and sha…
renulucshmi Jul 18, 2025
e9e43e1
Merge branch 'dev' of https://github.com/Code102SoftwareProject/skill…
renulucshmi Jul 18, 2025
b6765a3
Merge pull request #309 from Code102SoftwareProject/admin-report-renu
renulucshmi Jul 18, 2025
9a24693
Add comprehensive manual test result reports for various features
renulucshmi Jul 18, 2025
18f2238
Remove obsolete test scripts for unsuspension and user population
renulucshmi Jul 18, 2025
401769d
Merge pull request #310 from Code102SoftwareProject/test-renu
renulucshmi Jul 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
851 changes: 300 additions & 551 deletions __tests__/components/MeetingBox.test.tsx

Large diffs are not rendered by default.

96 changes: 91 additions & 5 deletions __tests__/components/SessionBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import React from 'react';
import { render, screen, fireEvent, waitFor, act } from '@testing-library/react';
import '@testing-library/jest-dom';
import SessionBox from '@/components/messageSystem/SessionBox';
import { useSessionActions } from '@/hooks/useSessionActions';

// Mock Next.js router
const mockPush = jest.fn();
Expand Down Expand Up @@ -87,6 +88,11 @@ jest.mock('@/utils/avatarUtils', () => ({
processAvatarUrl: jest.fn((url) => url || '/default-avatar.png'),
}));

// Mock the useSessionActions hook
jest.mock('@/hooks/useSessionActions', () => ({
useSessionActions: jest.fn(),
}));

// Mock data
const mockUser = {
_id: '6873cc50ac4e1d6e1cddf33f',
Expand All @@ -110,8 +116,8 @@ const mockSession = {
_id: 'session-id-1',
user1Id: mockUser,
user2Id: mockOtherUser,
skill1Id: { _id: 'skill1', name: 'React' },
skill2Id: { _id: 'skill2', name: 'Node.js' },
skill1Id: { _id: 'skill1', skillName: 'React' },
skill2Id: { _id: 'skill2', skillName: 'Node.js' },
descriptionOfService1: 'I can teach React basics',
descriptionOfService2: 'I want to learn Node.js',
startDate: '2025-01-15',
Expand Down Expand Up @@ -197,9 +203,33 @@ describe('SessionBox Component', () => {
onSessionUpdate: jest.fn()
};

// Default mock implementation for useSessionActions
const defaultMockSessionActions = {
sessions: [],
counterOffers: {},
loading: false,
processingSession: null,
pendingSessionCount: 0,
activeSessionCount: 0,
fetchSessions: jest.fn(),
handleAcceptReject: jest.fn(),
handleDeleteSession: jest.fn(),
handleCounterOfferResponse: jest.fn(),
handleRequestCompletion: jest.fn(),
handleCompletionResponse: jest.fn(),
handleRatingSubmit: jest.fn(),
setLoading: jest.fn(),
setSessions: jest.fn(),
setCounterOffers: jest.fn(),
setPendingSessionCount: jest.fn(),
setActiveSessionCount: jest.fn()
};

beforeEach(() => {
jest.clearAllMocks();
global.fetch = createMockFetch({});
// Reset to default mock implementation
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue(defaultMockSessionActions);
});

afterEach(() => {
Expand All @@ -210,6 +240,12 @@ describe('SessionBox Component', () => {
it('should show New Session button', async () => {
global.fetch = createMockFetch({ sessions: [] });

// Mock the hook to return empty sessions
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: []
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand All @@ -220,6 +256,12 @@ describe('SessionBox Component', () => {
it('should show empty state when no sessions exist', async () => {
global.fetch = createMockFetch({ sessions: [] });

// Mock the hook to return empty sessions
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: []
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand All @@ -236,11 +278,19 @@ describe('SessionBox Component', () => {
counterOffers: []
});

// Mock the hook to return the session
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: [mockSession],
pendingSessionCount: 1,
activeSessionCount: 1
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
expect(screen.getByText('I can teach React basics')).toBeInTheDocument();
expect(screen.getByText('I want to learn Node.js')).toBeInTheDocument();
expect(screen.getByText('React')).toBeInTheDocument();
expect(screen.getByText('Node.js')).toBeInTheDocument();
expect(screen.getByText('pending')).toBeInTheDocument();
});
});
Expand All @@ -257,6 +307,14 @@ describe('SessionBox Component', () => {
counterOffers: []
});

// Mock the hook to return multiple sessions
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: multiplePendingSessions,
pendingSessionCount: 3,
activeSessionCount: 3
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand All @@ -269,6 +327,12 @@ describe('SessionBox Component', () => {
it('should open create session modal when New Session button is clicked', async () => {
global.fetch = createMockFetch({ sessions: [] });

// Mock the hook to return empty sessions
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: []
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand All @@ -291,6 +355,14 @@ describe('SessionBox Component', () => {
counterOffers: []
});

// Mock the hook to return 3 active sessions
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: multiplePendingSessions,
pendingSessionCount: 3,
activeSessionCount: 3
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand Down Expand Up @@ -322,7 +394,7 @@ describe('SessionBox Component', () => {
render(<SessionBox {...defaultProps} />);

await waitFor(() => {
expect(screen.getByText('Failed to load user information')).toBeInTheDocument();
expect(screen.getByText('Failed to load user')).toBeInTheDocument();
});
});

Expand Down Expand Up @@ -351,6 +423,12 @@ describe('SessionBox Component', () => {
it('should close create session modal when close button is clicked', async () => {
global.fetch = createMockFetch({ sessions: [] });

// Mock the hook to return empty sessions
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: []
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand All @@ -374,6 +452,14 @@ describe('SessionBox Component', () => {
counterOffers: []
});

// Mock the hook to return the session
(useSessionActions as jest.MockedFunction<typeof useSessionActions>).mockReturnValue({
...defaultMockSessionActions,
sessions: [mockSession],
pendingSessionCount: 1,
activeSessionCount: 1
});

render(<SessionBox {...defaultProps} />);

await waitFor(() => {
Expand Down
Loading
Loading