content.spec.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import PageFiltersStore from 'sentry/stores/pageFiltersStore';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. import {useProfileFilters} from 'sentry/utils/profiling/hooks/useProfileFilters';
  7. import ProfilingContent from 'sentry/views/profiling/content';
  8. jest.mock('sentry/utils/profiling/hooks/useProfileFilters');
  9. describe('profiling Onboarding View > Unsupported Banner', function () {
  10. const {router} = initializeOrg({
  11. router: {
  12. location: {query: {}, search: '', pathname: '/test/'},
  13. },
  14. });
  15. beforeEach(function () {
  16. jest.resetAllMocks();
  17. PageFiltersStore.init();
  18. PageFiltersStore.onInitializeUrlState(
  19. {
  20. projects: [],
  21. environments: [],
  22. datetime: {start: null, end: null, period: '24h', utc: null},
  23. },
  24. new Set()
  25. );
  26. MockApiClient.addMockResponse({
  27. url: '/organizations/org-slug/events/',
  28. method: 'GET',
  29. body: {data: []},
  30. });
  31. MockApiClient.addMockResponse({
  32. url: '/organizations/org-slug/profiling/filters/',
  33. method: 'GET',
  34. body: {data: []},
  35. });
  36. jest.mocked(useProfileFilters).mockReturnValue({});
  37. });
  38. it('Displays unsupported banner for unsupported projects', async function () {
  39. ProjectsStore.loadInitialData([ProjectFixture({platform: 'nintendo-switch'})]);
  40. render(<ProfilingContent location={router.location} />);
  41. expect(await screen.findByTestId('unsupported-alert')).toBeInTheDocument();
  42. });
  43. it('Does not show unsupported banner for supported projects', async function () {
  44. ProjectsStore.loadInitialData([
  45. ProjectFixture({platform: 'android', hasProfiles: false}),
  46. ]);
  47. render(<ProfilingContent location={router.location} />);
  48. expect(await screen.findByTestId('profiling-upgrade')).toBeInTheDocument();
  49. expect(screen.queryByTestId('unsupported-alert')).not.toBeInTheDocument();
  50. });
  51. });