refactor tests to use renderInTestApp
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user