content.spec.tsx 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import EventView from 'sentry/utils/discover/eventView';
  4. import {SpanOperationBreakdownFilter} from 'sentry/views/performance/transactionSummary/filter';
  5. import SummaryContent from 'sentry/views/performance/transactionSummary/transactionOverview/content';
  6. function initialize(projects, query, additionalFeatures: string[] = []) {
  7. const features = ['transaction-event', 'performance-view', ...additionalFeatures];
  8. const organization = TestStubs.Organization({
  9. features,
  10. projects,
  11. });
  12. const initialOrgData = {
  13. organization,
  14. router: {
  15. location: {
  16. query: {...query},
  17. },
  18. },
  19. project: 1,
  20. projects: [],
  21. };
  22. const initialData = initializeOrg(initialOrgData);
  23. const eventView = EventView.fromNewQueryWithLocation(
  24. {
  25. id: undefined,
  26. version: 2,
  27. name: 'test-transaction',
  28. fields: ['id', 'user.display', 'transaction.duration', 'trace', 'timestamp'],
  29. projects: [],
  30. },
  31. initialData.router.location
  32. );
  33. const spanOperationBreakdownFilter = SpanOperationBreakdownFilter.None;
  34. const transactionName = 'example-transaction';
  35. return {
  36. ...initialData,
  37. spanOperationBreakdownFilter,
  38. transactionName,
  39. location: initialData.router.location,
  40. eventView,
  41. };
  42. }
  43. describe('Transaction Summary Content', function () {
  44. beforeEach(function () {
  45. MockApiClient.addMockResponse({
  46. method: 'GET',
  47. url: '/prompts-activity/',
  48. body: {},
  49. });
  50. MockApiClient.addMockResponse({
  51. url: '/organizations/org-slug/sdk-updates/',
  52. body: [],
  53. });
  54. MockApiClient.addMockResponse({
  55. url: '/organizations/org-slug/eventsv2/',
  56. body: {data: [{'event.type': 'error'}], meta: {'event.type': 'string'}},
  57. });
  58. MockApiClient.addMockResponse({
  59. url: '/organizations/org-slug/users/',
  60. body: [],
  61. });
  62. MockApiClient.addMockResponse({
  63. url: '/organizations/org-slug/issues/?limit=5&query=is%3Aunresolved%20transaction%3Aexample-transaction&sort=new&statsPeriod=14d',
  64. body: [],
  65. });
  66. MockApiClient.addMockResponse({
  67. url: '/organizations/org-slug/events-facets/',
  68. body: [],
  69. });
  70. MockApiClient.addMockResponse({
  71. url: '/organizations/org-slug/releases/stats/',
  72. body: [],
  73. });
  74. MockApiClient.addMockResponse({
  75. url: '/organizations/org-slug/events-stats/',
  76. body: [],
  77. });
  78. MockApiClient.addMockResponse({
  79. url: '/organizations/org-slug/events-facets-performance/',
  80. body: {},
  81. });
  82. MockApiClient.addMockResponse({
  83. url: '/organizations/org-slug/events-has-measurements/',
  84. body: {measurements: false},
  85. });
  86. });
  87. afterEach(function () {
  88. MockApiClient.clearMockResponses();
  89. });
  90. it('Basic Rendering', async function () {
  91. const projects = [TestStubs.Project()];
  92. const {
  93. organization,
  94. location,
  95. eventView,
  96. spanOperationBreakdownFilter,
  97. transactionName,
  98. } = initialize(projects, {});
  99. const routerContext = TestStubs.routerContext([{organization}]);
  100. const wrapper = mountWithTheme(
  101. <SummaryContent
  102. location={location}
  103. organization={organization}
  104. eventView={eventView}
  105. transactionName={transactionName}
  106. isLoading={false}
  107. totalValues={null}
  108. spanOperationBreakdownFilter={spanOperationBreakdownFilter}
  109. error={null}
  110. onChangeFilter={() => {}}
  111. />,
  112. routerContext
  113. );
  114. await tick();
  115. wrapper.update();
  116. expect(wrapper.find('Filter')).toHaveLength(1);
  117. expect(wrapper.find('StyledSearchBar')).toHaveLength(1);
  118. expect(wrapper.find('TransactionSummaryCharts')).toHaveLength(1);
  119. expect(wrapper.find('TransactionsList')).toHaveLength(1);
  120. expect(wrapper.find('UserStats')).toHaveLength(1);
  121. expect(wrapper.find('StatusBreakdown')).toHaveLength(1);
  122. expect(wrapper.find('SidebarCharts')).toHaveLength(1);
  123. expect(wrapper.find('DiscoverQuery')).toHaveLength(2);
  124. const transactionListProps = wrapper.find('TransactionsList').first().props();
  125. expect(transactionListProps.generateDiscoverEventView).toBeDefined();
  126. expect(transactionListProps.handleOpenInDiscoverClick).toBeDefined();
  127. expect(transactionListProps.generatePerformanceTransactionEventsView).toBeUndefined();
  128. expect(transactionListProps.handleOpenAllEventsClick).toBeUndefined();
  129. });
  130. it('Renders with generatePerformanceTransactionEventsView instead when feature flagged', async function () {
  131. const projects = [TestStubs.Project()];
  132. const {
  133. organization,
  134. location,
  135. eventView,
  136. spanOperationBreakdownFilter,
  137. transactionName,
  138. } = initialize(projects, {}, ['performance-events-page']);
  139. const routerContext = TestStubs.routerContext([{organization}]);
  140. const wrapper = mountWithTheme(
  141. <SummaryContent
  142. location={location}
  143. organization={organization}
  144. eventView={eventView}
  145. transactionName={transactionName}
  146. isLoading={false}
  147. totalValues={null}
  148. spanOperationBreakdownFilter={spanOperationBreakdownFilter}
  149. error={null}
  150. onChangeFilter={() => {}}
  151. />,
  152. routerContext
  153. );
  154. await tick();
  155. wrapper.update();
  156. expect(wrapper.find('Filter')).toHaveLength(1);
  157. expect(wrapper.find('StyledSearchBar')).toHaveLength(1);
  158. expect(wrapper.find('TransactionSummaryCharts')).toHaveLength(1);
  159. expect(wrapper.find('TransactionsList')).toHaveLength(1);
  160. expect(wrapper.find('UserStats')).toHaveLength(1);
  161. expect(wrapper.find('StatusBreakdown')).toHaveLength(1);
  162. expect(wrapper.find('SidebarCharts')).toHaveLength(1);
  163. expect(wrapper.find('DiscoverQuery')).toHaveLength(2);
  164. const transactionListProps = wrapper.find('TransactionsList').first().props();
  165. expect(transactionListProps.generateDiscoverEventView).toBeUndefined();
  166. expect(transactionListProps.handleOpenInDiscoverClick).toBeUndefined();
  167. expect(transactionListProps.generatePerformanceTransactionEventsView).toBeDefined();
  168. expect(transactionListProps.handleOpenAllEventsClick).toBeDefined();
  169. });
  170. it('Renders TransactionSummaryCharts withoutZerofill when feature flagged', async function () {
  171. const projects = [TestStubs.Project()];
  172. const {
  173. organization,
  174. location,
  175. eventView,
  176. spanOperationBreakdownFilter,
  177. transactionName,
  178. } = initialize(projects, {}, [
  179. 'performance-events-page',
  180. 'performance-chart-interpolation',
  181. ]);
  182. const routerContext = TestStubs.routerContext([{organization}]);
  183. const wrapper = mountWithTheme(
  184. <SummaryContent
  185. location={location}
  186. organization={organization}
  187. eventView={eventView}
  188. transactionName={transactionName}
  189. isLoading={false}
  190. totalValues={null}
  191. spanOperationBreakdownFilter={spanOperationBreakdownFilter}
  192. error={null}
  193. onChangeFilter={() => {}}
  194. />,
  195. routerContext
  196. );
  197. await tick();
  198. wrapper.update();
  199. expect(wrapper.find('TransactionSummaryCharts')).toHaveLength(1);
  200. const transactionSummaryChartsProps = wrapper
  201. .find('TransactionSummaryCharts')
  202. .first()
  203. .props();
  204. expect(transactionSummaryChartsProps.withoutZerofill).toEqual(true);
  205. });
  206. });