subscription-dashboard.test.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { expect } from 'chai'
  2. import { screen } from '@testing-library/react'
  3. import SubscriptionDashboard from '../../../../../../frontend/js/features/subscription/components/dashboard/subscription-dashboard'
  4. import {
  5. cleanUpContext,
  6. renderWithSubscriptionDashContext,
  7. } from '../../helpers/render-with-subscription-dash-context'
  8. describe('<SubscriptionDashboard />', function () {
  9. afterEach(function () {
  10. cleanUpContext()
  11. })
  12. describe('Free Plan', function () {
  13. beforeEach(function () {
  14. renderWithSubscriptionDashContext(<SubscriptionDashboard />)
  15. })
  16. it('does not render the "Get the most out of your" subscription text', function () {
  17. const text = screen.queryByText('Get the most out of your', {
  18. exact: false,
  19. })
  20. expect(text).to.be.null
  21. })
  22. it('does not render the contact support message', function () {
  23. const text = screen.queryByText(
  24. `You’re on an Overleaf Paid plan. Contact`,
  25. {
  26. exact: false,
  27. }
  28. )
  29. expect(text).to.be.null
  30. })
  31. })
  32. describe('Custom subscription', function () {
  33. it('renders the contact support message', function () {
  34. renderWithSubscriptionDashContext(<SubscriptionDashboard />, {
  35. metaTags: [
  36. {
  37. name: 'ol-currentInstitutionsWithLicence',
  38. value: [],
  39. },
  40. {
  41. name: 'ol-hasSubscription',
  42. value: true,
  43. },
  44. ],
  45. })
  46. screen.getByText(`You’re on an Overleaf Paid plan.`, {
  47. exact: false,
  48. })
  49. screen.getByText(`Contact support`, {
  50. exact: false,
  51. })
  52. })
  53. })
  54. it('Show a warning when coming from plans page', function () {
  55. renderWithSubscriptionDashContext(<SubscriptionDashboard />, {
  56. metaTags: [
  57. {
  58. name: 'ol-fromPlansPage',
  59. value: true,
  60. },
  61. ],
  62. })
  63. screen.getByText('You already have a subscription')
  64. })
  65. })