accepted-invite.test.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { render, screen } from '@testing-library/react'
  2. import AcceptedInvite from '../../../../../../frontend/js/features/subscription/components/group-invite/accepted-invite'
  3. import { expect } from 'chai'
  4. describe('accepted group invite', function () {
  5. it('renders', async function () {
  6. window.metaAttributesCache.set('ol-inviterName', 'example@overleaf.com')
  7. render(<AcceptedInvite />)
  8. await screen.findByText(
  9. 'You have joined the group subscription managed by example@overleaf.com'
  10. )
  11. })
  12. it('links to SSO enrollment page for SSO groups', async function () {
  13. window.metaAttributesCache.set('ol-inviterName', 'example@overleaf.com')
  14. window.metaAttributesCache.set('ol-groupSSOActive', true)
  15. window.metaAttributesCache.set('ol-subscriptionId', 'group123')
  16. render(<AcceptedInvite />)
  17. const linkBtn = (await screen.findByRole('link', {
  18. name: 'Done',
  19. })) as HTMLLinkElement
  20. expect(linkBtn.href).to.equal(
  21. 'https://www.test-overleaf.com/subscription/group123/sso_enrollment'
  22. )
  23. })
  24. it('links to dash for non-SSO groups', async function () {
  25. window.metaAttributesCache.set('ol-inviterName', 'example@overleaf.com')
  26. render(<AcceptedInvite />)
  27. const linkBtn = (await screen.findByRole('link', {
  28. name: 'Done',
  29. })) as HTMLLinkElement
  30. expect(linkBtn.href).to.equal('https://www.test-overleaf.com/project')
  31. })
  32. })