|
@@ -1,7 +1,11 @@
|
|
|
|
+import {FC} from 'react';
|
|
|
|
+
|
|
|
|
+import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
import {render, screen} from 'sentry-test/reactTestingLibrary';
|
|
import {render, screen} from 'sentry-test/reactTestingLibrary';
|
|
|
|
|
|
import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
|
|
import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
|
|
import {BaseGroup, EventOrGroupType, IssueCategory} from 'sentry/types';
|
|
import {BaseGroup, EventOrGroupType, IssueCategory} from 'sentry/types';
|
|
|
|
+import {OrganizationContext} from 'sentry/views/organizationContext';
|
|
|
|
|
|
describe('EventOrGroupTitle', function () {
|
|
describe('EventOrGroupTitle', function () {
|
|
const data = {
|
|
const data = {
|
|
@@ -13,18 +17,28 @@ describe('EventOrGroupTitle', function () {
|
|
culprit: 'culprit',
|
|
culprit: 'culprit',
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const {organization} = initializeOrg();
|
|
|
|
+
|
|
|
|
+ const TestComponent: FC = ({children}) => (
|
|
|
|
+ <OrganizationContext.Provider value={organization}>
|
|
|
|
+ {children}
|
|
|
|
+ </OrganizationContext.Provider>
|
|
|
|
+ );
|
|
|
|
+
|
|
it('renders with subtitle when `type = error`', function () {
|
|
it('renders with subtitle when `type = error`', function () {
|
|
const wrapper = render(
|
|
const wrapper = render(
|
|
- <EventOrGroupTitle
|
|
|
|
- data={
|
|
|
|
- {
|
|
|
|
- ...data,
|
|
|
|
- ...{
|
|
|
|
- type: EventOrGroupType.ERROR,
|
|
|
|
- },
|
|
|
|
- } as BaseGroup
|
|
|
|
- }
|
|
|
|
- />
|
|
|
|
|
|
+ <TestComponent>
|
|
|
|
+ <EventOrGroupTitle
|
|
|
|
+ data={
|
|
|
|
+ {
|
|
|
|
+ ...data,
|
|
|
|
+ ...{
|
|
|
|
+ type: EventOrGroupType.ERROR,
|
|
|
|
+ },
|
|
|
|
+ } as BaseGroup
|
|
|
|
+ }
|
|
|
|
+ />
|
|
|
|
+ </TestComponent>
|
|
);
|
|
);
|
|
|
|
|
|
expect(wrapper.container).toSnapshot();
|
|
expect(wrapper.container).toSnapshot();
|
|
@@ -32,16 +46,18 @@ describe('EventOrGroupTitle', function () {
|
|
|
|
|
|
it('renders with subtitle when `type = csp`', function () {
|
|
it('renders with subtitle when `type = csp`', function () {
|
|
const wrapper = render(
|
|
const wrapper = render(
|
|
- <EventOrGroupTitle
|
|
|
|
- data={
|
|
|
|
- {
|
|
|
|
- ...data,
|
|
|
|
- ...{
|
|
|
|
- type: EventOrGroupType.CSP,
|
|
|
|
- },
|
|
|
|
- } as BaseGroup
|
|
|
|
- }
|
|
|
|
- />
|
|
|
|
|
|
+ <TestComponent>
|
|
|
|
+ <EventOrGroupTitle
|
|
|
|
+ data={
|
|
|
|
+ {
|
|
|
|
+ ...data,
|
|
|
|
+ ...{
|
|
|
|
+ type: EventOrGroupType.CSP,
|
|
|
|
+ },
|
|
|
|
+ } as BaseGroup
|
|
|
|
+ }
|
|
|
|
+ />
|
|
|
|
+ </TestComponent>
|
|
);
|
|
);
|
|
|
|
|
|
expect(wrapper.container).toSnapshot();
|
|
expect(wrapper.container).toSnapshot();
|
|
@@ -49,18 +65,20 @@ describe('EventOrGroupTitle', function () {
|
|
|
|
|
|
it('renders with no subtitle when `type = default`', function () {
|
|
it('renders with no subtitle when `type = default`', function () {
|
|
const wrapper = render(
|
|
const wrapper = render(
|
|
- <EventOrGroupTitle
|
|
|
|
- data={
|
|
|
|
- {
|
|
|
|
- ...data,
|
|
|
|
- type: EventOrGroupType.DEFAULT,
|
|
|
|
- metadata: {
|
|
|
|
- ...data.metadata,
|
|
|
|
- title: 'metadata title',
|
|
|
|
- },
|
|
|
|
- } as BaseGroup
|
|
|
|
- }
|
|
|
|
- />
|
|
|
|
|
|
+ <TestComponent>
|
|
|
|
+ <EventOrGroupTitle
|
|
|
|
+ data={
|
|
|
|
+ {
|
|
|
|
+ ...data,
|
|
|
|
+ type: EventOrGroupType.DEFAULT,
|
|
|
|
+ metadata: {
|
|
|
|
+ ...data.metadata,
|
|
|
|
+ title: 'metadata title',
|
|
|
|
+ },
|
|
|
|
+ } as BaseGroup
|
|
|
|
+ }
|
|
|
|
+ />
|
|
|
|
+ </TestComponent>
|
|
);
|
|
);
|
|
|
|
|
|
expect(wrapper.container).toSnapshot();
|
|
expect(wrapper.container).toSnapshot();
|
|
@@ -72,18 +90,20 @@ describe('EventOrGroupTitle', function () {
|
|
]);
|
|
]);
|
|
|
|
|
|
render(
|
|
render(
|
|
- <EventOrGroupTitle
|
|
|
|
- data={
|
|
|
|
- {
|
|
|
|
- ...data,
|
|
|
|
- type: EventOrGroupType.ERROR,
|
|
|
|
- metadata: {
|
|
|
|
- ...data.metadata,
|
|
|
|
- title: 'metadata title',
|
|
|
|
- },
|
|
|
|
- } as BaseGroup
|
|
|
|
- }
|
|
|
|
- />,
|
|
|
|
|
|
+ <TestComponent>
|
|
|
|
+ <EventOrGroupTitle
|
|
|
|
+ data={
|
|
|
|
+ {
|
|
|
|
+ ...data,
|
|
|
|
+ type: EventOrGroupType.ERROR,
|
|
|
|
+ metadata: {
|
|
|
|
+ ...data.metadata,
|
|
|
|
+ title: 'metadata title',
|
|
|
|
+ },
|
|
|
|
+ } as BaseGroup
|
|
|
|
+ }
|
|
|
|
+ />
|
|
|
|
+ </TestComponent>,
|
|
{context: routerContext}
|
|
{context: routerContext}
|
|
);
|
|
);
|
|
|
|
|
|
@@ -92,15 +112,17 @@ describe('EventOrGroupTitle', function () {
|
|
|
|
|
|
it('does not render stack trace when issueCategory is performance', () => {
|
|
it('does not render stack trace when issueCategory is performance', () => {
|
|
render(
|
|
render(
|
|
- <EventOrGroupTitle
|
|
|
|
- data={
|
|
|
|
- {
|
|
|
|
- ...data,
|
|
|
|
- issueCategory: IssueCategory.PERFORMANCE,
|
|
|
|
- } as BaseGroup
|
|
|
|
- }
|
|
|
|
- withStackTracePreview
|
|
|
|
- />
|
|
|
|
|
|
+ <TestComponent>
|
|
|
|
+ <EventOrGroupTitle
|
|
|
|
+ data={
|
|
|
|
+ {
|
|
|
|
+ ...data,
|
|
|
|
+ issueCategory: IssueCategory.PERFORMANCE,
|
|
|
|
+ } as BaseGroup
|
|
|
|
+ }
|
|
|
|
+ withStackTracePreview
|
|
|
|
+ />
|
|
|
|
+ </TestComponent>
|
|
);
|
|
);
|
|
|
|
|
|
expect(screen.queryByTestId('stacktrace-preview')).not.toBeInTheDocument();
|
|
expect(screen.queryByTestId('stacktrace-preview')).not.toBeInTheDocument();
|
|
@@ -122,7 +144,12 @@ describe('EventOrGroupTitle', function () {
|
|
{organization: TestStubs.Organization({features: ['custom-event-title']})},
|
|
{organization: TestStubs.Organization({features: ['custom-event-title']})},
|
|
]);
|
|
]);
|
|
|
|
|
|
- render(<EventOrGroupTitle data={perfData} />, {context: routerContext});
|
|
|
|
|
|
+ render(
|
|
|
|
+ <TestComponent>
|
|
|
|
+ <EventOrGroupTitle data={perfData} />
|
|
|
|
+ </TestComponent>,
|
|
|
|
+ {context: routerContext}
|
|
|
|
+ );
|
|
|
|
|
|
expect(screen.getByText('N+1 Query')).toBeInTheDocument();
|
|
expect(screen.getByText('N+1 Query')).toBeInTheDocument();
|
|
expect(screen.getByText('transaction name')).toBeInTheDocument();
|
|
expect(screen.getByText('transaction name')).toBeInTheDocument();
|