checkoutOverviewV2.spec.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import {BillingConfigFixture} from 'getsentry-test/fixtures/billingConfig';
  2. import {PlanDetailsLookupFixture} from 'getsentry-test/fixtures/planDetailsLookup';
  3. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  4. import {initializeOrg} from 'sentry-test/initializeOrg';
  5. import {render, screen} from 'sentry-test/reactTestingLibrary';
  6. import SubscriptionStore from 'getsentry/stores/subscriptionStore';
  7. import {PlanTier} from 'getsentry/types';
  8. import AMCheckout from 'getsentry/views/amCheckout/';
  9. import CheckoutOverviewV2 from 'getsentry/views/amCheckout/checkoutOverviewV2';
  10. import type {CheckoutFormData} from 'getsentry/views/amCheckout/types';
  11. describe('CheckoutOverviewV2', function () {
  12. const api = new MockApiClient();
  13. const {organization, routerProps} = initializeOrg();
  14. const subscription = SubscriptionFixture({organization, plan: 'am3_f'});
  15. const params = {};
  16. const billingConfig = BillingConfigFixture(PlanTier.AM3);
  17. const teamPlanAnnual = PlanDetailsLookupFixture('am3_team_auf')!;
  18. beforeEach(function () {
  19. MockApiClient.clearMockResponses();
  20. SubscriptionStore.set(organization.slug, subscription);
  21. MockApiClient.addMockResponse({
  22. url: `/customers/${organization.slug}/plan-migrations/?applied=0`,
  23. method: 'GET',
  24. body: {},
  25. });
  26. MockApiClient.addMockResponse({
  27. url: `/subscriptions/${organization.slug}/`,
  28. method: 'GET',
  29. body: {},
  30. });
  31. MockApiClient.addMockResponse({
  32. url: `/customers/${organization.slug}/billing-config/`,
  33. method: 'GET',
  34. body: BillingConfigFixture(PlanTier.AM3),
  35. });
  36. MockApiClient.addMockResponse({
  37. url: `/organizations/${organization.slug}/promotions/trigger-check/`,
  38. method: 'POST',
  39. });
  40. });
  41. it('initializes with business plan and unset budget when on AM3 developer plan', async function () {
  42. render(
  43. <AMCheckout
  44. {...routerProps}
  45. api={api}
  46. checkoutTier={PlanTier.AM3}
  47. onToggleLegacy={jest.fn()}
  48. params={params}
  49. />
  50. );
  51. expect(await screen.findByTestId('checkout-overview-v2')).toBeInTheDocument();
  52. expect(screen.getByText('Sentry Business Plan')).toBeInTheDocument();
  53. expect(
  54. screen.getByText('This is your standard monthly subscription charge.')
  55. ).toBeInTheDocument();
  56. expect(screen.getAllByText('$89/mo')).toHaveLength(2);
  57. expect(screen.queryByTestId('additional-monthly-charge')).not.toBeInTheDocument();
  58. expect(screen.getByText('Monthly Reserved Volumes')).toBeInTheDocument();
  59. expect(screen.getByText('Billed Monthly')).toBeInTheDocument();
  60. });
  61. it('renders with existing plan', function () {
  62. const formData: CheckoutFormData = {
  63. plan: 'am3_team_auf',
  64. reserved: {
  65. errors: 100000,
  66. attachments: 25,
  67. replays: 50,
  68. spans: 10_000_000,
  69. monitorSeats: 1,
  70. profileDuration: 50,
  71. },
  72. onDemandMaxSpend: 5000,
  73. };
  74. render(
  75. <CheckoutOverviewV2
  76. activePlan={teamPlanAnnual}
  77. billingConfig={billingConfig}
  78. formData={formData}
  79. onUpdate={jest.fn()}
  80. organization={organization}
  81. subscription={subscription}
  82. />
  83. );
  84. expect(screen.getByText('Sentry Team Plan')).toBeInTheDocument();
  85. expect(screen.getByText('Monthly Reserved Volumes')).toBeInTheDocument();
  86. expect(screen.getByText('Billed Annually')).toBeInTheDocument();
  87. expect(screen.getByText('$312/yr')).toBeInTheDocument();
  88. expect(screen.getByTestId('additional-monthly-charge')).toHaveTextContent(
  89. '+ up to $50/mo based on PAYG usage'
  90. );
  91. expect(screen.getByTestId('attachments-reserved')).toHaveTextContent(
  92. '25 GB Attachments+ $65/yr'
  93. );
  94. expect(screen.getByTestId('errors-reserved')).toHaveTextContent(
  95. '100,000 Errors+ $162/yr'
  96. );
  97. // Shows "included" for categories with no additional spend
  98. expect(screen.getByTestId('replays-reserved')).toHaveTextContent(
  99. '50 ReplaysIncluded'
  100. );
  101. expect(screen.getByTestId('spans-reserved')).toHaveTextContent(
  102. '10,000,000 SpansIncluded'
  103. );
  104. expect(screen.getByTestId('monitorSeats-reserved')).toHaveTextContent(
  105. '1 Cron monitorIncluded'
  106. );
  107. expect(screen.getByTestId('profileDuration-reserved')).toHaveTextContent(
  108. '50 Profile hoursIncluded'
  109. );
  110. expect(screen.queryByTestId('spansIndexed-reserved')).not.toBeInTheDocument();
  111. expect(
  112. screen.getByText('This is your standard yearly subscription charge.')
  113. ).toBeInTheDocument();
  114. });
  115. it('hides payg budget when setting to zero', function () {
  116. const formData: CheckoutFormData = {
  117. plan: 'am3_team_auf',
  118. reserved: {
  119. errors: 100000,
  120. attachments: 25,
  121. replays: 500,
  122. monitorSeats: 1,
  123. },
  124. onDemandMaxSpend: 0,
  125. };
  126. render(
  127. <CheckoutOverviewV2
  128. activePlan={teamPlanAnnual}
  129. billingConfig={billingConfig}
  130. formData={formData}
  131. onUpdate={jest.fn()}
  132. organization={organization}
  133. subscription={subscription}
  134. />
  135. );
  136. expect(screen.getByText('Sentry Team Plan')).toBeInTheDocument();
  137. expect(screen.queryByTestId('additional-monthly-charge')).not.toBeInTheDocument();
  138. expect(screen.queryByText('Additional Coverage')).not.toBeInTheDocument();
  139. });
  140. });