spanOperationTable.spec.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import usePageFilters from 'sentry/utils/usePageFilters';
  3. import {Referrer} from 'sentry/views/performance/mobile/ui/referrers';
  4. import {SpanOperationTable} from 'sentry/views/performance/mobile/ui/screenSummary/spanOperationTable';
  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(screen.getAllByRole('columnheader', {name: 'Change'})).toHaveLength(3);
  49. expect(spanOpTableRequestMock).toHaveBeenCalledTimes(1);
  50. expect(spanOpTableRequestMock).toHaveBeenCalledWith(
  51. '/organizations/org-slug/events/',
  52. expect.objectContaining({
  53. query: expect.objectContaining({
  54. field: [
  55. 'project.id',
  56. 'span.op',
  57. 'span.group',
  58. 'span.description',
  59. 'avg_if(mobile.slow_frames,release,foo)',
  60. 'avg_if(mobile.slow_frames,release,bar)',
  61. 'avg_compare(mobile.slow_frames,release,foo,bar)',
  62. 'avg_if(mobile.frozen_frames,release,foo)',
  63. 'avg_if(mobile.frozen_frames,release,bar)',
  64. 'avg_compare(mobile.frozen_frames,release,foo,bar)',
  65. 'avg_if(mobile.frames_delay,release,foo)',
  66. 'avg_if(mobile.frames_delay,release,bar)',
  67. 'avg_compare(mobile.frames_delay,release,foo,bar)',
  68. ],
  69. }),
  70. })
  71. );
  72. });
  73. });