screensTable.spec.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import EventView from 'sentry/utils/discover/eventView';
  3. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  4. import {useReleaseSelection} from 'sentry/views/insights/common/queries/useReleases';
  5. import {AppStartScreens} from 'sentry/views/insights/mobile/appStarts/components/tables/screensTable';
  6. jest.mock('sentry/views/insights/common/queries/useReleases');
  7. jest.mocked(useReleaseSelection).mockReturnValue({
  8. primaryRelease: 'com.example.vu.android@2.10.5',
  9. isLoading: false,
  10. secondaryRelease: 'com.example.vu.android@2.10.3+42',
  11. });
  12. function getMockEventView({fields}) {
  13. return new EventView({
  14. id: '1',
  15. name: 'mock query',
  16. fields,
  17. sorts: [],
  18. query: '',
  19. project: [],
  20. start: '2019-10-01T00:00:00',
  21. end: '2019-10-02T00:00:00',
  22. statsPeriod: '14d',
  23. environment: [],
  24. additionalConditions: new MutableSearch(''),
  25. createdBy: undefined,
  26. interval: undefined,
  27. display: '',
  28. team: [],
  29. topEvents: undefined,
  30. yAxis: undefined,
  31. });
  32. }
  33. describe('AppStartScreens', () => {
  34. it('renders the correct headers', () => {
  35. render(
  36. <AppStartScreens
  37. data={{
  38. data: [],
  39. meta: {
  40. fields: [],
  41. },
  42. }}
  43. eventView={getMockEventView({fields: []})}
  44. isLoading={false}
  45. pageLinks={undefined}
  46. />
  47. );
  48. expect(screen.getByRole('columnheader', {name: 'Screen'})).toBeInTheDocument();
  49. expect(
  50. screen.getByRole('columnheader', {name: 'Avg Cold Start (R1)'})
  51. ).toBeInTheDocument();
  52. expect(
  53. screen.getByRole('columnheader', {name: 'Avg Cold Start (R2)'})
  54. ).toBeInTheDocument();
  55. expect(screen.getByRole('columnheader', {name: 'Change'})).toBeInTheDocument();
  56. expect(
  57. screen.getByRole('columnheader', {name: 'Type Breakdown'})
  58. ).toBeInTheDocument();
  59. expect(
  60. screen.getByRole('columnheader', {name: 'Cold Start Count'})
  61. ).toBeInTheDocument();
  62. });
  63. it('renders custom transaction and breakdown fields', () => {
  64. render(
  65. <AppStartScreens
  66. data={{
  67. data: [
  68. {
  69. id: '1',
  70. transaction: 'Screen 1',
  71. 'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.5)': 100,
  72. 'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.3+42)': 200,
  73. 'avg_compare(measurements.app_start_cold,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)': 50,
  74. app_start_breakdown: 'breakdown',
  75. 'count_starts(measurements.app_start_cold)': 10,
  76. },
  77. ],
  78. meta: {
  79. fields: [],
  80. },
  81. }}
  82. eventView={getMockEventView({fields: []})}
  83. isLoading={false}
  84. pageLinks={undefined}
  85. />
  86. );
  87. expect(screen.getByRole('link', {name: 'Screen 1'})).toBeInTheDocument();
  88. expect(screen.getByTestId('app-start-breakdown')).toBeInTheDocument();
  89. });
  90. });