redeemPromoCode.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  3. import {initializeOrg} from 'sentry-test/initializeOrg';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import SubscriptionStore from 'getsentry/stores/subscriptionStore';
  6. import {PlanTier} from 'getsentry/types';
  7. import RedeemPromoCode from 'getsentry/views/redeemPromoCode';
  8. describe('Redeem promo code', () => {
  9. const organization = OrganizationFixture({access: ['org:billing']});
  10. const {router} = initializeOrg({
  11. organization,
  12. });
  13. beforeEach(function () {
  14. SubscriptionStore.set(organization.slug, {});
  15. });
  16. it('renders redeem promo code page', function () {
  17. const subscription = SubscriptionFixture({
  18. plan: 'am1_f',
  19. planTier: PlanTier.AM1,
  20. organization,
  21. });
  22. SubscriptionStore.set(organization.slug, subscription);
  23. render(
  24. <RedeemPromoCode
  25. router={router}
  26. location={router.location}
  27. routes={router.routes}
  28. routeParams={router.params}
  29. route={{}}
  30. params={{orgId: organization.slug}}
  31. />,
  32. {
  33. router,
  34. organization,
  35. }
  36. );
  37. expect(screen.queryAllByText('Redeem Promotional Code')).toHaveLength(2);
  38. });
  39. it('does not render redeem promo code page for YY partnership orgs', async function () {
  40. const subscription = SubscriptionFixture({
  41. plan: 'am2_business',
  42. planTier: 'am2',
  43. partner: {
  44. externalId: 'x123x',
  45. name: 'YY Org',
  46. partnership: {
  47. id: 'YY',
  48. displayName: 'YY',
  49. supportNote: 'foo',
  50. },
  51. isActive: true,
  52. },
  53. organization,
  54. });
  55. SubscriptionStore.set(organization.slug, subscription);
  56. render(
  57. <RedeemPromoCode
  58. router={router}
  59. location={router.location}
  60. routes={router.routes}
  61. routeParams={router.params}
  62. route={{}}
  63. params={{orgId: organization.slug}}
  64. />,
  65. {
  66. router,
  67. organization,
  68. }
  69. );
  70. expect(await screen.findByTestId('partnership-note')).toBeInTheDocument();
  71. expect(screen.queryByText('Redeem Promotional Code')).not.toBeInTheDocument();
  72. });
  73. });