samplingSDKUpgradesAlert.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import {Fragment} from 'react';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import GlobalModal from 'sentry/components/globalModal';
  4. import {SamplingSDKUpgradesAlert} from 'sentry/views/settings/project/server-side-sampling/samplingSDKUpgradesAlert';
  5. import {getMockData, mockedProjects, recommendedSdkUpgrades} from './testUtils';
  6. describe('Server-Side Sampling - Sdk Upgrades Alert', function () {
  7. it('does not render content', function () {
  8. const {organization, project} = getMockData();
  9. render(
  10. <SamplingSDKUpgradesAlert
  11. organization={organization}
  12. projectId={project.id}
  13. onReadDocs={jest.fn()}
  14. recommendedSdkUpgrades={[]}
  15. />
  16. );
  17. expect(
  18. screen.queryByTestId('recommended-sdk-upgrades-alert')
  19. ).not.toBeInTheDocument();
  20. });
  21. it('renders content with update sdks info', function () {
  22. const {organization, project} = getMockData();
  23. render(
  24. <Fragment>
  25. <GlobalModal />
  26. <SamplingSDKUpgradesAlert
  27. organization={organization}
  28. projectId={project.id}
  29. onReadDocs={jest.fn()}
  30. recommendedSdkUpgrades={recommendedSdkUpgrades}
  31. />
  32. </Fragment>
  33. );
  34. expect(screen.getByTestId('recommended-sdk-upgrades-alert')).toBeInTheDocument();
  35. expect(screen.getByRole('button', {name: 'Learn More'})).toBeInTheDocument();
  36. expect(
  37. screen.getByText(
  38. 'To activate sampling rules, it’s a requirement to update the following project SDK(s):'
  39. )
  40. ).toBeInTheDocument();
  41. expect(screen.getByTestId('platform-icon-python')).toBeInTheDocument();
  42. expect(screen.getByTestId('badge-display-name')).toBeInTheDocument();
  43. expect(screen.getByRole('link', {name: mockedProjects[1].slug})).toHaveAttribute(
  44. 'href',
  45. `/organizations/org-slug/projects/sentry/?project=${mockedProjects[1].id}`
  46. );
  47. // Click on learn more button
  48. userEvent.click(screen.getByRole('button', {name: 'Learn More'}));
  49. // Recommended steps modal is rendered
  50. expect(
  51. screen.getByRole('heading', {
  52. name: 'Update the following SDK versions',
  53. })
  54. ).toBeInTheDocument();
  55. });
  56. });