webVitalsLandingPage.spec.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import {useLocation} from 'sentry/utils/useLocation';
  4. import useOrganization from 'sentry/utils/useOrganization';
  5. import usePageFilters from 'sentry/utils/usePageFilters';
  6. import WebVitalsLandingPage from 'sentry/views/performance/browser/webVitals/webVitalsLandingPage';
  7. jest.mock('sentry/utils/useLocation');
  8. jest.mock('sentry/utils/usePageFilters');
  9. jest.mock('sentry/utils/useOrganization');
  10. describe('WebVitalsLandingPage', function () {
  11. const organization = OrganizationFixture({
  12. features: ['starfish-browser-webvitals', 'performance-database-view'],
  13. });
  14. beforeEach(function () {
  15. jest.mocked(useLocation).mockReturnValue({
  16. pathname: '',
  17. search: '',
  18. query: {},
  19. hash: '',
  20. state: undefined,
  21. action: 'PUSH',
  22. key: '',
  23. });
  24. jest.mocked(usePageFilters).mockReturnValue({
  25. isReady: true,
  26. desyncedFilters: new Set(),
  27. pinnedFilters: new Set(),
  28. shouldPersist: true,
  29. selection: {
  30. datetime: {
  31. period: '10d',
  32. start: null,
  33. end: null,
  34. utc: false,
  35. },
  36. environments: [],
  37. projects: [],
  38. },
  39. });
  40. jest.mocked(useOrganization).mockReturnValue(organization);
  41. MockApiClient.addMockResponse({
  42. url: `/organizations/${organization.slug}/events/`,
  43. body: {
  44. data: [],
  45. },
  46. });
  47. MockApiClient.addMockResponse({
  48. url: `/organizations/${organization.slug}/events-stats/`,
  49. body: {},
  50. });
  51. });
  52. afterEach(function () {
  53. jest.resetAllMocks();
  54. });
  55. it('renders FID deprecation alert', async () => {
  56. jest.mocked(useLocation).mockReturnValue({
  57. pathname: '',
  58. search: '',
  59. query: {useStoredScores: 'true'},
  60. hash: '',
  61. state: undefined,
  62. action: 'PUSH',
  63. key: '',
  64. });
  65. render(<WebVitalsLandingPage />);
  66. await screen.findByText(/\(Interaction to Next Paint\) will replace/);
  67. await screen.findByText(
  68. /\(First Input Delay\) in our performance score calculation./
  69. );
  70. });
  71. });