webVitalsLandingPage.spec.tsx 1.9 KB

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