123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- import {mountWithTheme, shallow} from 'sentry-test/enzyme';
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import EventOrGroupHeader from 'app/components/eventOrGroupHeader';
- const data = {
- metadata: {
- type: 'metadata type',
- directive: 'metadata directive',
- uri: 'metadata uri',
- value: 'metadata value',
- message: 'metadata message',
- },
- culprit: 'culprit',
- };
- describe('EventOrGroupHeader', function () {
- const {routerContext} = initializeOrg();
- describe('Group', function () {
- const groupData = {
- ...data,
- level: 'error',
- id: 'id',
- };
- it('renders with `type = error`', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- orgId="orgId"
- data={{
- ...groupData,
- type: 'error',
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('renders with `type = csp`', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...groupData,
- ...{
- type: 'csp',
- },
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('renders with `type = default`', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...groupData,
- type: 'default',
- metadata: {
- ...groupData.metadata,
- title: 'metadata title',
- },
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('renders metadata values in message for error events', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...groupData,
- type: 'error',
- }}
- />,
- routerContext
- );
- const message = component.find('Message');
- expect(message.text()).toEqual('metadata value');
- });
- it('renders location', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- metadata: {
- filename: 'path/to/file.swift',
- },
- platform: 'swift',
- type: 'error',
- }}
- />,
- routerContext
- );
- const location = component.find('Location');
- expect(location.text()).toEqual('in path/to/file.swift');
- });
- });
- describe('Event', function () {
- const eventData = {
- ...data,
- id: 'id',
- eventID: 'eventID',
- groupID: 'groupID',
- culprit: undefined,
- };
- it('renders with `type = error`', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...eventData,
- type: 'error',
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('renders with `type = csp`', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...eventData,
- type: 'csp',
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('renders with `type = default`', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...eventData,
- type: 'default',
- metadata: {
- ...eventData.metadata,
- title: 'metadata title',
- },
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('hides level tag', function () {
- const component = mountWithTheme(
- <EventOrGroupHeader
- projectId="projectId"
- hideLevel
- data={{
- ...eventData,
- type: 'default',
- metadata: {
- ...eventData.metadata,
- title: 'metadata title',
- },
- }}
- />,
- routerContext
- );
- expect(component).toSnapshot();
- });
- it('keeps sort in link when query has sort', function () {
- const query = {
- sort: 'freq',
- };
- const component = shallow(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...eventData,
- type: 'default',
- }}
- location={{query}}
- />
- );
- const title = component.dive().dive().instance().getTitle();
- expect(title.props.to.query.sort).toEqual('freq');
- });
- it('lack of project adds allp parameter', function () {
- const query = {};
- const component = shallow(
- <EventOrGroupHeader
- params={{orgId: 'orgId'}}
- data={{
- ...eventData,
- type: 'default',
- }}
- location={{query}}
- />
- );
- const title = component.dive().dive().instance().getTitle();
- expect(title.props.to.query._allp).toEqual(1);
- });
- });
- });
|