Fix AirbrakeWidget.test.tsx

Signed-off-by: Karan Shah <karan.shah@simplybusiness.co.uk>
This commit is contained in:
Karan Shah
2021-12-29 17:04:08 +00:00
parent d0d32eff64
commit 3e77697da0
4 changed files with 50 additions and 35 deletions
+25 -2
View File
@@ -15,12 +15,35 @@
*/
import React from 'react';
import { createDevApp } from '@backstage/dev-utils';
import { airbrakePlugin, AirbrakePage } from '../src/plugin';
import { AirbrakePage, airbrakePlugin } from '../src/plugin';
import {
Content,
ContentHeader,
Header,
HeaderLabel,
Page,
SupportButton,
} from '@backstage/core-components';
createDevApp()
.registerPlugin(airbrakePlugin)
.addPage({
element: <AirbrakePage />,
element: (
<Page themeId="tool">
<Header title="Airbrake" subtitle="Errors in your application">
<HeaderLabel label="Owner" value="Owner" />
<HeaderLabel label="Lifecycle" value="Alpha" />
</Header>
<Content>
<ContentHeader title="Airbrake">
<SupportButton>
A description of your plugin goes here.
</SupportButton>
</ContentHeader>
<AirbrakePage />
</Content>
</Page>
),
title: 'Root Page',
path: '/airbrake',
})
@@ -31,7 +31,7 @@ describe('AirbrakeWidget', () => {
expect(exampleData.groups.length).toBeGreaterThan(0);
for (const group of exampleData.groups) {
expect(
await table.findByText(group.errors[0].message),
await table.getByText(group.errors[0].message),
).toBeInTheDocument();
}
});
@@ -14,42 +14,35 @@
* limitations under the License.
*/
import React from 'react';
import { Typography, Grid } from '@material-ui/core';
import {
InfoCard,
Header,
Page,
Content,
ContentHeader,
HeaderLabel,
SupportButton,
} from '@backstage/core-components';
import { Grid, Typography } from '@material-ui/core';
import { InfoCard } from '@backstage/core-components';
import exampleData from './ExampleData';
import hash from 'object-hash';
import { makeStyles } from '@material-ui/core/styles';
import { BackstageTheme } from '@backstage/theme';
const useStyles = makeStyles<BackstageTheme>(() => ({
multilineText: {
whiteSpace: 'pre-wrap',
},
}));
export const AirbrakeWidget = () => {
const classes = useStyles();
return (
<Page themeId="tool">
<Header title="Airbrake" subtitle="Errors in your application">
<HeaderLabel label="Owner" value="Owner" />
<HeaderLabel label="Lifecycle" value="Alpha" />
</Header>
<Content>
<ContentHeader title="Airbrake">
<SupportButton>A description of your plugin goes here.</SupportButton>
</ContentHeader>
<Grid container spacing={3} direction="column">
{exampleData.groups.map(group => (
<Grid item key={group.id}>
{group.errors.map(error => (
<InfoCard title={error.type} key={hash(error)}>
<Typography variant="body1">{error.message}</Typography>
</InfoCard>
))}
</Grid>
<Grid container spacing={3} direction="column">
{exampleData.groups.map(group => (
<Grid item key={group.id}>
{group.errors.map(error => (
<InfoCard title={error.type} key={hash(error)}>
<Typography variant="body1" className={classes.multilineText}>
{error.message}
</Typography>
</InfoCard>
))}
</Grid>
</Content>
</Page>
))}
</Grid>
);
};
@@ -65,8 +65,7 @@ export default {
errors: [
{
type: 'ChunkLoadError',
message:
'Loading chunk 7764 failed.\n(error: https://example.com/static/react-syntax-highlighter/lowlight-import.9ac339f2.chunk.js)',
message: 'Loading chunk 7764 failed.',
backtrace: [
{
file: '/PROJECT_ROOT/static/runtime.069c874d.js',