diff --git a/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx b/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx index f9faa3f90f..d77a855d67 100644 --- a/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx +++ b/plugins/catalog/src/components/EntityLayout/EntityLayout.test.tsx @@ -15,7 +15,11 @@ */ import { CatalogApi } from '@backstage/catalog-client'; import { Entity } from '@backstage/catalog-model'; -import { catalogApiRef, EntityContext } from '@backstage/plugin-catalog-react'; +import { + catalogApiRef, + EntityProvider, + AsyncEntityProvider, +} from '@backstage/plugin-catalog-react'; import { renderInTestApp } from '@backstage/test-utils'; import { fireEvent } from '@testing-library/react'; import React from 'react'; @@ -26,16 +30,12 @@ import { EntityLayout } from './EntityLayout'; import { AlertApi, alertApiRef } from '@backstage/core-plugin-api'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; -const mockEntityData = { - loading: false, - error: undefined, - entity: { - kind: 'MyKind', - metadata: { - name: 'my-entity', - }, - } as Entity, -}; +const mockEntity = { + kind: 'MyKind', + metadata: { + name: 'my-entity', + }, +} as Entity; const mockApis = ApiRegistry.with(catalogApiRef, {} as CatalogApi).with( alertApiRef, @@ -46,13 +46,13 @@ describe('EntityLayout', () => { it('renders simplest case', async () => { const rendered = await renderInTestApp( - +
tabbed-test-content
-
+
, ); @@ -62,20 +62,15 @@ describe('EntityLayout', () => { }); it('renders error message when entity is not found', async () => { - const noEntityData = { - ...mockEntityData, - entity: undefined, - }; - const rendered = await renderInTestApp( - +
tabbed-test-content
-
+
, ); @@ -92,7 +87,7 @@ describe('EntityLayout', () => { path="/*" element={ - +
tabbed-test-content
@@ -104,7 +99,7 @@ describe('EntityLayout', () => {
tabbed-test-content-2
-
+
} /> @@ -129,7 +124,7 @@ describe('EntityLayout', () => { const rendered = await renderInTestApp( - +
tabbed-test-content
@@ -149,7 +144,7 @@ describe('EntityLayout', () => {
tabbed-test-content-3
-
+
, ); diff --git a/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.test.tsx b/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.test.tsx index 5e99adf2a2..04ee1dc99e 100644 --- a/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.test.tsx +++ b/plugins/catalog/src/components/EntityLinksCard/EntityLinksCard.test.tsx @@ -15,7 +15,7 @@ */ import { Entity, EntityLink } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils'; import React from 'react'; import { EntityLinksCard } from './EntityLinksCard'; @@ -40,17 +40,12 @@ describe('EntityLinksCard', () => { it('should render a link', async () => { const links: EntityLink[] = [createLink()]; - const entityContextValue = { - entity: createEntity(links), - loading: false, - error: undefined, - }; const { queryByText } = await renderWithEffects( wrapInTestApp( - + - , + , ), ); @@ -59,17 +54,11 @@ describe('EntityLinksCard', () => { }); it('should show empty state', async () => { - const entityContextValue = { - entity: createEntity([]), - loading: false, - error: undefined, - }; - const { queryByText } = await renderWithEffects( wrapInTestApp( - + - , + , ), ); diff --git a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx index 1a87b83600..f80a66b9bb 100644 --- a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx +++ b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx @@ -15,7 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { render } from '@testing-library/react'; import React from 'react'; import { isKind } from './conditions'; @@ -46,15 +46,9 @@ describe('EntitySwitch', () => { const rendered = render( - + {content} - + , ); @@ -64,15 +58,9 @@ describe('EntitySwitch', () => { rendered.rerender( - + {content} - + , ); @@ -82,15 +70,9 @@ describe('EntitySwitch', () => { rendered.rerender( - + {content} - + , ); @@ -100,20 +82,16 @@ describe('EntitySwitch', () => { }); it('should switch child when filters switch', () => { - const entityContextValue = { - entity: { kind: 'component' } as Entity, - loading: false, - error: undefined, - }; + const entity = { kind: 'component' } as Entity; const rendered = render( - + - + , ); @@ -122,12 +100,12 @@ describe('EntitySwitch', () => { rendered.rerender( - + - + , ); diff --git a/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx b/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx index 022e58e053..d239370b6b 100644 --- a/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx +++ b/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsForEntity.test.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { renderHook } from '@testing-library/react-hooks'; import React, { PropsWithChildren } from 'react'; import { useConsumerGroupsForEntity } from './useConsumerGroupsForEntity'; @@ -23,11 +23,7 @@ describe('useConsumerGroupOffsets', () => { let entity: Entity; const wrapper = ({ children }: PropsWithChildren<{}>) => { - return ( - - {children} - - ); + return {children}; }; const subject = () => renderHook(useConsumerGroupsForEntity, { wrapper }); diff --git a/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsOffsetsForEntity.test.tsx b/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsOffsetsForEntity.test.tsx index 193d821ac9..a90d3d608e 100644 --- a/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsOffsetsForEntity.test.tsx +++ b/plugins/kafka/src/components/ConsumerGroupOffsets/useConsumerGroupsOffsetsForEntity.test.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { renderHook } from '@testing-library/react-hooks'; import { when } from 'jest-when'; import React, { PropsWithChildren } from 'react'; @@ -65,9 +65,7 @@ describe('useConsumerGroupOffsets', () => { mockKafkaApi, )} > - - {children} - + {children} ); }; diff --git a/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx b/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx index c4bd898f89..1433a186fb 100644 --- a/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx +++ b/plugins/lighthouse/src/components/AuditList/AuditListForEntity.test.tsx @@ -15,7 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { lightTheme } from '@backstage/theme'; import { ThemeProvider } from '@material-ui/core'; import { render } from '@testing-library/react'; @@ -77,16 +77,14 @@ describe('', () => { }, }; - const subject = (value = {}) => + const subject = () => render( - + - + , diff --git a/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx b/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx index 9a9ac7781e..58a3033a1f 100644 --- a/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx +++ b/plugins/lighthouse/src/components/Cards/LastLighthouseAuditCard.test.tsx @@ -15,7 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { lightTheme } from '@backstage/theme'; import { ThemeProvider } from '@material-ui/core'; import { render } from '@testing-library/react'; @@ -64,15 +64,13 @@ describe('', () => { }, }; - const subject = (value = {}) => + const subject = () => render( - + - + , ); diff --git a/plugins/lighthouse/src/hooks/useWebsiteForEntity.test.tsx b/plugins/lighthouse/src/hooks/useWebsiteForEntity.test.tsx index 85ed149b0e..64f7483081 100644 --- a/plugins/lighthouse/src/hooks/useWebsiteForEntity.test.tsx +++ b/plugins/lighthouse/src/hooks/useWebsiteForEntity.test.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { renderHook } from '@testing-library/react-hooks'; import React, { PropsWithChildren } from 'react'; import { lighthouseApiRef, WebsiteListResponse } from '../api'; @@ -61,9 +61,7 @@ describe('useWebsiteForEntity', () => { mockLighthouseApi, )} > - - {children} - + {children} ); }; diff --git a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx index a8fde99f1f..dc90a46fdf 100644 --- a/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/Group/GroupProfile/GroupProfileCard.stories.tsx @@ -15,7 +15,7 @@ */ import { GroupEntity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { Grid } from '@material-ui/core'; import React from 'react'; import { MemoryRouter } from 'react-router'; @@ -57,12 +57,12 @@ const defaultEntity: GroupEntity = { export const Default = () => ( - + - + ); diff --git a/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx b/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx index f3dae18e77..0a5a0cfef1 100644 --- a/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx +++ b/plugins/org/src/components/Cards/Group/MembersList/MembersListCard.stories.tsx @@ -16,7 +16,7 @@ import { Entity, GroupEntity } from '@backstage/catalog-model'; import { ApiProvider, ApiRegistry } from '@backstage/core-app-api'; -import { catalogApiRef, EntityContext } from '@backstage/plugin-catalog-react'; +import { catalogApiRef, EntityProvider } from '@backstage/plugin-catalog-react'; import { Grid } from '@material-ui/core'; import React from 'react'; import { MemoryRouter } from 'react-router'; @@ -105,13 +105,13 @@ const apiRegistry = (items: Entity[]) => export const Default = () => ( - + - + ); @@ -119,13 +119,13 @@ export const Default = () => ( export const Empty = () => ( - + - + ); diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx index 7ebdf31ae4..14fed985b6 100644 --- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx +++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.stories.tsx @@ -20,7 +20,7 @@ import { CatalogApi, catalogApiRef, catalogRouteRef, - EntityContext, + EntityProvider, } from '@backstage/plugin-catalog-react'; import { wrapInTestApp } from '@backstage/test-utils'; import { @@ -91,13 +91,13 @@ const apiRegistry = ApiRegistry.from([[catalogApiRef, catalogApi]]); export const Default = () => wrapInTestApp( - + - + , { mountedRoutes: { '/catalog': catalogRouteRef }, @@ -124,15 +124,13 @@ export const Themed = () => wrapInTestApp( - + - + , { diff --git a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx index c1019cf2dc..aecc401f52 100644 --- a/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx +++ b/plugins/org/src/components/Cards/User/UserProfileCard/UserProfileCard.stories.tsx @@ -15,7 +15,7 @@ */ import { UserEntity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { Grid } from '@material-ui/core'; import React from 'react'; import { MemoryRouter } from 'react-router'; @@ -55,13 +55,13 @@ const defaultEntity: UserEntity = { export const Default = () => ( - + - + ); @@ -83,12 +83,12 @@ const noImageEntity: UserEntity = { export const NoImage = () => ( - + - + ); diff --git a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx index 4ca86ee412..63d617aff2 100644 --- a/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx +++ b/plugins/splunk-on-call/src/components/EntitySplunkOnCallCard.test.tsx @@ -16,7 +16,7 @@ import React from 'react'; import { act, fireEvent, render, waitFor } from '@testing-library/react'; import { Entity } from '@backstage/catalog-model'; -import { EntityContext } from '@backstage/plugin-catalog-react'; +import { EntityProvider } from '@backstage/plugin-catalog-react'; import { wrapInTestApp } from '@backstage/test-utils'; import { splunkOnCallApiRef, @@ -71,35 +71,27 @@ const apis = ApiRegistry.from([ ], ]); -const mockEntityData = { - loading: false, - error: undefined, - entity: { - apiVersion: 'backstage.io/v1alpha1', - kind: 'Component', - metadata: { - name: 'splunkoncall-test', - annotations: { - 'splunk.com/on-call-team': 'test', - }, +const mockEntity = { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Component', + metadata: { + name: 'splunkoncall-test', + annotations: { + 'splunk.com/on-call-team': 'test', }, - } as Entity, -}; + }, +} as Entity; -const mockEntityDataNoIncidents = { - loading: false, - error: undefined, - entity: { - apiVersion: 'backstage.io/v1alpha1', - kind: 'Component', - metadata: { - name: 'splunkoncall-test', - annotations: { - 'splunk.com/on-call-team': 'test-noincidents', - }, +const mockEntityNoIncidents = { + apiVersion: 'backstage.io/v1alpha1', + kind: 'Component', + metadata: { + name: 'splunkoncall-test', + annotations: { + 'splunk.com/on-call-team': 'test-noincidents', }, - } as Entity, -}; + }, +} as Entity; describe('SplunkOnCallCard', () => { it('Render splunkoncall', async () => { @@ -113,9 +105,9 @@ describe('SplunkOnCallCard', () => { const { getByText, queryByTestId } = render( wrapInTestApp( - + - + , ), ); @@ -136,9 +128,9 @@ describe('SplunkOnCallCard', () => { const { getByText, queryByTestId } = render( wrapInTestApp( - + - + , ), ); @@ -155,9 +147,9 @@ describe('SplunkOnCallCard', () => { const { getByText, queryByTestId } = render( wrapInTestApp( - + - + , ), ); @@ -181,9 +173,9 @@ describe('SplunkOnCallCard', () => { const { getByText, queryByTestId } = render( wrapInTestApp( - + - + , ), ); @@ -204,9 +196,9 @@ describe('SplunkOnCallCard', () => { const { getByText, queryByTestId, getByRole } = render( wrapInTestApp( - + - + , ), );