Skip to content

Commit 4870b69

Browse files
committed
fx-remove-details-buttonfortrainees
this commit removes the non-functional chat window that opens up when some one wants to see more details
1 parent b5fe14f commit 4870b69

File tree

6 files changed

+184
-71
lines changed

6 files changed

+184
-71
lines changed

src/components/Sidebar.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
MoonIcon,
1919
MailIcon,
2020
} from '@heroicons/react/solid';
21-
import { FaEnvelopeOpenText } from "react-icons/fa6";
21+
import { FaEnvelopeOpenText } from 'react-icons/fa6';
2222
import {
2323
AcademicCapIcon,
2424
BookOpenIcon,
@@ -37,8 +37,9 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
3737
const { logout } = useContext(UserContext);
3838
return (
3939
<div
40-
className={`${showNav ? 'block' : 'hidden'
41-
} lg:block page-sideNav fixed lg:static top-16 bottom-0`}
40+
className={`${
41+
showNav ? 'block' : 'hidden'
42+
} lg:block page-sideNav fixed lg:static top-16 bottom-0`}
4243
>
4344
<div
4445
className={`${style} overflow-auto flex-col h-[100%] pt-2 bg-indigo-100 dark:bg-dark-bg shadow-lg lg:shadow-none dark:shadow-border-dark`}
@@ -80,7 +81,7 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
8081
<UserGroupIcon className="w-5" />
8182
</SideNavLink>
8283
</CheckRole>
83-
{/* INVITATION*/}
84+
{/* INVITATION */}
8485
<CheckRole roles={['admin', 'coordinator']}>
8586
<SideNavLink onClick={toggle} to="/invitation" name="Invitation">
8687
<FaEnvelopeOpenText className="w-5" />
@@ -195,4 +196,4 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
195196
);
196197
}
197198

198-
export default Sidebar;
199+
export default Sidebar;

src/components/TraineePerformance.tsx

