trialAlert.spec.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import {resetMockDate, setMockDate} from 'sentry-test/utils';
  5. import TrialAlert from 'getsentry/views/subscriptionPage/trialAlert';
  6. describe('Subscription > TrialAlert', function () {
  7. const organization = OrganizationFixture();
  8. const subscription = SubscriptionFixture({organization});
  9. beforeEach(() => {
  10. setMockDate(new Date('2021-01-01'));
  11. });
  12. afterEach(() => {
  13. resetMockDate();
  14. });
  15. it('does not render not on trial', function () {
  16. const sub = {
  17. ...subscription,
  18. isTrial: false,
  19. onDemandMaxSpend: 1000,
  20. onDemandSpendUsed: 0,
  21. };
  22. render(<TrialAlert subscription={sub} organization={organization} />);
  23. expect(screen.queryByRole('button')).not.toBeInTheDocument();
  24. });
  25. it('renders 1 day left', function () {
  26. const sub = {
  27. ...subscription,
  28. isTrial: true,
  29. onDemandMaxSpend: 1000,
  30. onDemandSpendUsed: 0,
  31. trialEnd: '2021-01-02',
  32. };
  33. render(<TrialAlert subscription={sub} organization={organization} />);
  34. expect(screen.getByText('1 Day Left')).toBeInTheDocument();
  35. expect(screen.getByRole('button')).toBeInTheDocument();
  36. });
  37. it('renders 14 days left', function () {
  38. const sub = {
  39. ...subscription,
  40. isTrial: true,
  41. onDemandMaxSpend: 1000,
  42. onDemandSpendUsed: 0,
  43. trialEnd: '2021-01-15',
  44. };
  45. render(<TrialAlert subscription={sub} organization={organization} />);
  46. expect(screen.getByText('14 Days Left')).toBeInTheDocument();
  47. expect(screen.getByRole('button')).toBeInTheDocument();
  48. });
  49. it('does not render negative days left', function () {
  50. const sub = {
  51. ...subscription,
  52. isTrial: true,
  53. onDemandMaxSpend: 1000,
  54. onDemandSpendUsed: 0,
  55. trialEnd: '2020-12-01',
  56. };
  57. render(<TrialAlert subscription={sub} organization={organization} />);
  58. expect(screen.queryByRole('button')).not.toBeInTheDocument();
  59. });
  60. it('renders enterprise trial', function () {
  61. const sub = {
  62. ...subscription,
  63. isTrial: true,
  64. isEnterpriseTrial: true,
  65. onDemandMaxSpend: 1000,
  66. onDemandSpendUsed: 0,
  67. };
  68. render(<TrialAlert subscription={sub} organization={organization} />);
  69. expect(screen.getByText('Enterprise Trial')).toBeInTheDocument();
  70. expect(
  71. screen.getByText(
  72. "With your trial you have access to Sentry's business plan features, and unlimited errors, transactions, replays, attachments, cron monitors, and uptime monitors."
  73. )
  74. ).toBeInTheDocument();
  75. });
  76. it('renders am3 enterprise trial', function () {
  77. const am3_sub = SubscriptionFixture({organization, plan: 'am3_f'});
  78. const sub = {
  79. ...am3_sub,
  80. isTrial: true,
  81. isEnterpriseTrial: true,
  82. onDemandMaxSpend: 1000,
  83. onDemandSpendUsed: 0,
  84. };
  85. render(<TrialAlert subscription={sub} organization={organization} />);
  86. expect(screen.getByText('Enterprise Trial')).toBeInTheDocument();
  87. expect(
  88. screen.getByText(
  89. "With your trial you have access to Sentry's business plan features, and unlimited errors, replays, attachments, cron monitors, spans, profile hours, and uptime monitors."
  90. )
  91. ).toBeInTheDocument();
  92. });
  93. it('renders plan trial', function () {
  94. const sub = {
  95. ...subscription,
  96. isTrial: true,
  97. isEnterpriseTrial: false,
  98. isPerformancePlanTrial: false,
  99. onDemandMaxSpend: 1000,
  100. onDemandSpendUsed: 0,
  101. };
  102. render(<TrialAlert subscription={sub} organization={organization} />);
  103. expect(screen.getByText('Business Plan Trial')).toBeInTheDocument();
  104. expect(
  105. screen.getByText(
  106. "With your trial you have access to Sentry's business plan features."
  107. )
  108. ).toBeInTheDocument();
  109. expect(screen.queryByText(/unlimited errors/)).not.toBeInTheDocument();
  110. });
  111. it('renders performance trial', function () {
  112. const sub = {
  113. ...subscription,
  114. isTrial: true,
  115. isEnterpriseTrial: false,
  116. isPerformancePlanTrial: true,
  117. onDemandMaxSpend: 1000,
  118. onDemandSpendUsed: 0,
  119. };
  120. render(<TrialAlert subscription={sub} organization={organization} />);
  121. expect(screen.getByText('Performance Trial')).toBeInTheDocument();
  122. expect(
  123. screen.getByText(
  124. `With your trial you have access to Sentry's performance features, and unlimited transactions and attachments.`
  125. )
  126. ).toBeInTheDocument();
  127. });
  128. });