test and description

Signed-off-by: Ladislav Vitásek <vity@vity.cz>
This commit is contained in:
Ladislav Vitásek
2024-10-02 12:01:35 +02:00
parent 9b38e9105c
commit 1845810161
2 changed files with 34 additions and 1 deletions
+6 -1
View File
@@ -2,4 +2,9 @@
'@backstage/plugin-catalog-graph': patch
---
Added Action attribute for CatalogGraphCard
Added InfoCard `action` attribute for CatalogGraphCard
```tsx
const action = <Button title="Action Button" onClick={handleClickEvent()} />
<CatalogGraphCard action={action} />
```
@@ -33,6 +33,7 @@ import userEvent from '@testing-library/user-event';
import React from 'react';
import { catalogGraphRouteRef } from '../../routes';
import { CatalogGraphCard } from './CatalogGraphCard';
import Button from '@material-ui/core/Button';
describe('<CatalogGraphCard/>', () => {
let entity: Entity;
@@ -127,6 +128,33 @@ describe('<CatalogGraphCard/>', () => {
expect(await screen.findByText('Custom Title')).toBeInTheDocument();
});
test('renders with action attribute', async () => {
catalog.getEntitiesByRefs.mockImplementation(async _ => ({
items: [
{
...entity,
relations: [],
},
],
}));
await renderInTestApp(
<ApiProvider apis={apis}>
<EntityProvider entity={entity}>
<CatalogGraphCard action={<Button title="Action Button" />} />
</EntityProvider>
</ApiProvider>,
{
mountedRoutes: {
'/entity/{kind}/{namespace}/{name}': entityRouteRef,
'/catalog-graph': catalogGraphRouteRef,
},
},
);
expect(await screen.findByText('Action Button')).toBeInTheDocument();
});
test('renders link to standalone viewer', async () => {
catalog.getEntitiesByRefs.mockImplementation(async _ => ({
items: [