Create a mock entity
Signed-off-by: Karan Shah <karan.shah@simplybusiness.co.uk>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { createDevApp } from '@backstage/dev-utils';
|
||||
import { EntityAirbrakeContent, airbrakePlugin } from '../src';
|
||||
import { airbrakePlugin, EntityAirbrakeContent } from '../src';
|
||||
import {
|
||||
Content,
|
||||
ContentHeader,
|
||||
@@ -25,6 +25,8 @@ import {
|
||||
SupportButton,
|
||||
} from '@backstage/core-components';
|
||||
import { airbrakeApiRef, MockAirbrakeApi } from '../src/api';
|
||||
import { EntityProvider } from '@backstage/plugin-catalog-react';
|
||||
import { entity } from '../src/api/mock/mock-entity';
|
||||
|
||||
createDevApp()
|
||||
.registerPlugin(airbrakePlugin)
|
||||
@@ -49,7 +51,9 @@ createDevApp()
|
||||
A description of your plugin goes here.
|
||||
</SupportButton>
|
||||
</ContentHeader>
|
||||
<EntityAirbrakeContent />
|
||||
<EntityProvider entity={entity('demo')}>
|
||||
<EntityAirbrakeContent />
|
||||
</EntityProvider>
|
||||
</Content>
|
||||
</Page>
|
||||
),
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { AIRBRAKE_PROJECT_SLUG_ANNOTATION } from '../../components/useProjectSlug';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
|
||||
export const entity = (name?: string) =>
|
||||
({
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
annotations: {
|
||||
[AIRBRAKE_PROJECT_SLUG_ANNOTATION]: name,
|
||||
},
|
||||
name: name,
|
||||
},
|
||||
} as Entity);
|
||||
@@ -18,22 +18,9 @@ import React from 'react';
|
||||
import { EntityAirbrakeWidget } from './EntityAirbrakeWidget';
|
||||
import exampleData from '../../api/mock/airbrake-groups-api-mock.json';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import { AIRBRAKE_PROJECT_SLUG_ANNOTATION } from '../useProjectSlug';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { entity } from '../../api/mock/mock-entity';
|
||||
|
||||
describe('EntityAirbrakeContent', () => {
|
||||
const entity = (name?: string) =>
|
||||
({
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
metadata: {
|
||||
annotations: {
|
||||
[AIRBRAKE_PROJECT_SLUG_ANNOTATION]: name,
|
||||
},
|
||||
name: name,
|
||||
},
|
||||
} as Entity);
|
||||
|
||||
it('renders all errors sent from Airbrake', async () => {
|
||||
const table = await renderInTestApp(
|
||||
<EntityAirbrakeWidget entity={entity('test')} />,
|
||||
|
||||
@@ -27,11 +27,10 @@ export const EntityAirbrakeContent = airbrakePlugin.provide(
|
||||
component: () =>
|
||||
import('./components/EntityAirbrakeWidget').then(
|
||||
({ EntityAirbrakeWidget }) => {
|
||||
const AirbrakePage = () => {
|
||||
return () => {
|
||||
const { entity } = useEntity();
|
||||
return <EntityAirbrakeWidget entity={entity} />;
|
||||
};
|
||||
return AirbrakePage;
|
||||
},
|
||||
),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user