orgStatsBanner.spec.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {MetricHistoryFixture} from 'getsentry-test/fixtures/metricHistory';
  3. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import OrgStatsBanner from 'getsentry/hooks/orgStatsBanner';
  6. import SubscriptionStore from 'getsentry/stores/subscriptionStore';
  7. describe('OrgStatsBanner', function () {
  8. let wrapper: any;
  9. afterEach(function () {
  10. jest.clearAllMocks();
  11. if (wrapper) {
  12. wrapper.unmount();
  13. }
  14. wrapper = null;
  15. });
  16. it('renders empty if not self serve', function () {
  17. const organization = OrganizationFixture();
  18. const subscription = SubscriptionFixture({
  19. organization,
  20. canSelfServe: false,
  21. });
  22. SubscriptionStore.set(organization.slug, subscription);
  23. wrapper = render(<OrgStatsBanner organization={organization} />);
  24. expect(wrapper.container).toBeEmptyDOMElement();
  25. });
  26. it('renders increase event limit CTA for billing user', function () {
  27. const organization = OrganizationFixture({
  28. access: ['org:billing'],
  29. });
  30. const subscription = SubscriptionFixture({
  31. organization,
  32. plan: 'am1_team',
  33. categories: {
  34. errors: MetricHistoryFixture({usageExceeded: false}),
  35. transactions: MetricHistoryFixture({usageExceeded: false}),
  36. attachments: MetricHistoryFixture({usageExceeded: true}),
  37. },
  38. canSelfServe: true,
  39. });
  40. SubscriptionStore.set(organization.slug, subscription);
  41. wrapper = render(<OrgStatsBanner organization={organization} />);
  42. expect(screen.getByText('Increase Reserved Limits')).toBeInTheDocument();
  43. expect(screen.getByText('Increase your Reserved Quotas')).toBeInTheDocument();
  44. });
  45. it('renders request increase event limit CTA for non-billing user', function () {
  46. const organization = OrganizationFixture({});
  47. const subscription = SubscriptionFixture({
  48. organization,
  49. plan: 'am1_team',
  50. categories: {
  51. errors: MetricHistoryFixture({usageExceeded: false}),
  52. transactions: MetricHistoryFixture({usageExceeded: false}),
  53. attachments: MetricHistoryFixture({usageExceeded: true}),
  54. },
  55. canSelfServe: true,
  56. });
  57. SubscriptionStore.set(organization.slug, subscription);
  58. wrapper = render(<OrgStatsBanner organization={organization} />);
  59. expect(screen.getByText('Request Additional Quota')).toBeInTheDocument();
  60. expect(
  61. screen.getByText('Request an Increase to Reserved Limits')
  62. ).toBeInTheDocument();
  63. });
  64. it('renders start trial for billing user', function () {
  65. const organization = OrganizationFixture({
  66. access: ['org:billing'],
  67. });
  68. const subscription = SubscriptionFixture({
  69. organization,
  70. plan: 'am1_f',
  71. categories: {
  72. errors: MetricHistoryFixture({usageExceeded: false}),
  73. transactions: MetricHistoryFixture({usageExceeded: false}),
  74. attachments: MetricHistoryFixture({usageExceeded: true}),
  75. },
  76. canSelfServe: true,
  77. canTrial: true,
  78. });
  79. SubscriptionStore.set(organization.slug, subscription);
  80. wrapper = render(<OrgStatsBanner organization={organization} />);
  81. expect(screen.getByText('Start Trial')).toBeInTheDocument();
  82. expect(screen.getByText('Try Sentry Business for Free')).toBeInTheDocument();
  83. });
  84. it('renders upgrade for billing user', function () {
  85. const organization = OrganizationFixture({
  86. access: ['org:billing'],
  87. });
  88. const subscription = SubscriptionFixture({
  89. organization,
  90. plan: 'am1_f',
  91. categories: {
  92. errors: MetricHistoryFixture({usageExceeded: false}),
  93. transactions: MetricHistoryFixture({usageExceeded: false}),
  94. attachments: MetricHistoryFixture({usageExceeded: true}),
  95. },
  96. canSelfServe: true,
  97. canTrial: false,
  98. });
  99. SubscriptionStore.set(organization.slug, subscription);
  100. wrapper = render(<OrgStatsBanner organization={organization} />);
  101. expect(screen.getByText('Upgrade Plan')).toBeInTheDocument();
  102. expect(screen.getByText('Upgrade to Business')).toBeInTheDocument();
  103. });
  104. it('renders request upgrade for non-billing user', function () {
  105. const organization = OrganizationFixture({});
  106. const subscription = SubscriptionFixture({
  107. organization,
  108. plan: 'am1_f',
  109. categories: {
  110. errors: MetricHistoryFixture({usageExceeded: false}),
  111. transactions: MetricHistoryFixture({usageExceeded: false}),
  112. attachments: MetricHistoryFixture({usageExceeded: true}),
  113. },
  114. canSelfServe: true,
  115. canTrial: false,
  116. });
  117. SubscriptionStore.set(organization.slug, subscription);
  118. wrapper = render(<OrgStatsBanner organization={organization} />);
  119. expect(screen.getByText('Request Upgrade')).toBeInTheDocument();
  120. expect(screen.getByText('Request an Upgrade to Business')).toBeInTheDocument();
  121. });
  122. });