successful-subscription.test.tsx 2.9 KB

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