screensTable.spec.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 {AppStartScreens} from 'sentry/views/performance/mobile/appStarts/screens/screensTable';
  5. import {useReleaseSelection} from 'sentry/views/starfish/queries/useReleases';
  6. jest.mock('sentry/views/starfish/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: 'Cold Start (R1)'})
  51. ).toBeInTheDocument();
  52. expect(
  53. screen.getByRole('columnheader', {name: '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(screen.getByRole('columnheader', {name: 'Count'})).toBeInTheDocument();
  60. });
  61. it('renders custom transaction and breakdown fields', () => {
  62. render(
  63. <AppStartScreens
  64. data={{
  65. data: [
  66. {
  67. id: '1',
  68. transaction: 'Screen 1',
  69. 'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.5)': 100,
  70. 'avg_if(measurements.app_start_cold,release,com.example.vu.android@2.10.3+42)': 200,
  71. 'avg_compare(measurements.app_start_cold,release,com.example.vu.android@2.10.5,com.example.vu.android@2.10.3+42)': 50,
  72. app_start_breakdown: 'breakdown',
  73. 'count_starts(measurements.app_start_cold)': 10,
  74. },
  75. ],
  76. meta: {
  77. fields: [],
  78. },
  79. }}
  80. eventView={getMockEventView({fields: []})}
  81. isLoading={false}
  82. pageLinks={undefined}
  83. />
  84. );
  85. expect(screen.getByRole('link', {name: 'Screen 1'})).toBeInTheDocument();
  86. expect(screen.getByTestId('app-start-breakdown')).toBeInTheDocument();
  87. });
  88. });