diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.test.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.test.tsx
index 45411a9d5e..eaaaab39bc 100644
--- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.test.tsx
+++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLink.test.tsx
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import { render } from '@testing-library/react';
+import { renderInTestApp } from '@backstage/test-utils';
import React from 'react';
-import { MemoryRouter } from 'react-router';
+import { entityRouteRef } from '../../routes';
import { EntityRefLink } from './EntityRefLink';
describe('', () => {
- it('renders link for entity in default namespace', () => {
+ it('renders link for entity in default namespace', async () => {
const entity = {
apiVersion: 'v1',
kind: 'Component',
@@ -33,9 +33,14 @@ describe('', () => {
lifecycle: 'production',
},
};
- const { getByText } = render(, {
- wrapper: MemoryRouter,
- });
+ const { getByText } = await renderInTestApp(
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
expect(getByText('component:software')).toHaveAttribute(
'href',
@@ -43,7 +48,7 @@ describe('', () => {
);
});
- it('renders link for entity in other namespace', () => {
+ it('renders link for entity in other namespace', async () => {
const entity = {
apiVersion: 'v1',
kind: 'Component',
@@ -57,16 +62,21 @@ describe('', () => {
lifecycle: 'production',
},
};
- const { getByText } = render(, {
- wrapper: MemoryRouter,
- });
+ const { getByText } = await renderInTestApp(
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
expect(getByText('component:test/software')).toHaveAttribute(
'href',
'/catalog/test/component/software',
);
});
- it('renders link for entity and hides default kind', () => {
+ it('renders link for entity and hides default kind', async () => {
const entity = {
apiVersion: 'v1',
kind: 'Component',
@@ -80,10 +90,12 @@ describe('', () => {
lifecycle: 'production',
},
};
- const { getByText } = render(
+ const { getByText } = await renderInTestApp(
,
{
- wrapper: MemoryRouter,
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
},
);
expect(getByText('test/software')).toHaveAttribute(
@@ -92,46 +104,58 @@ describe('', () => {
);
});
- it('renders link for entity name in default namespace', () => {
+ it('renders link for entity name in default namespace', async () => {
const entityName = {
kind: 'Component',
namespace: 'default',
name: 'software',
};
- const { getByText } = render(, {
- wrapper: MemoryRouter,
- });
+ const { getByText } = await renderInTestApp(
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
expect(getByText('component:software')).toHaveAttribute(
'href',
'/catalog/default/component/software',
);
});
- it('renders link for entity name in other namespace', () => {
+ it('renders link for entity name in other namespace', async () => {
const entityName = {
kind: 'Component',
namespace: 'test',
name: 'software',
};
- const { getByText } = render(, {
- wrapper: MemoryRouter,
- });
+ const { getByText } = await renderInTestApp(
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
expect(getByText('component:test/software')).toHaveAttribute(
'href',
'/catalog/test/component/software',
);
});
- it('renders link for entity name and hides default kind', () => {
+ it('renders link for entity name and hides default kind', async () => {
const entityName = {
kind: 'Component',
namespace: 'test',
name: 'software',
};
- const { getByText } = render(
+ const { getByText } = await renderInTestApp(
,
{
- wrapper: MemoryRouter,
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
},
);
expect(getByText('test/software')).toHaveAttribute(
@@ -140,18 +164,20 @@ describe('', () => {
);
});
- it('renders link with custom children', () => {
+ it('renders link with custom children', async () => {
const entityName = {
kind: 'Component',
namespace: 'test',
name: 'software',
};
- const { getByText } = render(
+ const { getByText } = await renderInTestApp(
Custom Children
,
{
- wrapper: MemoryRouter,
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
},
);
expect(getByText('Custom Children')).toHaveAttribute(
diff --git a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.test.tsx b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.test.tsx
index 97817f3de9..147e139749 100644
--- a/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.test.tsx
+++ b/plugins/catalog-react/src/components/EntityRefLink/EntityRefLinks.test.tsx
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import { render } from '@testing-library/react';
+import { renderInTestApp } from '@backstage/test-utils';
import React from 'react';
-import { MemoryRouter } from 'react-router';
+import { entityRouteRef } from '../../routes';
import { EntityRefLinks } from './EntityRefLinks';
describe('', () => {
- it('renders a single link', () => {
+ it('renders a single link', async () => {
const entityNames = [
{
kind: 'Component',
@@ -28,16 +28,21 @@ describe('', () => {
name: 'software',
},
];
- const { getByText } = render(, {
- wrapper: MemoryRouter,
- });
+ const { getByText } = await renderInTestApp(
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
expect(getByText('component:software')).toHaveAttribute(
'href',
'/catalog/default/component/software',
);
});
- it('renders multiple links', () => {
+ it('renders multiple links', async () => {
const entityNames = [
{
kind: 'Component',
@@ -50,9 +55,14 @@ describe('', () => {
name: 'interface',
},
];
- const { getByText } = render(, {
- wrapper: MemoryRouter,
- });
+ const { getByText } = await renderInTestApp(
+ ,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
+ );
expect(getByText(',')).toBeInTheDocument();
expect(getByText('component:software')).toHaveAttribute(
'href',
diff --git a/plugins/catalog-react/src/components/EntityTable/presets.test.tsx b/plugins/catalog-react/src/components/EntityTable/presets.test.tsx
index 6e18508b1f..a509b67477 100644
--- a/plugins/catalog-react/src/components/EntityTable/presets.test.tsx
+++ b/plugins/catalog-react/src/components/EntityTable/presets.test.tsx
@@ -23,6 +23,7 @@ import {
import { renderInTestApp } from '@backstage/test-utils';
import { waitFor } from '@testing-library/react';
import React from 'react';
+import { entityRouteRef } from '../../routes';
import { EntityTable } from './EntityTable';
import { componentEntityColumns, systemEntityColumns } from './presets';
@@ -68,6 +69,11 @@ describe('systemEntityColumns', () => {
emptyContent={
EMPTY
}
columns={systemEntityColumns}
/>,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
@@ -123,6 +129,11 @@ describe('componentEntityColumns', () => {
emptyContent={EMPTY
}
columns={componentEntityColumns}
/>,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
diff --git a/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx b/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx
index 339323c1bf..eccf824c2e 100644
--- a/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx
+++ b/plugins/catalog-react/src/components/UnregisterEntityDialog/UnregisterEntityDialog.test.tsx
@@ -22,6 +22,7 @@ import { UnregisterEntityDialog } from './UnregisterEntityDialog';
import { ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model';
import { CatalogClient } from '@backstage/catalog-client';
import { catalogApiRef } from '../../api';
+import { entityRouteRef } from '../../routes';
import { screen, waitFor } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import * as state from './useUnregisterEntityDialogState';
@@ -89,6 +90,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
userEvent.click(screen.getByText('Cancel'));
@@ -110,6 +116,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
@@ -132,6 +143,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
@@ -159,6 +175,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
@@ -198,6 +219,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
@@ -239,6 +265,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {
@@ -282,6 +313,11 @@ describe('UnregisterEntityDialog', () => {
entity={entity}
/>
,
+ {
+ mountedRoutes: {
+ '/catalog/:namespace/:kind/:name/*': entityRouteRef,
+ },
+ },
);
await waitFor(() => {