content.spec.tsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import {InjectedRouter} from 'react-router';
  2. import {Organization} from 'sentry-fixture/organization';
  3. import RouterContextFixture from 'sentry-fixture/routerContextFixture';
  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 = Organization({
  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: '/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=new&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. });
  130. afterEach(function () {
  131. MockApiClient.clearMockResponses();
  132. });
  133. it('performs basic rendering', function () {
  134. const project = TestStubs.Project();
  135. const {
  136. organization,
  137. location,
  138. eventView,
  139. spanOperationBreakdownFilter,
  140. transactionName,
  141. router,
  142. } = initialize(project, {});
  143. const routerContext = RouterContextFixture([{organization}]);
  144. render(
  145. <WrappedComponent
  146. location={location}
  147. organization={organization}
  148. eventView={eventView}
  149. projectId={project.id}
  150. transactionName={transactionName}
  151. isLoading={false}
  152. totalValues={null}
  153. spanOperationBreakdownFilter={spanOperationBreakdownFilter}
  154. error={null}
  155. onChangeFilter={() => {}}
  156. router={router}
  157. />,
  158. {context: routerContext}
  159. );
  160. expect(screen.getByTestId('page-filter-environment-selector')).toBeInTheDocument();
  161. expect(screen.getByTestId('page-filter-timerange-selector')).toBeInTheDocument();
  162. expect(screen.getByTestId('smart-search-bar')).toBeInTheDocument();
  163. expect(screen.getByTestId('transaction-summary-charts')).toBeInTheDocument();
  164. expect(screen.getByRole('heading', {name: /user misery/i})).toBeInTheDocument();
  165. expect(screen.getByRole('heading', {name: /status breakdown/i})).toBeInTheDocument();
  166. expect(screen.getByRole('heading', {name: /apdex/i})).toBeInTheDocument();
  167. expect(screen.getByTestId('apdex-summary-value')).toBeInTheDocument();
  168. expect(screen.getByRole('heading', {name: /failure rate/i})).toBeInTheDocument();
  169. expect(screen.getByTestId('failure-rate-summary-value')).toBeInTheDocument();
  170. });
  171. });