errorsAndTransactions.spec.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {UserFixture} from 'sentry-fixture/user';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import EventView, {EventViewOptions} from 'sentry/utils/discover/eventView';
  6. import {getCustomEventsFieldRenderer} from 'sentry/views/dashboards/datasetConfig/errorsAndTransactions';
  7. describe('getCustomFieldRenderer', function () {
  8. const {organization, router, routerContext} = initializeOrg();
  9. const baseEventViewOptions: EventViewOptions = {
  10. start: undefined,
  11. end: undefined,
  12. createdBy: UserFixture(),
  13. display: undefined,
  14. fields: [],
  15. sorts: [],
  16. query: '',
  17. project: [],
  18. environment: [],
  19. yAxis: 'count()',
  20. id: undefined,
  21. name: undefined,
  22. statsPeriod: '14d',
  23. team: [],
  24. topEvents: undefined,
  25. };
  26. it('links trace ids to performance', async function () {
  27. const customFieldRenderer = getCustomEventsFieldRenderer('trace', {});
  28. render(
  29. customFieldRenderer(
  30. {trace: 'abcd'},
  31. {
  32. organization,
  33. location: router.location,
  34. eventView: new EventView({
  35. ...baseEventViewOptions,
  36. fields: [{field: 'trace'}],
  37. }),
  38. }
  39. ) as React.ReactElement<any, any>,
  40. {context: routerContext}
  41. );
  42. await userEvent.click(await screen.findByText('abcd'));
  43. expect(router.push).toHaveBeenCalledWith({
  44. pathname: '/organizations/org-slug/performance/trace/abcd/',
  45. query: {
  46. pageEnd: undefined,
  47. pageStart: undefined,
  48. statsPeriod: '14d',
  49. },
  50. });
  51. });
  52. it('links event ids to event details', async function () {
  53. const project = ProjectFixture();
  54. const customFieldRenderer = getCustomEventsFieldRenderer('id', {});
  55. render(
  56. customFieldRenderer(
  57. {id: 'defg', 'project.name': project.slug},
  58. {
  59. organization,
  60. location: router.location,
  61. eventView: new EventView({
  62. ...baseEventViewOptions,
  63. fields: [{field: 'id'}],
  64. project: [parseInt(project.id, 10)],
  65. }),
  66. }
  67. ) as React.ReactElement<any, any>,
  68. {context: routerContext}
  69. );
  70. await userEvent.click(await screen.findByText('defg'));
  71. expect(router.push).toHaveBeenCalledWith({
  72. pathname: `/organizations/org-slug/discover/${project.slug}:defg/`,
  73. query: {
  74. display: undefined,
  75. environment: [],
  76. field: ['id'],
  77. id: undefined,
  78. interval: undefined,
  79. name: undefined,
  80. project: [parseInt(project.id, 10)],
  81. query: '',
  82. sort: [],
  83. topEvents: undefined,
  84. widths: [],
  85. yAxis: 'count()',
  86. pageEnd: undefined,
  87. pageStart: undefined,
  88. statsPeriod: '14d',
  89. },
  90. });
  91. });
  92. it('links << unparameterized >> title/transaction columns to event details', async function () {
  93. const project = ProjectFixture();
  94. const customFieldRenderer = getCustomEventsFieldRenderer('title', {});
  95. render(
  96. customFieldRenderer(
  97. {title: '<< unparameterized >>'},
  98. {
  99. organization,
  100. location: router.location,
  101. eventView: new EventView({
  102. ...baseEventViewOptions,
  103. fields: [{field: 'id'}],
  104. project: [parseInt(project.id, 10)],
  105. }),
  106. }
  107. ) as React.ReactElement<any, any>,
  108. {context: routerContext}
  109. );
  110. await userEvent.click(await screen.findByText('<< unparameterized >>'));
  111. expect(router.push).toHaveBeenCalledWith(
  112. expect.objectContaining({
  113. pathname: `/organizations/org-slug/discover/results/`,
  114. query: expect.objectContaining({
  115. query: 'event.type:transaction transaction.source:"url"',
  116. }),
  117. })
  118. );
  119. });
  120. });