diff --git a/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.test.tsx b/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.test.tsx index bb7c8d1c5e5a3774c11790afd600408ba1b7341e..5a6e2f1a5c873778ae6e824b800a617a6a9761ad 100644 --- a/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.test.tsx +++ b/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.test.tsx @@ -3,11 +3,9 @@ import { InitialStoreState, getReduxStoreWithActionsListener, } from '@/utils/testing/getReduxStoreActionsListener'; -import mockRouter from 'next-router-mock'; import { fireEvent, render, screen } from '@testing-library/react'; import { MockStoreEnhanced } from 'redux-mock-store'; import { FIRST_ARRAY_ELEMENT } from '@/constants/common'; -import { projectFixture } from '@/models/fixtures/projectFixture'; import { LoggedInMenuModal } from './LoggedInMenuModal.component'; const renderComponent = ( @@ -41,22 +39,4 @@ describe('LoggedInMenuModal component', () => { const actions = store.getActions(); expect(actions[FIRST_ARRAY_ELEMENT].type).toBe('modal/closeModal'); }); - - it('redirects to the admin panel when "Go to the admin panel" button is clicked', () => { - const routerPushSpy = jest.spyOn(mockRouter, 'push'); - renderComponent({ - project: { - data: projectFixture, - loading: 'succeeded', - error: { message: '', name: '' }, - projectId: '', - }, - }); - - fireEvent.click(screen.getByText('Go to the admin panel')); - - expect(routerPushSpy).toHaveBeenCalledWith( - `https://lux1.atcomp.pl/minerva/admin.xhtml?id=pdmap_appu_test`, - ); - }); }); diff --git a/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.tsx b/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.tsx index 04c9cd9e6f8ac5170a5bdfcf41f344c49de69f3c..284d998f8dad6185777063462a5e5ee60d5258f4 100644 --- a/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.tsx +++ b/src/components/FunctionalArea/Modal/LoggedInMenuModal/LoggedInMenuModal.component.tsx @@ -2,19 +2,17 @@ import { CURRENT_PROJECT_ADMIN_PANEL_URL } from '@/constants'; import { useAppDispatch } from '@/redux/hooks/useAppDispatch'; import { closeModal } from '@/redux/modal/modal.slice'; import { Button } from '@/shared/Button'; -import { useRouter } from 'next/router'; import React from 'react'; export const LoggedInMenuModal = (): React.ReactNode => { const dispatch = useAppDispatch(); - const router = useRouter(); const closeLoggedInMenuModal = (): void => { dispatch(closeModal()); }; const goToTheAdminPanel = (): void => { - router.push(CURRENT_PROJECT_ADMIN_PANEL_URL); + window.location.href = CURRENT_PROJECT_ADMIN_PANEL_URL; }; return ( <div className="flex justify-center gap-5 border border-t-[#E1E0E6] bg-white p-6"> diff --git a/src/components/FunctionalArea/TopBar/User/User.component.test.tsx b/src/components/FunctionalArea/TopBar/User/User.component.test.tsx index 707e0f5dac4dac4709f7d47e1eef9e5ee3e226ba..5a1ec9b5b884b2330ed91aa4faab3f490441ee70 100644 --- a/src/components/FunctionalArea/TopBar/User/User.component.test.tsx +++ b/src/components/FunctionalArea/TopBar/User/User.component.test.tsx @@ -6,8 +6,6 @@ import { USER_INITIAL_STATE_MOCK } from '@/redux/user/user.mock'; import { mockNetworkResponse } from '@/utils/mockNetworkResponse'; import { apiPath } from '@/redux/apiPath'; import { HttpStatusCode } from 'axios'; -import mockRouter from 'next-router-mock'; -import { projectFixture } from '@/models/fixtures/projectFixture'; import { oauthFixture } from '@/models/fixtures/oauthFixture'; import { User } from './User.component'; @@ -160,39 +158,6 @@ describe('AuthenticatedUser component', () => { expect(modalState.isOpen).toBeTruthy(); expect(modalState.modalName).toBe('login'); }); - it('should change site to admin panel if go to the admin panel is pressed', async () => { - const routerPushSpy = jest.spyOn(mockRouter, 'push'); - renderComponent({ - project: { - data: projectFixture, - loading: 'succeeded', - error: { message: '', name: '' }, - projectId: '', - }, - user: { - ...USER_INITIAL_STATE_MOCK, - authenticated: true, - login: 'name', - role: 'admin', - }, - }); - - const button = screen.getByTestId('authenticated-button'); - - await waitFor(() => { - button.click(); - }); - - const adminPanelButton = screen.getByText('Go to the admin panel'); - - await waitFor(() => { - adminPanelButton.click(); - }); - - expect(routerPushSpy).toHaveBeenCalledWith( - `https://lux1.atcomp.pl/minerva/admin.xhtml?id=pdmap_appu_test`, - ); - }); }); describe('UnauthenticatedUser component', () => { diff --git a/src/components/FunctionalArea/TopBar/User/hooks/useUserActions.ts b/src/components/FunctionalArea/TopBar/User/hooks/useUserActions.ts index f1c0f845b995fe380cd750a38acbf3d7b874631b..cb3deb245565a989e12bb64a7bb8fa2b7d9d4b48 100644 --- a/src/components/FunctionalArea/TopBar/User/hooks/useUserActions.ts +++ b/src/components/FunctionalArea/TopBar/User/hooks/useUserActions.ts @@ -4,7 +4,6 @@ import { openLoginModal } from '@/redux/modal/modal.slice'; import { userRoleSelector } from '@/redux/user/user.selectors'; import { logout } from '@/redux/user/user.thunks'; import { IconTypes } from '@/types/iconTypes'; -import { useRouter } from 'next/router'; import { USER_ROLE } from '@/constants/user'; import { useMemo } from 'react'; import { CURRENT_PROJECT_ADMIN_PANEL_URL } from '@/constants'; @@ -21,7 +20,6 @@ type UseUserActionsReturnType = { export const useUserActions = (): UseUserActionsReturnType => { const dispatch = useAppDispatch(); const userRole = useAppSelector(userRoleSelector); - const router = useRouter(); const actions = useMemo(() => { return userRole === USER_ROLE.ADMIN || userRole === USER_ROLE.CURATOR @@ -43,7 +41,7 @@ export const useUserActions = (): UseUserActionsReturnType => { }; const goToThePanelAdmin = (): void => { - router.push(CURRENT_PROJECT_ADMIN_PANEL_URL); + window.location.href = CURRENT_PROJECT_ADMIN_PANEL_URL; }; const handleActionClick = (action: string): void => {