diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index 14628a0323..150f5362f3 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -77,8 +77,7 @@ "peerDependencies": { "react": "^16.13.1 || ^17.0.0 || ^18.0.0", "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0", - "react-router-dom": "6.0.0-beta.0 || ^6.3.0", - "react-router": "6.17.0" + "react-router-dom": "6.0.0-beta.0 || ^6.3.0" }, "devDependencies": { "@backstage/cli": "workspace:^", diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx index 96b1a3ae59..9196ad9e8d 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx @@ -41,7 +41,7 @@ import { act, fireEvent, screen, waitFor } from '@testing-library/react'; import React from 'react'; import { EntityLayout } from './EntityLayout'; import { rootRouteRef, unregisterRedirectRouteRef } from '../../routes'; -import * as router from 'react-router'; +import { Route, Routes } from 'react-router-dom'; describe('EntityLayout', () => { const mockEntity = { @@ -326,15 +326,6 @@ describe('EntityLayout - CleanUpAfterRemoval', () => { }, }; - const navigate = jest.fn(); - beforeEach(() => { - jest.spyOn(router, 'useNavigate').mockImplementation(() => navigate); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - it('redirects to externalRouteRef when unregisterRedirectRouteRef is bound', async () => { await renderInTestApp( { + + catalog-page

} /> + external-page

} /> +
, { mountedRoutes: { '/catalog/:namespace/:kind/:name': entityRouteRef, '/catalog': rootRouteRef, - '/testExternalRouteRef': unregisterRedirectRouteRef, + '/testRoute': unregisterRedirectRouteRef, }, }, ); @@ -386,7 +381,7 @@ describe('EntityLayout - CleanUpAfterRemoval', () => { }); await waitFor(() => { - expect(navigate).toHaveBeenCalledWith('/testExternalRouteRef'); + expect(screen.getByText('external-page')).toBeInTheDocument(); }); }); @@ -415,6 +410,10 @@ describe('EntityLayout - CleanUpAfterRemoval', () => { + + catalog-page

} /> + external-page

} /> +
, { mountedRoutes: { @@ -440,7 +439,7 @@ describe('EntityLayout - CleanUpAfterRemoval', () => { }); await waitFor(() => { - expect(navigate).toHaveBeenCalledWith('/catalog'); + expect(screen.getByText('catalog-page')).toBeInTheDocument(); }); }); });