@@ -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(
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user