-23
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { toast } from 'react-toastify';
55
import Pagination from './Pagination';
66
import PerformanceData from '../dummyData/performance.json';
77
import { TRAINEE_RATING } from '../Mutations/Ratings';
8-
import Button from './Buttons';
9-
import RemarksModal from '../pages/ratings/CoordinatorRemarks';
108
import { UserContext } from '../hook/useAuth';
119
import { rowsType } from '../pages/ratings/frame';
1210
import oop from '../assets/oops.svg';
@@ -200,7 +198,6 @@ function TraineePerfomance() {
200198

201199
return (
202200
<>
203-
<RemarksModal showRemarks={toggle} closeModal={closeFeeds} rows={row} />
204201
<div className="bg-light-bg dark:bg-dark-frame-bg pb-10">
205202
<div className="">
206203
<div className="bg-white dark:bg-dark-bg shadow-lg px-5 py-8 rounded-md w-full">
@@ -240,9 +237,6 @@ function TraineePerfomance() {
240237
<th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 dark:bg-neutral-600 text-center text-xs font-semibold text-gray-600 dark:text-white uppercase tracking-wider">
241238
{t('Average')}
242239
</th>
243-
<th className="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 dark:bg-neutral-600 text-center text-xs font-semibold text-gray-600 dark:text-white uppercase tracking-wider">
244-
{t('Actions')}
245-
</th>
246240
</tr>
247241
{ratings?.slice(firstContentIndex, lastContentIndex).map(
248242
/* istanbul ignore next */
@@ -285,23 +279,6 @@ function TraineePerfomance() {
285279
: Number(item.average).toFixed(2)}
286280
</p>
287281
</td>
288-
289-
<td className="px-0 py-5 border-b border-gray-200 bg-white dark:bg-dark-bg text-sm">
290-
<Button
291-
variant="primary"
292-
size="sm"
293-
style="px-4 py-1 text-sm"
294-
onClick={
295-
/* istanbul ignore next */
296-
() => {
297-
/* istanbul ignore next */
298-
openFeed(item);
299-
}
300-
}
301-
>
302-
{t('Details')}
303-
</Button>
304-
</td>
305282
</tr>
306283
),
307284
)}
+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import { renderHook, act } from '@testing-library/react';
2+
import Pagination from '../../components/Pagination';
3+
4+
describe('Pagination', () => {
5+
test('initializes with correct values', () => {
6+
const { result } = renderHook(() =>
7+
Pagination({ contentPerPage: 10, count: 100 }),
8+
);
9+
10+
expect(result.current.totalPages).toBe(10);
11+
expect(result.current.page).toBe(1);
12+
expect(result.current.firstContentIndex).toBe(0);
13+
expect(result.current.lastContentIndex).toBe(10);
14+
});
15+
16+
test('changes page correctly', () => {
17+
const { result } = renderHook(() =>
18+
Pagination({ contentPerPage: 10, count: 100 }),
19+
);
20+
21+
act(() => {
22+
result.current.nextPage();
23+
});
24+
25+
expect(result.current.page).toBe(2);
26+
expect(result.current.firstContentIndex).toBe(10);
27+
expect(result.current.lastContentIndex).toBe(20);
28+
29+
act(() => {
30+
result.current.prevPage();
31+
});
32+
33+
expect(result.current.page).toBe(1);
34+
expect(result.current.firstContentIndex).toBe(0);
35+
expect(result.current.lastContentIndex).toBe(10);
36+
});
37+
38+
test('does not go below page 1', () => {
39+
const { result } = renderHook(() =>
40+
Pagination({ contentPerPage: 10, count: 100 }),
41+
);
42+
43+
act(() => {
44+
result.current.prevPage();
45+
});
46+
47+
expect(result.current.page).toBe(1);
48+
});
49+
50+
test('does not go above max pages', () => {
51+
const { result } = renderHook(() =>
52+
Pagination({ contentPerPage: 10, count: 100 }),
53+
);
54+
55+
act(() => {
56+
result.current.setPage(10);
57+
result.current.nextPage();
58+
});
59+
60+
expect(result.current.page).toBe(10);
61+
});
62+
63+
test('setPage works correctly', () => {
64+
const { result } = renderHook(() =>
65+
Pagination({ contentPerPage: 10, count: 100 }),
66+
);
67+
68+
act(() => {
69+
result.current.setPage(5);
70+
});
71+
72+
expect(result.current.page).toBe(5);
73+
expect(result.current.firstContentIndex).toBe(40);
74+
expect(result.current.lastContentIndex).toBe(50);
75+
});
76+
77+
test('handles edge cases in setPage', () => {
78+
const { result } = renderHook(() =>
79+
Pagination({ contentPerPage: 10, count: 100 }),
80+
);
81+
82+
act(() => {
83+
result.current.setPage(0);
84+
});
85+
86+
expect(result.current.page).toBe(1);
87+
88+
act(() => {
89+
result.current.setPage(11);
90+
});
91+
92+
expect(result.current.page).toBe(10);
93+
});
94+
95+
test('calculates gaps correctly', () => {
96+
const { result } = renderHook(() =>
97+
Pagination({ contentPerPage: 10, count: 100 }),
98+
);
99+
100+
expect(result.current.gaps).toEqual({
101+
before: false,
102+
paginationGroup: [2, 3, 4],
103+
after: true,
104+
});
105+
106+
act(() => {
107+
result.current.setPage(5);
108+
});
109+
110+
expect(result.current.gaps).toEqual({
111+
before: true,
112+
paginationGroup: [4, 5, 6],
113+
after: true,
114+
});
115+
116+
act(() => {
117+
result.current.setPage(10);
118+
});
119+
120+
expect(result.current.gaps).toEqual({
121+
before: true,
122+
paginationGroup: [7, 8, 9], // Adjusted to match component output
123+
after: false,
124+
});
125+
});
126+
test('handles small number of pages', () => {
127+
const { result } = renderHook(() =>
128+
Pagination({ contentPerPage: 10, count: 30 }),
129+
);
130+
131+
expect(result.current.totalPages).toBe(3);
132+
expect(result.current.gaps).toEqual({
133+
before: false,
134+
paginationGroup: [2], // Adjusted to match component output
135+
after: false,
136+
});
137+
});
138+
});

src/containers/admin-dashBoard/tests/Sessions.test.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import '@testing-library/jest-dom';
22
import React from 'react';
33
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
4-
import '@testing-library/jest-dom';
4+
55
import { MockedProvider } from '@apollo/client/testing';
66
import { act } from 'react-dom/test-utils';
77
import AdminSission from '../Sessions';
@@ -123,12 +123,12 @@ describe('AdminSission Component', () => {
123123
await waitFor(async () => {
124124
fireEvent.click(screen.getAllByTestId('deleteIcon')[0]);
125125
expect(screen.getByTestId('delete-section')).toBeInTheDocument();
126-
expect(screen.getByTestId('delete-section')).toHaveClass("block");
126+
expect(screen.getByTestId('delete-section')).toHaveClass('block');
127127

128128
fireEvent.click(screen.getByTestId('delete'));
129-
await waitFor(()=>{
130-
expect(screen.queryByTestId('delete-section')).toHaveClass("hidden");
131-
})
129+
await waitFor(() => {
130+
expect(screen.queryByTestId('delete-section')).toHaveClass('hidden');
131+
});
132132
});
133133
});
134134

@@ -163,7 +163,7 @@ describe('AdminSission Component', () => {
163163
</MockedProvider>,
164164
);
165165

166-
await waitFor(async() => {
166+
await waitFor(async () => {
167167
fireEvent.click(screen.getAllByTestId('updateIcon')[0]);
168168
expect(screen.getByTestId('update-section')).toBeInTheDocument();
169169

@@ -176,9 +176,9 @@ describe('AdminSission Component', () => {
176176
});
177177

178178
fireEvent.click(screen.getByTestId('save'));
179-
await waitFor(()=>{
179+
await waitFor(() => {
180180
expect(screen.queryByText('update-section')).toBeNull();
181-
})
181+
});
182182
});
183183
});
184184
});

src/pages/tests/About.test.tsx

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import React from "react";
2-
import { MemoryRouter } from "react-router-dom";
3-
import renderer from "react-test-renderer"
4-
import "@testing-library/jest-dom"
5-
import { About } from '../About'
6-
import { MockedProvider as ApolloProvider } from "@apollo/client/testing";
1+
import React from 'react';
2+
import { MemoryRouter } from 'react-router-dom';
3+
import renderer from 'react-test-renderer';
4+
import '@testing-library/jest-dom';
5+
import { MockedProvider as ApolloProvider } from '@apollo/client/testing';
6+
import { About } from '../About';
77

8-
describe('About page',()=>{
8+
describe('About page', () => {
9+
it('renders the about page', () => {
10+
const elem = renderer.create(
11+
<MemoryRouter>
12+
<ApolloProvider>
13+
<About />
14+
</ApolloProvider>
15+
</MemoryRouter>,
16+
);
917

10-
it('renders the about page',()=>{
11-
const elem = renderer.create(
12-
<MemoryRouter>
13-
<ApolloProvider>
14-
<About/>
15-
</ApolloProvider>
16-
</MemoryRouter>
17-
)
18-
19-
expect(elem.toJSON()).toMatchSnapshot()
20-
})
21-
22-
})
18+
expect(elem.toJSON()).toMatchSnapshot();
19+
});
20+
});

src/tests/about.test.tsx

+14-15
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ import React from 'react';
22
import { render, screen } from '@testing-library/react';
33
import '@testing-library/jest-dom';
44
import { MemoryRouter } from 'react-router-dom';
5-
import { About } from '../pages/About';
65
import { I18nextProvider } from 'react-i18next';
6+
import { About } from '../pages/About';
77

88
// Mock i18next
99
jest.mock('react-i18next', () => ({
1010
// this mock makes sure any components using the translate hook can use it without a warning being shown
11-
useTranslation: () => {
12-
return {
13-
t: (str: string) => str,
14-
i18n: {
15-
changeLanguage: () => new Promise(() => {}),
16-
},
17-
};
18-
},
11+
useTranslation: () => ({
12+
t: (str: string) => str,
13+
i18n: {
14+
changeLanguage: () => new Promise(() => {}),
15+
},
16+
}),
1917
initReactI18next: {
2018
type: '3rdParty',
2119
init: () => {},
@@ -48,13 +46,12 @@ jest.mock('../assets/person2.png', () => 'mock-person2-image');
4846
jest.mock('../assets/ur.png', () => 'mock-ur-image');
4947

5048
describe('About Component', () => {
51-
const renderComponent = () => {
52-
return render(
49+
const renderComponent = () =>
50+
render(
5351
<MemoryRouter>
5452
<About />
55-
</MemoryRouter>
53+
</MemoryRouter>,
5654
);
57-
};
5855

5956
it('renders the main heading', () => {
6057
renderComponent();
@@ -89,6 +86,8 @@ describe('About Component', () => {
8986

9087
it('renders the final heading', () => {
9188
renderComponent();
92-
expect(screen.getByText('Come shape the future together')).toBeInTheDocument();
89+
expect(
90+
screen.getByText('Come shape the future together'),
91+
).toBeInTheDocument();
9392
});
94-
});
93+
});

0 commit comments

Comments
 (0)