webVitalMeters.spec.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import type {TableData} from 'sentry/utils/discover/discoverQuery';
  4. import {useLocation} from 'sentry/utils/useLocation';
  5. import usePageFilters from 'sentry/utils/usePageFilters';
  6. import WebVitalMeters from 'sentry/views/performance/browser/webVitals/components/webVitalMeters';
  7. import type {ProjectScore} from 'sentry/views/performance/browser/webVitals/utils/types';
  8. jest.mock('sentry/utils/useLocation');
  9. jest.mock('sentry/utils/usePageFilters');
  10. describe('WebVitalMeters', function () {
  11. const organization = OrganizationFixture();
  12. const projectScore: ProjectScore = {
  13. lcpWeight: 30,
  14. fcpWeight: 20,
  15. fidWeight: 25,
  16. clsWeight: 15,
  17. ttfbWeight: 10,
  18. inpWeight: 10,
  19. };
  20. const projectData: TableData = {
  21. data: [],
  22. };
  23. beforeEach(function () {
  24. jest.mocked(useLocation).mockReturnValue({
  25. pathname: '',
  26. search: '',
  27. query: {},
  28. hash: '',
  29. state: undefined,
  30. action: 'PUSH',
  31. key: '',
  32. });
  33. jest.mocked(usePageFilters).mockReturnValue({
  34. isReady: true,
  35. desyncedFilters: new Set(),
  36. pinnedFilters: new Set(),
  37. shouldPersist: true,
  38. selection: {
  39. datetime: {
  40. period: '10d',
  41. start: null,
  42. end: null,
  43. utc: false,
  44. },
  45. environments: [],
  46. projects: [],
  47. },
  48. });
  49. });
  50. it('renders web vital meters with interaction to next paint', async () => {
  51. render(<WebVitalMeters projectData={projectData} projectScore={projectScore} />, {
  52. organization,
  53. });
  54. await screen.findByText('Largest Contentful Paint');
  55. screen.getByText('First Contentful Paint');
  56. screen.getByText('Cumulative Layout Shift');
  57. screen.getByText('Time To First Byte');
  58. screen.getByText('Interaction to Next Paint');
  59. });
  60. });