@@ -24,6 +24,14 @@ import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
import { AboutContent } from './AboutContent';
|
||||
import { CatalogApi } from '@backstage/catalog-client';
|
||||
import { ApiProvider } from '@backstage/core-app-api';
|
||||
|
||||
const catalogApi: jest.Mocked<CatalogApi> = {
|
||||
getEntityByRef: jest.fn(),
|
||||
} as any;
|
||||
|
||||
const apis = TestApiRegistry.from([catalogApiRef, catalogApi]);
|
||||
|
||||
describe('<AboutContent />', () => {
|
||||
describe('An unknown entity', () => {
|
||||
@@ -63,11 +71,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -93,11 +106,16 @@ describe('<AboutContent />', () => {
|
||||
entity.spec = {};
|
||||
entity.relations = [];
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -148,11 +166,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -185,11 +208,16 @@ describe('<AboutContent />', () => {
|
||||
delete entity.spec!.system;
|
||||
entity.relations = [];
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -253,11 +281,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -293,11 +326,16 @@ describe('<AboutContent />', () => {
|
||||
delete entity.spec!.system;
|
||||
entity.relations = [];
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -349,11 +387,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -376,11 +419,16 @@ describe('<AboutContent />', () => {
|
||||
delete entity.metadata.tags;
|
||||
entity.relations = [];
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -421,11 +469,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -453,11 +506,16 @@ describe('<AboutContent />', () => {
|
||||
delete entity.metadata.tags;
|
||||
delete entity.spec!.type;
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -509,11 +567,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -542,11 +605,16 @@ describe('<AboutContent />', () => {
|
||||
delete entity.spec!.system;
|
||||
entity.relations = [];
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -600,11 +668,16 @@ describe('<AboutContent />', () => {
|
||||
});
|
||||
|
||||
it('renders info', async () => {
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
@@ -631,11 +704,16 @@ describe('<AboutContent />', () => {
|
||||
delete entity.spec!.domain;
|
||||
entity.relations = [];
|
||||
|
||||
await renderInTestApp(<AboutContent entity={entity} />, {
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
await renderInTestApp(
|
||||
<ApiProvider apis={apis}>
|
||||
<AboutContent entity={entity} />
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||
expect(screen.getByText('Description').nextSibling).toHaveTextContent(
|
||||
|
||||
Reference in New Issue
Block a user