eventOrGroupTitle.spec.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
  3. import {BaseGroup, EventOrGroupType, IssueCategory} from 'sentry/types';
  4. describe('EventOrGroupTitle', function () {
  5. const data = {
  6. metadata: {
  7. type: 'metadata type',
  8. directive: 'metadata directive',
  9. uri: 'metadata uri',
  10. },
  11. culprit: 'culprit',
  12. };
  13. it('renders with subtitle when `type = error`', function () {
  14. const wrapper = render(
  15. <EventOrGroupTitle
  16. data={
  17. {
  18. ...data,
  19. ...{
  20. type: EventOrGroupType.ERROR,
  21. },
  22. } as BaseGroup
  23. }
  24. />
  25. );
  26. expect(wrapper.container).toSnapshot();
  27. });
  28. it('renders with subtitle when `type = csp`', function () {
  29. const wrapper = render(
  30. <EventOrGroupTitle
  31. data={
  32. {
  33. ...data,
  34. ...{
  35. type: EventOrGroupType.CSP,
  36. },
  37. } as BaseGroup
  38. }
  39. />
  40. );
  41. expect(wrapper.container).toSnapshot();
  42. });
  43. it('renders with no subtitle when `type = default`', function () {
  44. const wrapper = render(
  45. <EventOrGroupTitle
  46. data={
  47. {
  48. ...data,
  49. type: EventOrGroupType.DEFAULT,
  50. metadata: {
  51. ...data.metadata,
  52. title: 'metadata title',
  53. },
  54. } as BaseGroup
  55. }
  56. />
  57. );
  58. expect(wrapper.container).toSnapshot();
  59. });
  60. it('renders with title override', function () {
  61. const routerContext = TestStubs.routerContext([
  62. {organization: TestStubs.Organization({features: ['custom-event-title']})},
  63. ]);
  64. render(
  65. <EventOrGroupTitle
  66. data={
  67. {
  68. ...data,
  69. type: EventOrGroupType.ERROR,
  70. metadata: {
  71. ...data.metadata,
  72. title: 'metadata title',
  73. },
  74. } as BaseGroup
  75. }
  76. />,
  77. {context: routerContext}
  78. );
  79. expect(screen.getByText('metadata title')).toBeInTheDocument();
  80. });
  81. it('does not render stack trace when issueCategory is performance', () => {
  82. render(
  83. <EventOrGroupTitle
  84. data={
  85. {
  86. ...data,
  87. issueCategory: IssueCategory.PERFORMANCE,
  88. } as BaseGroup
  89. }
  90. withStackTracePreview
  91. />
  92. );
  93. expect(screen.queryByTestId('stacktrace-preview')).not.toBeInTheDocument();
  94. });
  95. describe('performance issue list', () => {
  96. const perfData = {
  97. title: 'Hello',
  98. type: EventOrGroupType.TRANSACTION,
  99. issueCategory: IssueCategory.PERFORMANCE,
  100. metadata: {
  101. title: 'N+1 Query',
  102. },
  103. culprit: 'transaction name',
  104. } as BaseGroup;
  105. it('should correctly render title', () => {
  106. const routerContext = TestStubs.routerContext([
  107. {organization: TestStubs.Organization({features: ['custom-event-title']})},
  108. ]);
  109. render(<EventOrGroupTitle data={perfData} />, {context: routerContext});
  110. expect(screen.getByText('N+1 Query')).toBeInTheDocument();
  111. expect(screen.getByText('transaction name')).toBeInTheDocument();
  112. });
  113. });
  114. });