security-section.test.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import SecuritySection from '@/features/settings/components/security-section'
  2. import { expect } from 'chai'
  3. import { screen, render } from '@testing-library/react'
  4. import fetchMock from 'fetch-mock'
  5. describe('<SecuritySection />', function () {
  6. afterEach(function () {
  7. fetchMock.removeRoutes().clearHistory()
  8. })
  9. it('shows Group SSO rows in security section', async function () {
  10. window.metaAttributesCache.set('ol-memberOfSSOEnabledGroups', [
  11. {
  12. groupId: 'abc123abc123',
  13. linked: true,
  14. },
  15. {
  16. groupId: 'fff999fff999',
  17. linked: false,
  18. },
  19. ])
  20. render(<SecuritySection />)
  21. expect(screen.getAllByText('Single Sign-On (SSO)').length).to.equal(2)
  22. const link = screen.getByRole('button', {
  23. name: /Set up SSO/i,
  24. })
  25. expect(link).to.exist
  26. expect(link.getAttribute('href')).to.equal(
  27. '/subscription/fff999fff999/sso_enrollment'
  28. )
  29. })
  30. it('does not show the security section with no groups with SSO enabled', async function () {
  31. window.metaAttributesCache.set('ol-memberOfSSOEnabledGroups', [])
  32. render(<SecuritySection />)
  33. expect(screen.queryByText('Security')).to.not.exist
  34. })
  35. })