screensOverviewTable.spec.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import type {Location} from 'history';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import EventView from 'sentry/utils/discover/eventView';
  6. import {useLocation} from 'sentry/utils/useLocation';
  7. import usePageFilters from 'sentry/utils/usePageFilters';
  8. import ScreensOverviewTable from 'sentry/views/insights/mobile/screens/components/screensOverviewTable';
  9. jest.mock('sentry/utils/useLocation');
  10. jest.mock('sentry/views/insights/common/utils/useModuleURL');
  11. jest.mock('sentry/utils/usePageFilters');
  12. describe('ScreensOverviewTable', () => {
  13. const organization = OrganizationFixture({
  14. features: ['insights-addon-modules', 'insights-mobile-screens-module'],
  15. });
  16. const project = ProjectFixture();
  17. const location = {
  18. action: 'PUSH',
  19. hash: '',
  20. key: '',
  21. pathname: '/organizations/org-slug/performance/mobile/mobile-screens',
  22. query: {
  23. project: project.id,
  24. },
  25. search: '',
  26. state: undefined,
  27. } as Location;
  28. jest.mocked(useLocation).mockReturnValue(location);
  29. jest.mocked(usePageFilters).mockReturnValue({
  30. isReady: true,
  31. desyncedFilters: new Set(),
  32. pinnedFilters: new Set(),
  33. shouldPersist: true,
  34. selection: {
  35. datetime: {
  36. period: '10d',
  37. start: null,
  38. end: null,
  39. utc: false,
  40. },
  41. environments: [],
  42. projects: [parseInt(project.id, 10)],
  43. },
  44. });
  45. const mockEventView = EventView.fromLocation(location);
  46. const mockData = {
  47. data: [
  48. {
  49. id: '1',
  50. transaction: 'Screen 01',
  51. 'avg(mobile.slow_frames)': 12,
  52. 'avg(mobile.frozen_frames)': 23,
  53. 'count()': 45,
  54. },
  55. ],
  56. meta: {
  57. fields: [],
  58. },
  59. };
  60. it('renders columns', async () => {
  61. render(
  62. <ScreensOverviewTable
  63. data={mockData}
  64. eventView={mockEventView}
  65. isLoading={false}
  66. pageLinks=""
  67. />,
  68. {
  69. organization,
  70. }
  71. );
  72. // headers
  73. expect(await screen.findByText('Screen')).toBeInTheDocument();
  74. expect(await screen.findByText('Slow Frames')).toBeInTheDocument();
  75. expect(await screen.findByText('Frozen Frames')).toBeInTheDocument();
  76. expect(await screen.findByText('Screen 01')).toBeInTheDocument();
  77. // slow frames
  78. expect(await screen.findByText('12')).toBeInTheDocument();
  79. // frozen frames
  80. expect(await screen.findByText('23')).toBeInTheDocument();
  81. // count
  82. expect(await screen.findByText('45')).toBeInTheDocument();
  83. });
  84. });