Merge pull request #7367 from alexrybch/title-column
added "title" columns
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-catalog': patch
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
Name column will now render entity `metadata.title` if its present
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -71,6 +72,11 @@ describe('<ConsumedApisCard />', () => {
|
||||
<ConsumedApisCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText(/Consumed APIs/i)).toBeInTheDocument();
|
||||
@@ -116,6 +122,11 @@ describe('<ConsumedApisCard />', () => {
|
||||
<ConsumedApisCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -71,6 +72,11 @@ describe('<HasApisCard />', () => {
|
||||
<HasApisCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('APIs')).toBeInTheDocument();
|
||||
@@ -116,6 +122,11 @@ describe('<HasApisCard />', () => {
|
||||
<HasApisCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -71,6 +72,11 @@ describe('<ProvidedApisCard />', () => {
|
||||
<ProvidedApisCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText(/Provided APIs/i)).toBeInTheDocument();
|
||||
@@ -116,6 +122,11 @@ describe('<ProvidedApisCard />', () => {
|
||||
<ProvidedApisCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -70,6 +71,11 @@ describe('<ConsumingComponentsCard />', () => {
|
||||
<ConsumingComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Consumers')).toBeInTheDocument();
|
||||
@@ -121,6 +127,11 @@ describe('<ConsumingComponentsCard />', () => {
|
||||
<ConsumingComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -70,6 +71,11 @@ describe('<ProvidingComponentsCard />', () => {
|
||||
<ProvidingComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Providers')).toBeInTheDocument();
|
||||
@@ -121,6 +127,11 @@ describe('<ProvidingComponentsCard />', () => {
|
||||
<ProvidingComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -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('<EntityRefLink />', () => {
|
||||
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('<EntityRefLink />', () => {
|
||||
lifecycle: 'production',
|
||||
},
|
||||
};
|
||||
const { getByText } = render(<EntityRefLink entityRef={entity} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLink entityRef={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('component:software')).toHaveAttribute(
|
||||
'href',
|
||||
@@ -43,7 +48,7 @@ describe('<EntityRefLink />', () => {
|
||||
);
|
||||
});
|
||||
|
||||
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('<EntityRefLink />', () => {
|
||||
lifecycle: 'production',
|
||||
},
|
||||
};
|
||||
const { getByText } = render(<EntityRefLink entityRef={entity} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLink entityRef={entity} />,
|
||||
{
|
||||
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('<EntityRefLink />', () => {
|
||||
lifecycle: 'production',
|
||||
},
|
||||
};
|
||||
const { getByText } = render(
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLink entityRef={entity} defaultKind="Component" />,
|
||||
{
|
||||
wrapper: MemoryRouter,
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(getByText('test/software')).toHaveAttribute(
|
||||
@@ -92,46 +104,58 @@ describe('<EntityRefLink />', () => {
|
||||
);
|
||||
});
|
||||
|
||||
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(<EntityRefLink entityRef={entityName} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLink entityRef={entityName} />,
|
||||
{
|
||||
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(<EntityRefLink entityRef={entityName} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLink entityRef={entityName} />,
|
||||
{
|
||||
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(
|
||||
<EntityRefLink entityRef={entityName} defaultKind="component" />,
|
||||
{
|
||||
wrapper: MemoryRouter,
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(getByText('test/software')).toHaveAttribute(
|
||||
@@ -140,18 +164,20 @@ describe('<EntityRefLink />', () => {
|
||||
);
|
||||
});
|
||||
|
||||
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(
|
||||
<EntityRefLink entityRef={entityName} defaultKind="component">
|
||||
Custom Children
|
||||
</EntityRefLink>,
|
||||
{
|
||||
wrapper: MemoryRouter,
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(getByText('Custom Children')).toHaveAttribute(
|
||||
|
||||
@@ -19,20 +19,23 @@ import {
|
||||
ENTITY_DEFAULT_NAMESPACE,
|
||||
} from '@backstage/catalog-model';
|
||||
import React, { forwardRef } from 'react';
|
||||
import { generatePath } from 'react-router';
|
||||
import { entityRoute } from '../../routes';
|
||||
import { entityRouteRef } from '../../routes';
|
||||
import { formatEntityRefTitle } from './format';
|
||||
import { Link, LinkProps } from '@backstage/core-components';
|
||||
import { useRouteRef } from '@backstage/core-plugin-api';
|
||||
import { Tooltip } from '@material-ui/core';
|
||||
|
||||
export type EntityRefLinkProps = {
|
||||
entityRef: Entity | EntityName;
|
||||
defaultKind?: string;
|
||||
title?: string;
|
||||
children?: React.ReactNode;
|
||||
} & Omit<LinkProps, 'to'>;
|
||||
|
||||
export const EntityRefLink = forwardRef<any, EntityRefLinkProps>(
|
||||
(props, ref) => {
|
||||
const { entityRef, defaultKind, children, ...linkProps } = props;
|
||||
const { entityRef, defaultKind, title, children, ...linkProps } = props;
|
||||
const entityRoute = useRouteRef(entityRouteRef);
|
||||
|
||||
let kind;
|
||||
let namespace;
|
||||
@@ -56,17 +59,21 @@ export const EntityRefLink = forwardRef<any, EntityRefLinkProps>(
|
||||
namespace?.toLocaleLowerCase('en-US') ?? ENTITY_DEFAULT_NAMESPACE,
|
||||
name,
|
||||
};
|
||||
const formattedEntityRefTitle = formatEntityRefTitle(entityRef, {
|
||||
defaultKind,
|
||||
});
|
||||
|
||||
// TODO: Use useRouteRef here to generate the path
|
||||
return (
|
||||
<Link
|
||||
{...linkProps}
|
||||
ref={ref}
|
||||
to={generatePath(`/catalog/${entityRoute.path}`, routeParams)}
|
||||
>
|
||||
const link = (
|
||||
<Link {...linkProps} ref={ref} to={entityRoute(routeParams)}>
|
||||
{children}
|
||||
{!children && formatEntityRefTitle(entityRef, { defaultKind })}
|
||||
{!children && (title ?? formattedEntityRefTitle)}
|
||||
</Link>
|
||||
);
|
||||
|
||||
return title ? (
|
||||
<Tooltip title={formattedEntityRefTitle}>{link}</Tooltip>
|
||||
) : (
|
||||
link
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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('<EntityRefLinks />', () => {
|
||||
it('renders a single link', () => {
|
||||
it('renders a single link', async () => {
|
||||
const entityNames = [
|
||||
{
|
||||
kind: 'Component',
|
||||
@@ -28,16 +28,21 @@ describe('<EntityRefLinks />', () => {
|
||||
name: 'software',
|
||||
},
|
||||
];
|
||||
const { getByText } = render(<EntityRefLinks entityRefs={entityNames} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLinks entityRefs={entityNames} />,
|
||||
{
|
||||
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('<EntityRefLinks />', () => {
|
||||
name: 'interface',
|
||||
},
|
||||
];
|
||||
const { getByText } = render(<EntityRefLinks entityRefs={entityNames} />, {
|
||||
wrapper: MemoryRouter,
|
||||
});
|
||||
const { getByText } = await renderInTestApp(
|
||||
<EntityRefLinks entityRefs={entityNames} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(getByText(',')).toBeInTheDocument();
|
||||
expect(getByText('component:software')).toHaveAttribute(
|
||||
'href',
|
||||
|
||||
@@ -58,7 +58,11 @@ export function createEntityRefColumn<T extends Entity>({
|
||||
return formatContent(entity1).localeCompare(formatContent(entity2));
|
||||
},
|
||||
render: entity => (
|
||||
<EntityRefLink entityRef={entity} defaultKind={defaultKind} />
|
||||
<EntityRefLink
|
||||
entityRef={entity}
|
||||
defaultKind={defaultKind}
|
||||
title={entity.metadata?.title}
|
||||
/>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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={<div>EMPTY</div>}
|
||||
columns={systemEntityColumns}
|
||||
/>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -123,6 +129,11 @@ describe('componentEntityColumns', () => {
|
||||
emptyContent={<div>EMPTY</div>}
|
||||
columns={componentEntityColumns}
|
||||
/>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
+36
@@ -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}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
userEvent.click(screen.getByText('Cancel'));
|
||||
@@ -110,6 +116,11 @@ describe('UnregisterEntityDialog', () => {
|
||||
entity={entity}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -132,6 +143,11 @@ describe('UnregisterEntityDialog', () => {
|
||||
entity={entity}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -159,6 +175,11 @@ describe('UnregisterEntityDialog', () => {
|
||||
entity={entity}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -198,6 +219,11 @@ describe('UnregisterEntityDialog', () => {
|
||||
entity={entity}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -239,6 +265,11 @@ describe('UnregisterEntityDialog', () => {
|
||||
entity={entity}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -282,6 +313,11 @@ describe('UnregisterEntityDialog', () => {
|
||||
entity={entity}
|
||||
/>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
CatalogApi,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
@@ -85,6 +86,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('service')).toBeInTheDocument();
|
||||
@@ -132,6 +138,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(getByText('View Source').closest('a')).toHaveAttribute(
|
||||
'href',
|
||||
@@ -178,6 +189,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const editLink = getByTitle('Edit Metadata').closest('a');
|
||||
@@ -211,6 +227,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(getByText('View Source').closest('a')).not.toHaveAttribute('href');
|
||||
});
|
||||
@@ -243,6 +264,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(catalogApi.refreshEntity).not.toHaveBeenCalledWith(
|
||||
@@ -280,6 +306,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(queryByTitle('Schedule entity refresh')).not.toBeInTheDocument();
|
||||
@@ -326,6 +357,7 @@ describe('<AboutCard />', () => {
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/docs/:namespace/:kind/:name': viewTechDocRouteRef,
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -371,6 +403,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('View TechDocs').closest('a')).not.toHaveAttribute('href');
|
||||
@@ -414,6 +451,11 @@ describe('<AboutCard />', () => {
|
||||
<AboutCard />
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('View TechDocs').closest('a')).not.toHaveAttribute('href');
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
RELATION_OWNED_BY,
|
||||
RELATION_PART_OF,
|
||||
} from '@backstage/catalog-model';
|
||||
import { entityRouteRef } from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
import { AboutContent } from './AboutContent';
|
||||
@@ -75,6 +76,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -103,6 +109,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -162,6 +173,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -193,6 +209,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -265,6 +286,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -299,6 +325,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -351,6 +382,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -374,6 +410,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -414,6 +455,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -438,6 +484,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -498,6 +549,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -525,6 +581,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -585,6 +646,11 @@ describe('<AboutContent />', () => {
|
||||
it('renders info', async () => {
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
@@ -610,6 +676,11 @@ describe('<AboutContent />', () => {
|
||||
|
||||
const { getByText, queryByText } = await renderInTestApp(
|
||||
<AboutContent entity={entity} />,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Description')).toBeInTheDocument();
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
RELATION_OWNED_BY,
|
||||
} from '@backstage/catalog-model';
|
||||
import { TableColumn, TableProps } from '@backstage/core-components';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
MockStorageApi,
|
||||
renderWithEffects,
|
||||
@@ -136,6 +136,7 @@ describe('CatalogPage', () => {
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/create': createComponentRouteRef,
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
),
|
||||
|
||||
@@ -24,6 +24,7 @@ import { renderInTestApp } from '@backstage/test-utils';
|
||||
import * as React from 'react';
|
||||
import { CatalogTable } from './CatalogTable';
|
||||
import {
|
||||
entityRouteRef,
|
||||
MockEntityListContextProvider,
|
||||
UserListFilter,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
@@ -60,6 +61,11 @@ describe('CatalogTable component', () => {
|
||||
<MockEntityListContextProvider value={{ error: new Error('error') }}>
|
||||
<CatalogTable />
|
||||
</MockEntityListContextProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
const errorMessage = await rendered.findByText(
|
||||
/Could not fetch catalog entities./,
|
||||
@@ -83,6 +89,11 @@ describe('CatalogTable component', () => {
|
||||
>
|
||||
<CatalogTable />
|
||||
</MockEntityListContextProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
expect(rendered.getByText(/Owned \(3\)/)).toBeInTheDocument();
|
||||
expect(rendered.getByText(/component1/)).toBeInTheDocument();
|
||||
@@ -104,6 +115,11 @@ describe('CatalogTable component', () => {
|
||||
<MockEntityListContextProvider value={{ entities: [entity] }}>
|
||||
<CatalogTable />
|
||||
</MockEntityListContextProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const editButton = getByTitle('Edit');
|
||||
@@ -129,6 +145,11 @@ describe('CatalogTable component', () => {
|
||||
<MockEntityListContextProvider value={{ entities: [entity] }}>
|
||||
<CatalogTable />
|
||||
</MockEntityListContextProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const viewButton = getByTitle('View');
|
||||
|
||||
@@ -34,6 +34,7 @@ export function createNameColumn(
|
||||
<EntityRefLink
|
||||
entityRef={entity}
|
||||
defaultKind={props?.defaultKind || 'Component'}
|
||||
title={entity.metadata?.title}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
+11
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -64,6 +65,11 @@ describe('<DependencyOfComponentsCard />', () => {
|
||||
<DependencyOfComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Dependency of components')).toBeInTheDocument();
|
||||
@@ -111,6 +117,11 @@ describe('<DependencyOfComponentsCard />', () => {
|
||||
<DependencyOfComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
+11
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -64,6 +65,11 @@ describe('<DependsOnComponentsCard />', () => {
|
||||
<DependsOnComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Depends on components')).toBeInTheDocument();
|
||||
@@ -111,6 +117,11 @@ describe('<DependsOnComponentsCard />', () => {
|
||||
<DependsOnComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -64,6 +65,11 @@ describe('<DependsOnResourcesCard />', () => {
|
||||
<DependsOnResourcesCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Depends on resources')).toBeInTheDocument();
|
||||
@@ -111,6 +117,11 @@ describe('<DependsOnResourcesCard />', () => {
|
||||
<DependsOnResourcesCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
AsyncEntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
@@ -54,6 +55,11 @@ describe('EntityLayout', () => {
|
||||
</EntityLayout>
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(rendered.getByText('my-entity')).toBeInTheDocument();
|
||||
@@ -80,6 +86,11 @@ describe('EntityLayout', () => {
|
||||
</EntityLayout>
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(rendered.getByText('My Entity')).toBeInTheDocument();
|
||||
@@ -98,6 +109,11 @@ describe('EntityLayout', () => {
|
||||
</EntityLayout>
|
||||
</AsyncEntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(rendered.getByText('Warning: Entity not found')).toBeInTheDocument();
|
||||
@@ -130,6 +146,11 @@ describe('EntityLayout', () => {
|
||||
}
|
||||
/>
|
||||
</Routes>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const secondTab = rendered.queryAllByRole('tab')[1];
|
||||
@@ -172,6 +193,11 @@ describe('EntityLayout', () => {
|
||||
</EntityLayout>
|
||||
</EntityProvider>
|
||||
</ApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(rendered.queryByText('tabbed-test-title')).toBeInTheDocument();
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -64,6 +65,11 @@ describe('<HasComponentsCard />', () => {
|
||||
<HasComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Has components')).toBeInTheDocument();
|
||||
@@ -111,6 +117,11 @@ describe('<HasComponentsCard />', () => {
|
||||
<HasComponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -111,6 +112,11 @@ describe('<HasResourcesCard />', () => {
|
||||
<HasResourcesCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -64,6 +65,11 @@ describe('<HasSubcomponentsCard />', () => {
|
||||
<HasSubcomponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Has subcomponents')).toBeInTheDocument();
|
||||
@@ -111,6 +117,11 @@ describe('<HasSubcomponentsCard />', () => {
|
||||
<HasSubcomponentsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { waitFor } from '@testing-library/react';
|
||||
@@ -64,6 +65,11 @@ describe('<HasSystemsCard />', () => {
|
||||
<HasSystemsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('Has systems')).toBeInTheDocument();
|
||||
@@ -109,6 +115,11 @@ describe('<HasSystemsCard />', () => {
|
||||
<HasSystemsCard />
|
||||
</EntityProvider>
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
*/
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
CatalogApi,
|
||||
catalogApiRef,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
import { FossaApi, fossaApiRef } from '../../api';
|
||||
@@ -125,6 +129,11 @@ describe('<FossaPage />', () => {
|
||||
<Wrapper>
|
||||
<FossaPage />
|
||||
</Wrapper>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name/*': entityRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getAllByText(/Not configured/i)).toHaveLength(2);
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
|
||||
import { UserEntity } from '@backstage/catalog-model';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import {
|
||||
EntityProvider,
|
||||
entityRouteRef,
|
||||
} from '@backstage/plugin-catalog-react';
|
||||
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
import { UserProfileCard } from './UserProfileCard';
|
||||
@@ -53,6 +56,11 @@ describe('UserSummary Test', () => {
|
||||
<EntityProvider entity={userEntity}>
|
||||
<UserProfileCard entity={userEntity} variant="gridItem" />
|
||||
</EntityProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import { wrapInTestApp } from '@backstage/test-utils';
|
||||
import { configApiRef } from '@backstage/core-plugin-api';
|
||||
import { DocsTable } from './DocsTable';
|
||||
import { rootDocsRouteRef } from '../../routes';
|
||||
import { entityRouteRef } from '@backstage/plugin-catalog-react';
|
||||
|
||||
// Hacky way to mock a specific boolean config value.
|
||||
const getOptionalBooleanMock = jest.fn().mockReturnValue(false);
|
||||
@@ -94,6 +95,7 @@ describe('DocsTable test', () => {
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/docs/:namespace/:kind/:name/*': rootDocsRouteRef,
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -144,6 +146,7 @@ describe('DocsTable test', () => {
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/techdocs/:namespace/:kind/:name/*': rootDocsRouteRef,
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
},
|
||||
),
|
||||
@@ -163,6 +166,7 @@ describe('DocsTable test', () => {
|
||||
wrapInTestApp(<DocsTable entities={[]} />, {
|
||||
mountedRoutes: {
|
||||
'/docs/:namespace/:kind/:name/*': rootDocsRouteRef,
|
||||
'/catalog/:namespace/:kind/:name': entityRouteRef,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user