content.spec.tsx 5.9 KB

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