invite-not-valid.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import InviteNotValid from '@/features/share-project/invite-not-valid'
  2. describe('<InviteNotValid />', function () {
  3. const email = 'test@example.com'
  4. it('renders the sorry message', function () {
  5. cy.mount(<InviteNotValid email={email} />)
  6. cy.findByRole('heading', {
  7. name: /sorry, this project isn’t available/i,
  8. })
  9. })
  10. it('renders the broken link message', function () {
  11. cy.mount(<InviteNotValid email={email} />)
  12. cy.findByText(/the link may be broken or you may not have access rights/i)
  13. })
  14. it('renders a back to projects button linking to /project', function () {
  15. cy.mount(<InviteNotValid email={email} />)
  16. cy.findByRole('link', { name: /back to my projects/i }).should(
  17. 'have.attr',
  18. 'href',
  19. '/project'
  20. )
  21. })
  22. it('renders the logged-in email', function () {
  23. cy.mount(<InviteNotValid email={email} />)
  24. cy.contains(
  25. new RegExp(
  26. `you are currently logged in as ${email}. you might need to log in with a different email address`,
  27. 'i'
  28. )
  29. )
  30. })
  31. it('does not render the CTA and email when email not provided', function () {
  32. cy.mount(<InviteNotValid />)
  33. cy.findByRole('link', { name: /back to my projects/i }).should('not.exist')
  34. cy.contains(
  35. new RegExp(
  36. `you are currently logged in as ${email}. you might need to log in with a different email address`,
  37. 'i'
  38. )
  39. ).should('not.exist')
  40. })
  41. })