successful-subscription.test.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { expect } from 'chai'
  2. import { screen, within } from '@testing-library/react'
  3. import SuccessfulSubscription from '../../../../../../frontend/js/features/subscription/components/successful-subscription/successful-subscription'
  4. import { renderWithSubscriptionDashContext } from '../../helpers/render-with-subscription-dash-context'
  5. import { annualActiveSubscription } from '../../fixtures/subscriptions'
  6. import { ExposedSettings } from '../../../../../../types/exposed-settings'
  7. import { UserProvider } from '@/shared/context/user-context'
  8. describe('successful subscription page', function () {
  9. it('renders the invoices link', function () {
  10. const adminEmail = 'foo@example.com'
  11. renderWithSubscriptionDashContext(
  12. <UserProvider>
  13. <SuccessfulSubscription />
  14. </UserProvider>,
  15. {
  16. metaTags: [
  17. {
  18. name: 'ol-ExposedSettings',
  19. value: {
  20. adminEmail,
  21. } as ExposedSettings,
  22. },
  23. { name: 'ol-subscription', value: annualActiveSubscription },
  24. ],
  25. }
  26. )
  27. screen.getByRole('heading', { name: /thanks for subscribing/i })
  28. const alert = screen.getByRole('alert')
  29. within(alert).getByText(/to modify your subscription go to/i)
  30. const manageSubscriptionLink = within(alert).getByRole('link', {
  31. name: /manage subscription/i,
  32. })
  33. expect(manageSubscriptionLink.getAttribute('href')).to.equal(
  34. '/user/subscription'
  35. )
  36. screen.getByText(
  37. `Thank you for subscribing to the ${annualActiveSubscription.plan.name} plan.`,
  38. { exact: false }
  39. )
  40. screen.getByText(
  41. /it’s support from people like yourself that allows .* to continue to grow and improve/i
  42. )
  43. expect(screen.getByText(/get the most out of your/i).textContent).to.match(
  44. /get the most out of your subscription by checking out Overleaf’s features/i
  45. )
  46. expect(
  47. screen
  48. .getByText(/if there is anything you ever/i)
  49. .textContent?.replace(/\xA0/g, ' ')
  50. ).to.equal(
  51. `If there is anything you ever need please feel free to contact us directly at ${adminEmail}.`
  52. )
  53. const contactLink = screen.getByRole('link', {
  54. name: adminEmail,
  55. })
  56. expect(contactLink.getAttribute('href')).to.equal(`mailto:${adminEmail}`)
  57. expect(
  58. screen.getByText(/if you would like to help us improve/i).textContent
  59. ).to.match(
  60. /if you would like to help us improve .*, please take a moment to fill out this survey/i
  61. )
  62. const surveyLink = screen.getByRole('link', {
  63. name: /this survey/i,
  64. })
  65. expect(surveyLink.getAttribute('href')).to.equal(
  66. 'https://forms.gle/CdLNX9m6NLxkv1yr5'
  67. )
  68. const helpLink = screen.getByRole('link', {
  69. name: /Overleaf’s features/i,
  70. })
  71. expect(helpLink.getAttribute('href')).to.equal(
  72. '/learn/how-to/Overleaf_premium_features'
  73. )
  74. const backToYourProjectsLink = screen.getByRole('link', {
  75. name: /back to your projects/i,
  76. })
  77. expect(backToYourProjectsLink.getAttribute('href')).to.equal('/project')
  78. })
  79. })