accepted-invite.test.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. afterEach(function () {
  6. window.metaAttributesCache = new Map()
  7. })
  8. it('renders', async function () {
  9. window.metaAttributesCache.set('ol-inviterName', 'example@overleaf.com')
  10. render(<AcceptedInvite />)
  11. await screen.findByText(
  12. 'You have joined the group subscription managed by example@overleaf.com'
  13. )
  14. })
  15. it('links to SSO enrollment page for SSO groups', async function () {
  16. window.metaAttributesCache.set('ol-inviterName', 'example@overleaf.com')
  17. window.metaAttributesCache.set('ol-groupSSOActive', true)
  18. window.metaAttributesCache.set('ol-subscriptionId', 'group123')
  19. render(<AcceptedInvite />)
  20. const linkBtn = (await screen.findByRole('link', {
  21. name: 'Done',
  22. })) as HTMLLinkElement
  23. expect(linkBtn.href).to.equal(
  24. 'https://www.test-overleaf.com/subscription/group123/sso_enrollment'
  25. )
  26. })
  27. it('links to dash for non-SSO groups', async function () {
  28. window.metaAttributesCache.set('ol-inviterName', 'example@overleaf.com')
  29. render(<AcceptedInvite />)
  30. const linkBtn = (await screen.findByRole('link', {
  31. name: 'Done',
  32. })) as HTMLLinkElement
  33. expect(linkBtn.href).to.equal('https://www.test-overleaf.com/project')
  34. })
  35. })