pageUpsellOverlay.spec.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {BillingConfigFixture} from 'getsentry-test/fixtures/billingConfig';
  3. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import PageUpsellOverlay from 'getsentry/components/features/pageUpsellOverlay';
  6. import SubscriptionStore from 'getsentry/stores/subscriptionStore';
  7. import {PlanTier} from 'getsentry/types';
  8. describe('PageUpsellOverlay', function () {
  9. let wrapper: any;
  10. afterEach(function () {
  11. if (wrapper) {
  12. wrapper.unmount();
  13. }
  14. wrapper = null;
  15. });
  16. const org = OrganizationFixture({access: ['org:billing']});
  17. MockApiClient.addMockResponse({
  18. url: `/customers/${org.slug}/billing-config/?tier=am2`,
  19. body: BillingConfigFixture(PlanTier.AM2),
  20. });
  21. it('renders customSecondaryCTA', function () {
  22. const subscription = SubscriptionFixture({
  23. organization: org,
  24. canSelfServe: true,
  25. canTrial: false,
  26. });
  27. SubscriptionStore.set(org.slug, subscription);
  28. wrapper = render(
  29. <PageUpsellOverlay
  30. organization={org}
  31. customSecondaryCTA="My Text"
  32. features={[]}
  33. name=""
  34. positioningStrategy={jest.fn()}
  35. description=""
  36. requiredPlan=""
  37. source=""
  38. />
  39. );
  40. expect(screen.queryByText('Learn More')).not.toBeInTheDocument();
  41. expect(screen.getByText('My Text')).toBeInTheDocument();
  42. expect(screen.getByText('Upgrade Plan')).toBeInTheDocument();
  43. });
  44. it('renders learn more', function () {
  45. const subscription = SubscriptionFixture({
  46. organization: org,
  47. canSelfServe: true,
  48. canTrial: false,
  49. });
  50. SubscriptionStore.set(org.slug, subscription);
  51. wrapper = render(
  52. <PageUpsellOverlay
  53. organization={org}
  54. features={[]}
  55. name=""
  56. positioningStrategy={jest.fn()}
  57. description=""
  58. requiredPlan=""
  59. source=""
  60. />
  61. );
  62. expect(screen.getByText('Learn More')).toBeInTheDocument();
  63. expect(screen.getByText('Upgrade Plan')).toBeInTheDocument();
  64. });
  65. it('does not render CTA for non-self serve', function () {
  66. const subscription = SubscriptionFixture({
  67. organization: org,
  68. canSelfServe: false,
  69. canTrial: false,
  70. });
  71. SubscriptionStore.set(org.slug, subscription);
  72. wrapper = render(
  73. <PageUpsellOverlay
  74. organization={org}
  75. features={[]}
  76. name=""
  77. positioningStrategy={jest.fn()}
  78. description=""
  79. requiredPlan=""
  80. source=""
  81. />
  82. );
  83. expect(screen.getByText('Learn More')).toBeInTheDocument();
  84. expect(screen.queryByText('Upgrade Plan')).not.toBeInTheDocument();
  85. });
  86. });