errorsAndTransactions.spec.jsx 3.0 KB

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