screensOverviewTable.spec.tsx 2.7 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 useOrganization from 'sentry/utils/useOrganization';
  8. import usePageFilters from 'sentry/utils/usePageFilters';
  9. import ScreensOverviewTable from 'sentry/views/insights/mobile/screens/components/screensOverviewTable';
  10. jest.mock('sentry/utils/useOrganization');
  11. jest.mock('sentry/utils/useLocation');
  12. jest.mock('sentry/views/insights/common/utils/useModuleURL');
  13. jest.mock('sentry/utils/usePageFilters');
  14. describe('ScreensOverviewTable', () => {
  15. const organization = OrganizationFixture({
  16. features: ['insights-addon-modules', 'insights-mobile-screens-module'],
  17. });
  18. const project = ProjectFixture();
  19. const location = {
  20. action: 'PUSH',
  21. hash: '',
  22. key: '',
  23. pathname: '/organizations/org-slug/performance/mobile/mobile-screens',
  24. query: {
  25. project: project.id,
  26. },
  27. search: '',
  28. state: undefined,
  29. } as Location;
  30. jest.mocked(useOrganization).mockReturnValue(organization);
  31. jest.mocked(useLocation).mockReturnValue(location);
  32. jest.mocked(usePageFilters).mockReturnValue({
  33. isReady: true,
  34. desyncedFilters: new Set(),
  35. pinnedFilters: new Set(),
  36. shouldPersist: true,
  37. selection: {
  38. datetime: {
  39. period: '10d',
  40. start: null,
  41. end: null,
  42. utc: false,
  43. },
  44. environments: [],
  45. projects: [parseInt(project.id, 10)],
  46. },
  47. });
  48. const mockEventView = EventView.fromLocation(location);
  49. const mockData = {
  50. data: [
  51. {
  52. id: '1',
  53. transaction: 'Screen 01',
  54. 'avg(mobile.slow_frames)': 12,
  55. 'avg(mobile.frozen_frames)': 23,
  56. 'count()': 45,
  57. },
  58. ],
  59. meta: {
  60. fields: [],
  61. },
  62. };
  63. it('renders columns', async () => {
  64. render(
  65. <ScreensOverviewTable
  66. data={mockData}
  67. eventView={mockEventView}
  68. isLoading={false}
  69. pageLinks=""
  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. });