From ea1e1e31c63a521b66d1cbc9bd1ce8ef87cfabd9 Mon Sep 17 00:00:00 2001
From: shebelle <154588570+shebz2023@users.noreply.github.com>
Date: Thu, 5 Sep 2024 15:35:46 +0200
Subject: [PATCH] fix(trainee dashboard) remove performance details field
(#436)
---
src/components/Sidebar.tsx | 11 ++-
src/components/TraineePerformance.tsx | 94 ++++++++-----------
.../admin-dashBoard/tests/Sessions.test.tsx | 16 ++--
src/pages/tests/About.test.tsx | 38 ++++----
src/tests/about.test.tsx | 29 +++---
5 files changed, 83 insertions(+), 105 deletions(-)
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 6dd7625bf..2ab1266d8 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -18,7 +18,7 @@ import {
MoonIcon,
MailIcon,
} from '@heroicons/react/solid';
-import { FaEnvelopeOpenText } from "react-icons/fa6";
+import { FaEnvelopeOpenText } from 'react-icons/fa6';
import {
AcademicCapIcon,
BookOpenIcon,
@@ -37,8 +37,9 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
const { logout } = useContext(UserContext);
return (
void }) {
- {/* INVITATION*/}
+ {/* INVITATION */}
@@ -195,4 +196,4 @@ function Sidebar({ style, toggle }: { style: string; toggle: () => void }) {
);
}
-export default Sidebar;
\ No newline at end of file
+export default Sidebar;
diff --git a/src/components/TraineePerformance.tsx b/src/components/TraineePerformance.tsx
index a67fe9eb1..7981c5416 100644
--- a/src/components/TraineePerformance.tsx
+++ b/src/components/TraineePerformance.tsx
@@ -5,7 +5,6 @@ import { toast } from 'react-toastify';
import Pagination from './Pagination';
import PerformanceData from '../dummyData/performance.json';
import { TRAINEE_RATING } from '../Mutations/Ratings';
-import Button from './Buttons';
import RemarksModal from '../pages/ratings/CoordinatorRemarks';
import { UserContext } from '../hook/useAuth';
import { rowsType } from '../pages/ratings/frame';
@@ -63,7 +62,7 @@ export const GET_RATINGS_DATA = gql`
`;
function TraineePerfomance() {
- const [usedata, setUserdata] = React.useState([]);
+ const [usedata, setUserdata] = useState([]);
const { data, loading, error } = useQuery(GET_RATINGS_DATA, {});
const { user } = useContext(UserContext);
const [row, setRow] = useState({
@@ -121,14 +120,11 @@ function TraineePerfomance() {
useEffect(() => {
getRatings({
fetchPolicy: 'network-only',
- onCompleted: /* istanbul ignore next */ (data) => {
- /* istanbul ignore next */
+ onCompleted: (data) => {
setRatings(data?.fetchRatingsTrainee);
- /* istanbul ignore next */
sessionStorage.removeItem('data');
},
- onError: /* istanbul ignore next */ (error) => {
- /* istanbul ignore next */
+ onError: (error) => {
toast.error(error?.message || 'Something went wrong');
},
});
@@ -152,6 +148,7 @@ function TraineePerfomance() {
const closeFeeds = () => {
setToggle(false);
};
+
if (loading) {
return (
<>
@@ -171,6 +168,7 @@ function TraineePerfomance() {
>
);
}
+
if (ratings?.length === 0) {
return (
<>
@@ -240,14 +238,10 @@ function TraineePerfomance() {
{t('Average')}
|
-
- {t('Actions')}
- |
- {ratings?.slice(firstContentIndex, lastContentIndex).map(
- /* istanbul ignore next */
- (item: any) => (
- /* istanbul ignore next */
+ {ratings
+ ?.slice(firstContentIndex, lastContentIndex)
+ .map((item: any) => (
@@ -280,29 +274,13 @@ function TraineePerfomance() {
|
- {item.average % 1 === 0 ? item.average : Number(item.average).toFixed(2)}
+ {item.average % 1 === 0
+ ? item.average
+ : Number(item.average).toFixed(2)}
|
-
-
-
- |
- ),
- )}
+ ))}
@@ -314,8 +292,9 @@ function TraineePerfomance() {
onClick={prevPage}
data-testid="prev"
type="button"
- className={`page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${page === 1 && 'disabled'
- }`}
+ className={`page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
+ page === 1 && 'disabled'
+ }`}
>
←
@@ -323,32 +302,32 @@ function TraineePerfomance() {
onClick={() => setPage(1)}
data-testid="page1"
type="button"
- className={`page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${page === 1 && 'disabled'
- }`}
+ className={`page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
+ page === 1 && 'disabled'
+ }`}
>
1
- {/* @ts-ignore */}
- {gaps.paginationGroup.map(
- /* istanbul ignore next */(el) => (
-
- ),
- )}
+ {gaps.paginationGroup.map((el) => (
+
+ ))}
@@ -356,8 +335,9 @@ function TraineePerfomance() {
onClick={nextPage}
data-testid="next"
type="button"
- className={`page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${page === totalPages && 'disabled'
- }`}
+ className={`page flex text-white h-12 w-12 items-center justify-center border-solid cursor-pointer bg-transparent ${
+ page === totalPages && 'disabled'
+ }`}
>
→
diff --git a/src/containers/admin-dashBoard/tests/Sessions.test.tsx b/src/containers/admin-dashBoard/tests/Sessions.test.tsx
index ce2ea11c1..dded76ce9 100644
--- a/src/containers/admin-dashBoard/tests/Sessions.test.tsx
+++ b/src/containers/admin-dashBoard/tests/Sessions.test.tsx
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom';
import React from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
-import '@testing-library/jest-dom';
+
import { MockedProvider } from '@apollo/client/testing';
import { act } from 'react-dom/test-utils';
import AdminSission from '../Sessions';
@@ -123,12 +123,12 @@ describe('AdminSission Component', () => {
await waitFor(async () => {
fireEvent.click(screen.getAllByTestId('deleteIcon')[0]);
expect(screen.getByTestId('delete-section')).toBeInTheDocument();
- expect(screen.getByTestId('delete-section')).toHaveClass("block");
+ expect(screen.getByTestId('delete-section')).toHaveClass('block');
fireEvent.click(screen.getByTestId('delete'));
- await waitFor(()=>{
- expect(screen.queryByTestId('delete-section')).toHaveClass("hidden");
- })
+ await waitFor(() => {
+ expect(screen.queryByTestId('delete-section')).toHaveClass('hidden');
+ });
});
});
@@ -163,7 +163,7 @@ describe('AdminSission Component', () => {
,
);
- await waitFor(async() => {
+ await waitFor(async () => {
fireEvent.click(screen.getAllByTestId('updateIcon')[0]);
expect(screen.getByTestId('update-section')).toBeInTheDocument();
@@ -176,9 +176,9 @@ describe('AdminSission Component', () => {
});
fireEvent.click(screen.getByTestId('save'));
- await waitFor(()=>{
+ await waitFor(() => {
expect(screen.queryByText('update-section')).toBeNull();
- })
+ });
});
});
});
diff --git a/src/pages/tests/About.test.tsx b/src/pages/tests/About.test.tsx
index 42f67053f..abe7e86d0 100644
--- a/src/pages/tests/About.test.tsx
+++ b/src/pages/tests/About.test.tsx
@@ -1,22 +1,20 @@
-import React from "react";
-import { MemoryRouter } from "react-router-dom";
-import renderer from "react-test-renderer"
-import "@testing-library/jest-dom"
-import { About } from '../About'
-import { MockedProvider as ApolloProvider } from "@apollo/client/testing";
+import React from 'react';
+import { MemoryRouter } from 'react-router-dom';
+import renderer from 'react-test-renderer';
+import '@testing-library/jest-dom';
+import { MockedProvider as ApolloProvider } from '@apollo/client/testing';
+import { About } from '../About';
-describe('About page',()=>{
+describe('About page', () => {
+ it('renders the about page', () => {
+ const elem = renderer.create(
+
+
+
+
+ ,
+ );
- it('renders the about page',()=>{
- const elem = renderer.create(
-
-
-
-
-
- )
-
- expect(elem.toJSON()).toMatchSnapshot()
- })
-
-})
+ expect(elem.toJSON()).toMatchSnapshot();
+ });
+});
diff --git a/src/tests/about.test.tsx b/src/tests/about.test.tsx
index 46dae07de..ac2218e0b 100644
--- a/src/tests/about.test.tsx
+++ b/src/tests/about.test.tsx
@@ -2,20 +2,18 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { MemoryRouter } from 'react-router-dom';
-import { About } from '../pages/About';
import { I18nextProvider } from 'react-i18next';
+import { About } from '../pages/About';
// Mock i18next
jest.mock('react-i18next', () => ({
// this mock makes sure any components using the translate hook can use it without a warning being shown
- useTranslation: () => {
- return {
- t: (str: string) => str,
- i18n: {
- changeLanguage: () => new Promise(() => {}),
- },
- };
- },
+ useTranslation: () => ({
+ t: (str: string) => str,
+ i18n: {
+ changeLanguage: () => new Promise(() => {}),
+ },
+ }),
initReactI18next: {
type: '3rdParty',
init: () => {},
@@ -48,13 +46,12 @@ jest.mock('../assets/person2.png', () => 'mock-person2-image');
jest.mock('../assets/ur.png', () => 'mock-ur-image');
describe('About Component', () => {
- const renderComponent = () => {
- return render(
+ const renderComponent = () =>
+ render(
-
+ ,
);
- };
it('renders the main heading', () => {
renderComponent();
@@ -89,6 +86,8 @@ describe('About Component', () => {
it('renders the final heading', () => {
renderComponent();
- expect(screen.getByText('Come shape the future together')).toBeInTheDocument();
+ expect(
+ screen.getByText('Come shape the future together'),
+ ).toBeInTheDocument();
});
-});
\ No newline at end of file
+});