refactor tests to use renderInTestApp

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-12-31 19:14:29 +01:00
parent db2e137744
commit 0f50c7c754
18 changed files with 234 additions and 401 deletions
@@ -16,10 +16,8 @@
import { ErrorCell } from './ErrorCell';
import React from 'react';
import { render } from '@testing-library/react';
import mockIssue from '../../api/mock/sentry-issue-mock.json';
import { ThemeProvider } from '@material-ui/core';
import { lightTheme } from '@backstage/theme';
import { renderInTestApp } from '@backstage/test-utils';
describe('Sentry error cell component', () => {
it('should render a link that lead to Sentry', async () => {
@@ -33,11 +31,7 @@ describe('Sentry error cell component', () => {
userCount: 2,
permalink: 'http://example.com',
};
const cell = render(
<ThemeProvider theme={lightTheme}>
<ErrorCell sentryIssue={testIssue} />
</ThemeProvider>,
);
const cell = await renderInTestApp(<ErrorCell sentryIssue={testIssue} />);
const errorType = await cell.findByText('Exception');
expect(errorType.closest('a')).toHaveAttribute(
'href',
@@ -53,11 +47,7 @@ describe('Sentry error cell component', () => {
userCount: 2,
permalink: 'http://example.com',
};
const cell = render(
<ThemeProvider theme={lightTheme}>
<ErrorCell sentryIssue={testIssue} />
</ThemeProvider>,
);
const cell = await renderInTestApp(<ErrorCell sentryIssue={testIssue} />);
const errorType = await cell.findByText('Exception: Could not load cr...');
expect(errorType.closest('a')).toHaveAttribute(
'href',
@@ -15,12 +15,10 @@
*/
import React from 'react';
import { render } from '@testing-library/react';
import SentryIssuesTable from './SentryIssuesTable';
import { SentryIssue } from '../../api';
import mockIssue from '../../api/mock/sentry-issue-mock.json';
import { ThemeProvider } from '@material-ui/core';
import { lightTheme } from '@backstage/theme';
import { renderInTestApp } from '@backstage/test-utils';
describe('SentryIssuesTable', () => {
it('should render headers in a table', async () => {
@@ -35,19 +33,17 @@ describe('SentryIssuesTable', () => {
userCount: 2,
},
];
const table = await render(
<ThemeProvider theme={lightTheme}>
<SentryIssuesTable
sentryIssues={issues}
statsFor="24h"
tableOptions={{
padding: 'dense',
paging: true,
search: false,
pageSize: 5,
}}
/>
</ThemeProvider>,
const table = await renderInTestApp(
<SentryIssuesTable
sentryIssues={issues}
statsFor="24h"
tableOptions={{
padding: 'dense',
paging: true,
search: false,
pageSize: 5,
}}
/>,
);
expect(await table.findByText('Error')).toBeInTheDocument();
expect(await table.findByText('Graph')).toBeInTheDocument();
@@ -68,19 +64,17 @@ describe('SentryIssuesTable', () => {
userCount: 202,
},
];
const table = await render(
<ThemeProvider theme={lightTheme}>
<SentryIssuesTable
sentryIssues={issues}
statsFor="24h"
tableOptions={{
padding: 'dense',
paging: true,
search: false,
pageSize: 5,
}}
/>
</ThemeProvider>,
const table = await renderInTestApp(
<SentryIssuesTable
sentryIssues={issues}
statsFor="24h"
tableOptions={{
padding: 'dense',
paging: true,
search: false,
pageSize: 5,
}}
/>,
);
expect(await table.findByText('Exception')).toBeInTheDocument();
expect(await table.findByText('exception was thrown')).toBeInTheDocument();
@@ -99,19 +93,17 @@ describe('SentryIssuesTable', () => {
userCount: 202,
},
];
const table = await render(
<ThemeProvider theme={lightTheme}>
<SentryIssuesTable
sentryIssues={issues}
statsFor="24h"
tableOptions={{
padding: 'dense',
paging: true,
search: false,
pageSize: 5,
}}
/>
</ThemeProvider>,
const table = await renderInTestApp(
<SentryIssuesTable
sentryIssues={issues}
statsFor="24h"
tableOptions={{
padding: 'dense',
paging: true,
search: false,
pageSize: 5,
}}
/>,
);
expect(await table.findByText('Last 24h')).toBeInTheDocument();
});