subscriptionUpsellBanner.spec.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 {SubscriptionUpsellBanner} from './subscriptionUpsellBanner';
  5. describe('SubscriptionUpsellBanner', () => {
  6. beforeEach(() => {
  7. const promptResponse = {
  8. dismissed_ts: undefined,
  9. snoozed_ts: undefined,
  10. };
  11. MockApiClient.addMockResponse({
  12. url: `/organizations/org-slug/prompts-activity/`,
  13. body: promptResponse,
  14. });
  15. MockApiClient.addMockResponse({
  16. url: `/customers/org-slug/plan-migrations/?applied=0`,
  17. method: 'GET',
  18. body: {},
  19. });
  20. MockApiClient.addMockResponse({
  21. url: `/subscriptions/org-slug/`,
  22. body: {},
  23. });
  24. MockApiClient.addMockResponse({
  25. url: `/customers/org-slug/plan-migrations/`,
  26. query: {scheduled: 1, applied: 0},
  27. method: 'GET',
  28. body: [],
  29. });
  30. });
  31. it('should render banner for users on free plan with billing access', async () => {
  32. const organization = OrganizationFixture({access: ['org:billing']});
  33. const subscription = SubscriptionFixture({
  34. organization,
  35. planTier: 'am2',
  36. plan: 'am2_f',
  37. });
  38. render(
  39. <SubscriptionUpsellBanner
  40. organization={organization}
  41. subscription={subscription}
  42. />,
  43. {organization}
  44. );
  45. expect(await screen.findByText('Try Sentry Business for Free')).toBeInTheDocument();
  46. expect(
  47. screen.getByText(/Activate your trial to take advantage of/)
  48. ).toBeInTheDocument();
  49. expect(screen.getByRole('button', {name: 'Start Trial'})).toBeInTheDocument();
  50. });
  51. it('should render banner for users on free plan without billing access', async () => {
  52. const organization = OrganizationFixture();
  53. const subscription = SubscriptionFixture({
  54. organization,
  55. planTier: 'am2',
  56. plan: 'am2_f',
  57. });
  58. render(
  59. <SubscriptionUpsellBanner
  60. organization={organization}
  61. subscription={subscription}
  62. />,
  63. {organization}
  64. );
  65. expect(
  66. await screen.findByText('Request a Free Sentry Business Trial')
  67. ).toBeInTheDocument();
  68. expect(
  69. screen.getByText(/your Organization’s owner to start a Business plan/)
  70. ).toBeInTheDocument();
  71. expect(screen.getByRole('button', {name: 'Request Trial'})).toBeInTheDocument();
  72. });
  73. });