jest tests for ownershipCard improved
Signed-off-by: Jan Vilimek <jan.vilimek@oriflame.com>
This commit is contained in:
@@ -108,6 +108,22 @@ describe('OwnershipCard', () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: 'system',
|
||||
metadata: {
|
||||
name: 'my-systen',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
type: 'ownedBy',
|
||||
target: {
|
||||
name: 'my-team',
|
||||
namespace: 'default',
|
||||
kind: 'Group',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
] as any;
|
||||
|
||||
it('displays entity counts', async () => {
|
||||
@@ -144,6 +160,7 @@ describe('OwnershipCard', () => {
|
||||
expect(
|
||||
queryByText(getByText('LIBRARY').parentElement!, '1'),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('SYSTEM')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('links to the catalog with the group filter', async () => {
|
||||
@@ -222,3 +239,138 @@ describe('OwnershipCard', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('OwnershipCardWithCustomFilterDefinition', () => {
|
||||
const groupEntity: GroupEntity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Group',
|
||||
metadata: {
|
||||
name: 'my-team',
|
||||
},
|
||||
spec: {
|
||||
type: 'team',
|
||||
children: [],
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
type: 'memberOf',
|
||||
target: {
|
||||
kind: 'group',
|
||||
name: 'ExampleGroup',
|
||||
namespace: 'default',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const items = [
|
||||
{
|
||||
kind: 'API',
|
||||
metadata: {
|
||||
name: 'my-api',
|
||||
},
|
||||
spec: {
|
||||
type: 'openapi',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
type: 'ownedBy',
|
||||
target: {
|
||||
name: 'my-team',
|
||||
namespace: 'default',
|
||||
kind: 'Group',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'my-service',
|
||||
},
|
||||
spec: {
|
||||
type: 'service',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
type: 'ownedBy',
|
||||
target: {
|
||||
name: 'my-team',
|
||||
namespace: 'default',
|
||||
kind: 'Group',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
name: 'my-library',
|
||||
namespace: 'other-namespace',
|
||||
},
|
||||
spec: {
|
||||
type: 'library',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
type: 'ownedBy',
|
||||
target: {
|
||||
name: 'my-team',
|
||||
namespace: 'default',
|
||||
kind: 'Group',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: 'system',
|
||||
metadata: {
|
||||
name: 'my-systen',
|
||||
},
|
||||
relations: [
|
||||
{
|
||||
type: 'ownedBy',
|
||||
target: {
|
||||
name: 'my-team',
|
||||
namespace: 'default',
|
||||
kind: 'Group',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
] as any;
|
||||
|
||||
it('displays entity counts', async () => {
|
||||
const catalogApi: jest.Mocked<CatalogApi> = {
|
||||
getEntities: jest.fn(),
|
||||
} as any;
|
||||
|
||||
catalogApi.getEntities.mockResolvedValue({
|
||||
items,
|
||||
});
|
||||
|
||||
const { getByText } = await renderInTestApp(
|
||||
<TestApiProvider apis={[[catalogApiRef, catalogApi]]}>
|
||||
<EntityProvider entity={groupEntity}>
|
||||
<OwnershipCard entityFilterKind={['API','system']} />
|
||||
</EntityProvider>
|
||||
</TestApiProvider>,
|
||||
{
|
||||
mountedRoutes: {
|
||||
'/create': catalogRouteRef,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
expect(getByText('OPENAPI')).toBeInTheDocument();
|
||||
expect(
|
||||
queryByText(getByText('OPENAPI').parentElement!, '1'),
|
||||
).toBeInTheDocument();
|
||||
expect(getByText('SERVICE')).not.toBeInTheDocument();
|
||||
expect(getByText('LIBRARY')).not.toBeInTheDocument();
|
||||
expect(getByText('SYSTEM')).toBeInTheDocument();
|
||||
expect(
|
||||
queryByText(getByText('SYSTEM').parentElement!, '1'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user