spanOperationTable.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import usePageFilters from 'sentry/utils/usePageFilters';
  3. import {SpanOperationTable} from 'sentry/views/insights/mobile/ui/components/tables/spanOperationTable';
  4. import {Referrer} from 'sentry/views/insights/mobile/ui/referrers';
  5. jest.mock('sentry/utils/usePageFilters');
  6. jest.mocked(usePageFilters).mockReturnValue({
  7. isReady: true,
  8. desyncedFilters: new Set(),
  9. pinnedFilters: new Set(),
  10. shouldPersist: true,
  11. selection: {
  12. datetime: {
  13. period: '10d',
  14. start: null,
  15. end: null,
  16. utc: false,
  17. },
  18. environments: [],
  19. projects: [],
  20. },
  21. });
  22. describe('SpanOperationTable', () => {
  23. it('renders and fetches the proper data', () => {
  24. const spanOpTableRequestMock = MockApiClient.addMockResponse({
  25. url: '/organizations/org-slug/events/',
  26. body: [],
  27. match: [MockApiClient.matchQuery({referrer: Referrer.SPAN_OPERATION_TABLE})],
  28. });
  29. render(
  30. <SpanOperationTable
  31. transaction="transaction"
  32. primaryRelease="foo"
  33. secondaryRelease="bar"
  34. />
  35. );
  36. [
  37. 'Operation',
  38. 'Span Description',
  39. 'Slow (R1)',
  40. 'Slow (R2)',
  41. 'Frozen (R1)',
  42. 'Frozen (R2)',
  43. 'Delay (R1)',
  44. 'Delay (R2)',
  45. ].forEach(header => {
  46. expect(screen.getByRole('columnheader', {name: header})).toBeInTheDocument();
  47. });
  48. expect(spanOpTableRequestMock).toHaveBeenCalledTimes(1);
  49. expect(spanOpTableRequestMock).toHaveBeenCalledWith(
  50. '/organizations/org-slug/events/',
  51. expect.objectContaining({
  52. query: expect.objectContaining({
  53. field: [
  54. 'project.id',
  55. 'span.op',
  56. 'span.group',
  57. 'span.description',
  58. 'division_if(mobile.slow_frames,mobile.total_frames,release,foo)',
  59. 'division_if(mobile.slow_frames,mobile.total_frames,release,bar)',
  60. 'division_if(mobile.frozen_frames,mobile.total_frames,release,foo)',
  61. 'division_if(mobile.frozen_frames,mobile.total_frames,release,bar)',
  62. 'avg_if(mobile.frames_delay,release,foo)',
  63. 'avg_if(mobile.frames_delay,release,bar)',
  64. 'avg_compare(mobile.frames_delay,release,foo,bar)',
  65. ],
  66. }),
  67. })
  68. );
  69. });
  70. });