promotionReminderModal.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {DiscountInfoFixture} from 'getsentry-test/fixtures/discountInfo';
  2. import {PromotionFixture} from 'getsentry-test/fixtures/promotion';
  3. import {renderGlobalModal, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import {openPromotionReminderModal} from 'getsentry/actionCreators/modal';
  5. import type {PromotionClaimed} from 'getsentry/types';
  6. describe('Promotion Reminder Modal', function () {
  7. const cancelFn = jest.fn();
  8. const promotionClaimed: PromotionClaimed = {
  9. promotion: PromotionFixture({
  10. name: 'Test Promotion',
  11. slug: 'test_promotion',
  12. showDiscountInfo: true,
  13. discountInfo: DiscountInfoFixture({
  14. amount: 2500,
  15. billingInterval: 'monthly',
  16. billingPeriods: 3,
  17. discountType: 'percentPoints',
  18. disclaimerText:
  19. "*Receive 40% off the monthly price of Sentry's Team or Business plan subscriptions for your first three months if you upgrade today",
  20. durationText: 'First three months',
  21. maxCentsPerPeriod: 10000,
  22. reminderText:
  23. 'Changing your plan type from Business to Team will cancel your current promotion.',
  24. }),
  25. }),
  26. dateClaimed: '2023-03-01T10:00:00.000Z',
  27. dateCompleted: '2023-03-01T10:00:00.000Z',
  28. dateExpired: '2023-03-04T10:00:00.000Z',
  29. freeEventCreditDaysLeft: 0,
  30. isLastCycleForFreeEvents: false,
  31. };
  32. it('renders promotion reminder modal', async function () {
  33. openPromotionReminderModal(promotionClaimed, cancelFn);
  34. renderGlobalModal();
  35. expect(screen.getByText('Promotion Conflict')).toBeInTheDocument();
  36. expect(screen.getByText('Current Promotion:')).toBeInTheDocument();
  37. expect(
  38. screen.getByText(
  39. 'Changing your plan type from Business to Team will cancel your current promotion.'
  40. )
  41. ).toBeInTheDocument();
  42. expect(
  43. screen.getByText('25% off (up to $100 per month) for 3 months starting on 3/1/2023')
  44. ).toBeInTheDocument();
  45. expect(screen.getByText('Cancel')).toBeInTheDocument();
  46. expect(screen.getByText('Downgrade Anyway')).toBeInTheDocument();
  47. await userEvent.click(screen.getByRole('button', {name: 'Cancel'}));
  48. expect(cancelFn).toHaveBeenCalled();
  49. });
  50. });