attempt to unbreak storybook tests for GroupProfileCard

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-02-24 13:11:40 +01:00
parent c787dcf501
commit b2efb8d544
2 changed files with 67 additions and 40 deletions
@@ -15,17 +15,17 @@
*/
import { GroupEntity } from '@backstage/catalog-model';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import {
CatalogApi,
catalogApiRef,
EntityProvider,
entityRouteRef,
} from '@backstage/plugin-catalog-react';
import { TestApiProvider, wrapInTestApp } from '@backstage/test-utils';
import { Grid } from '@material-ui/core';
import React from 'react';
import { MemoryRouter } from 'react-router';
import React, { ComponentType } from 'react';
import { GroupProfileCard } from './GroupProfileCard';
export default {
title: 'Plugins/Org/Group Profile Card',
component: GroupProfileCard,
};
const dummyDepartment = {
type: 'childOf',
targetRef: 'group:default/department-a',
@@ -56,14 +56,34 @@ const defaultEntity: GroupEntity = {
relations: [dummyDepartment],
};
const catalogApi: Partial<CatalogApi> = {
async refreshEntity() {},
};
export const Default = () => (
<MemoryRouter>
<EntityProvider entity={defaultEntity}>
<Grid container spacing={4}>
<Grid item xs={12} md={4}>
<GroupProfileCard variant="gridItem" />
</Grid>
<EntityProvider entity={defaultEntity}>
<Grid container spacing={4}>
<Grid item xs={12} md={4}>
<GroupProfileCard variant="gridItem" />
</Grid>
</EntityProvider>
</MemoryRouter>
</Grid>
</EntityProvider>
);
export default {
title: 'Plugins/Org/Group Profile Card',
component: GroupProfileCard,
decorators: [
(Story: ComponentType<{}>) =>
wrapInTestApp(
<TestApiProvider apis={[[catalogApiRef, catalogApi]]}>
<Story />
</TestApiProvider>,
{
mountedRoutes: {
'/a': entityRouteRef,
},
},
),
],
};
@@ -15,17 +15,15 @@
*/
import { UserEntity } from '@backstage/catalog-model';
import { EntityProvider } from '@backstage/plugin-catalog-react';
import {
EntityProvider,
entityRouteRef,
} from '@backstage/plugin-catalog-react';
import { wrapInTestApp } from '@backstage/test-utils';
import { Grid } from '@material-ui/core';
import React from 'react';
import { MemoryRouter } from 'react-router';
import React, { ComponentType } from 'react';
import { UserProfileCard } from './UserProfileCard';
export default {
title: 'Plugins/Org/User Profile Card',
component: UserProfileCard,
};
const dummyGroup = {
type: 'memberOf',
targetRef: 'group:default/team-a',
@@ -56,15 +54,13 @@ const defaultEntity: UserEntity = {
};
export const Default = () => (
<MemoryRouter>
<EntityProvider entity={defaultEntity}>
<Grid container spacing={4}>
<Grid item xs={12} md={4}>
<UserProfileCard variant="gridItem" />
</Grid>
<EntityProvider entity={defaultEntity}>
<Grid container spacing={4}>
<Grid item xs={12} md={4}>
<UserProfileCard variant="gridItem" />
</Grid>
</EntityProvider>
</MemoryRouter>
</Grid>
</EntityProvider>
);
const noImageEntity: UserEntity = {
@@ -85,13 +81,24 @@ const noImageEntity: UserEntity = {
};
export const NoImage = () => (
<MemoryRouter>
<EntityProvider entity={noImageEntity}>
<Grid container spacing={4}>
<Grid item xs={12} md={4}>
<UserProfileCard variant="gridItem" />
</Grid>
<EntityProvider entity={noImageEntity}>
<Grid container spacing={4}>
<Grid item xs={12} md={4}>
<UserProfileCard variant="gridItem" />
</Grid>
</EntityProvider>
</MemoryRouter>
</Grid>
</EntityProvider>
);
export default {
title: 'Plugins/Org/User Profile Card',
component: UserProfileCard,
decorators: [
(Story: ComponentType<{}>) =>
wrapInTestApp(<Story />, {
mountedRoutes: {
'/a': entityRouteRef,
},
}),
],
};