pageOverview.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 PageOverview from 'sentry/views/performance/browser/webVitals/pageOverview';
  7. jest.mock('sentry/utils/useLocation');
  8. jest.mock('sentry/utils/usePageFilters');
  9. jest.mock('sentry/utils/useOrganization');
  10. describe('PageOverview', 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. MockApiClient.addMockResponse({
  52. url: `/organizations/${organization.slug}/spans-aggregation/`,
  53. body: {},
  54. });
  55. });
  56. afterEach(function () {
  57. jest.resetAllMocks();
  58. });
  59. it('renders performance score migration alert', async () => {
  60. jest.mocked(useLocation).mockReturnValue({
  61. pathname: '',
  62. search: '',
  63. query: {useStoredScores: 'true', transaction: '/'},
  64. hash: '',
  65. state: undefined,
  66. action: 'PUSH',
  67. key: '',
  68. });
  69. render(<PageOverview />);
  70. await screen.findByText(
  71. /We made improvements to how Performance Scores are calculated for your projects/
  72. );
  73. });
  74. });