webVitalsLandingPage.spec.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 performance score migration 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(
  67. /We made improvements to how Performance Scores are calculated for your projects/
  68. );
  69. });
  70. });