content.spec.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import type {InjectedRouter} from 'react-router';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {initializeOrg} from 'sentry-test/initializeOrg';
  5. import {render, screen} from 'sentry-test/reactTestingLibrary';
  6. import EventView from 'sentry/utils/discover/eventView';
  7. import {MEPSettingProvider} from 'sentry/utils/performance/contexts/metricsEnhancedSetting';
  8. import {SpanOperationBreakdownFilter} from 'sentry/views/performance/transactionSummary/filter';
  9. import SummaryContent from 'sentry/views/performance/transactionSummary/transactionOverview/content';
  10. function initialize(project, query, additionalFeatures: string[] = []) {
  11. const features = ['transaction-event', 'performance-view', ...additionalFeatures];
  12. const organization = OrganizationFixture({
  13. features,
  14. projects: [project],
  15. });
  16. const initialData = initializeOrg({
  17. organization,
  18. router: {
  19. location: {
  20. query: {...query},
  21. },
  22. },
  23. projects: [],
  24. });
  25. const eventView = EventView.fromNewQueryWithLocation(
  26. {
  27. id: undefined,
  28. version: 2,
  29. name: 'test-transaction',
  30. fields: ['id', 'user.display', 'transaction.duration', 'trace', 'timestamp'],
  31. projects: [],
  32. },
  33. initialData.router.location
  34. );
  35. const spanOperationBreakdownFilter = SpanOperationBreakdownFilter.NONE;
  36. const transactionName = 'example-transaction';
  37. return {
  38. ...initialData,
  39. spanOperationBreakdownFilter,
  40. transactionName,
  41. location: initialData.router.location,
  42. eventView,
  43. };
  44. }
  45. function WrappedComponent({
  46. organization,
  47. ...props
  48. }: React.ComponentProps<typeof SummaryContent> & {
  49. router: InjectedRouter<Record<string, string>, any>;
  50. }) {
  51. return (
  52. <MEPSettingProvider>
  53. <SummaryContent organization={organization} {...props} />
  54. </MEPSettingProvider>
  55. );
  56. }
  57. describe('Transaction Summary Content', function () {
  58. beforeEach(function () {
  59. MockApiClient.addMockResponse({
  60. method: 'GET',
  61. url: '/organizations/org-slug/prompts-activity/',
  62. body: {},
  63. });
  64. MockApiClient.addMockResponse({
  65. url: '/organizations/org-slug/sdk-updates/',
  66. body: [],
  67. });
  68. MockApiClient.addMockResponse({
  69. url: '/organizations/org-slug/events/',
  70. body: {data: [{'event.type': 'error'}], meta: {fields: {'event.type': 'string'}}},
  71. });
  72. MockApiClient.addMockResponse({
  73. url: '/organizations/org-slug/users/',
  74. body: [],
  75. });
  76. MockApiClient.addMockResponse({
  77. url: '/organizations/org-slug/issues/?limit=5&query=is%3Aunresolved%20transaction%3Aexample-transaction&sort=trends&statsPeriod=14d',
  78. body: [],
  79. });
  80. MockApiClient.addMockResponse({
  81. url: '/organizations/org-slug/events-facets/',
  82. body: [],
  83. });
  84. MockApiClient.addMockResponse({
  85. url: '/organizations/org-slug/releases/stats/',
  86. body: [],
  87. });
  88. MockApiClient.addMockResponse({
  89. url: '/organizations/org-slug/events-stats/',
  90. body: [],
  91. });
  92. MockApiClient.addMockResponse({
  93. url: '/organizations/org-slug/events-facets-performance/',
  94. body: {},
  95. });
  96. MockApiClient.addMockResponse({
  97. url: '/organizations/org-slug/events-has-measurements/',
  98. body: {measurements: false},
  99. });
  100. MockApiClient.addMockResponse({
  101. url: '/organizations/org-slug/events-spans-performance/',
  102. body: [
  103. {
  104. op: 'ui.long-task',
  105. group: 'c777169faad84eb4',
  106. description: 'Main UI thread blocked',
  107. frequency: 713,
  108. count: 9040,
  109. avgOccurrences: null,
  110. sumExclusiveTime: 1743893.9822921753,
  111. p50ExclusiveTime: null,
  112. p75ExclusiveTime: 244.9998779296875,
  113. p95ExclusiveTime: null,
  114. p99ExclusiveTime: null,
  115. },
  116. ],
  117. });
  118. MockApiClient.addMockResponse({
  119. url: `/projects/org-slug/project-slug/profiling/functions/`,
  120. body: {functions: []},
  121. });
  122. MockApiClient.addMockResponse({
  123. url: '/organizations/org-slug/dynamic-sampling/custom-rules/',
  124. body: '',
  125. });
  126. });
  127. afterEach(function () {
  128. MockApiClient.clearMockResponses();
  129. });
  130. it('performs basic rendering', async function () {
  131. const project = ProjectFixture();
  132. const {
  133. organization,
  134. location,
  135. eventView,
  136. spanOperationBreakdownFilter,
  137. transactionName,
  138. router,
  139. } = initialize(project, {});
  140. render(
  141. <WrappedComponent
  142. location={location}
  143. organization={organization}
  144. eventView={eventView}
  145. projectId={project.id}
  146. transactionName={transactionName}
  147. isLoading={false}
  148. totalValues={null}
  149. spanOperationBreakdownFilter={spanOperationBreakdownFilter}
  150. error={null}
  151. onChangeFilter={() => {}}
  152. router={router}
  153. />,
  154. {router, organization}
  155. );
  156. expect(
  157. await screen.findByTestId('page-filter-environment-selector')
  158. ).toBeInTheDocument();
  159. expect(screen.getByTestId('page-filter-timerange-selector')).toBeInTheDocument();
  160. expect(screen.getByTestId('smart-search-bar')).toBeInTheDocument();
  161. expect(screen.getByTestId('transaction-summary-charts')).toBeInTheDocument();
  162. expect(screen.getByRole('heading', {name: /user misery/i})).toBeInTheDocument();
  163. expect(screen.getByRole('heading', {name: /status breakdown/i})).toBeInTheDocument();
  164. expect(screen.getByRole('heading', {name: /apdex/i})).toBeInTheDocument();
  165. expect(screen.getByTestId('apdex-summary-value')).toBeInTheDocument();
  166. expect(screen.getByRole('heading', {name: /failure rate/i})).toBeInTheDocument();
  167. expect(screen.getByTestId('failure-rate-summary-value')).toBeInTheDocument();
  168. });
  169. });