content.spec.tsx 5.6 KB

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