managedNote.spec.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 {BillingType} from 'getsentry/types';
  5. import ManagedNote from 'getsentry/views/subscriptionPage/managedNote';
  6. describe('ManagedNote', function () {
  7. const organization = OrganizationFixture();
  8. it('renders nothing when subscription can self-serve', function () {
  9. const subscription = SubscriptionFixture({
  10. organization,
  11. canSelfServe: true,
  12. });
  13. const {container} = render(<ManagedNote subscription={subscription} />);
  14. expect(container).toBeEmptyDOMElement();
  15. });
  16. it('renders nothing for VC partner', function () {
  17. const subscription = SubscriptionFixture({
  18. organization,
  19. canSelfServe: false,
  20. partner: {
  21. externalId: 'x123x',
  22. name: 'Org',
  23. partnership: {
  24. id: 'VC',
  25. displayName: 'XX',
  26. supportNote: '',
  27. },
  28. isActive: true,
  29. },
  30. });
  31. const {container} = render(<ManagedNote subscription={subscription} />);
  32. expect(container).toBeEmptyDOMElement();
  33. });
  34. it('renders sales message for invoiced subscriptions', function () {
  35. const subscription = SubscriptionFixture({
  36. organization,
  37. canSelfServe: false,
  38. type: BillingType.INVOICED,
  39. });
  40. render(<ManagedNote subscription={subscription} />);
  41. expect(screen.getByRole('link')).toHaveAttribute('href', 'mailto:sales@sentry.io');
  42. expect(screen.getByTestId('managed-note')).toHaveTextContent(
  43. 'Contact us at sales@sentry.io to make changes to your subscription.'
  44. );
  45. });
  46. it('renders sales message for custom price subscriptions', function () {
  47. const subscription = SubscriptionFixture({
  48. organization,
  49. canSelfServe: false,
  50. customPrice: 100,
  51. });
  52. render(<ManagedNote subscription={subscription} />);
  53. expect(screen.getByRole('link')).toHaveAttribute('href', 'mailto:sales@sentry.io');
  54. expect(screen.getByTestId('managed-note')).toHaveTextContent(
  55. 'Contact us at sales@sentry.io to make changes to your subscription.'
  56. );
  57. });
  58. it('renders GitHub marketplace message for GitHub partner', function () {
  59. const subscription = SubscriptionFixture({
  60. organization,
  61. canSelfServe: false,
  62. partner: {
  63. externalId: 'x123x',
  64. name: 'GitHub Org',
  65. partnership: {
  66. id: 'GH',
  67. displayName: 'GitHub',
  68. supportNote: '',
  69. },
  70. isActive: true,
  71. },
  72. });
  73. render(<ManagedNote subscription={subscription} />);
  74. expect(screen.getByRole('link')).toHaveAttribute(
  75. 'href',
  76. 'https://github.com/marketplace/sentry'
  77. );
  78. expect(screen.getByTestId('managed-note')).toHaveTextContent(
  79. 'Visit the GitHub Marketplace to make changes to your subscription.'
  80. );
  81. });
  82. it('renders Heroku dashboard message for Heroku partner', function () {
  83. const subscription = SubscriptionFixture({
  84. organization,
  85. canSelfServe: false,
  86. partner: {
  87. externalId: 'x123x',
  88. name: 'Heroku Org',
  89. partnership: {
  90. id: 'HK',
  91. displayName: 'Heroku',
  92. supportNote: '',
  93. },
  94. isActive: true,
  95. },
  96. });
  97. render(<ManagedNote subscription={subscription} />);
  98. expect(screen.getByRole('link')).toHaveAttribute(
  99. 'href',
  100. 'https://dashboard.heroku.com'
  101. );
  102. expect(screen.getByTestId('managed-note')).toHaveTextContent(
  103. 'Visit the Heroku Dashboard to make changes to your subscription.'
  104. );
  105. });
  106. it('renders default support message for other cases', function () {
  107. const subscription = SubscriptionFixture({
  108. organization,
  109. canSelfServe: false,
  110. });
  111. render(<ManagedNote subscription={subscription} />);
  112. expect(screen.getByRole('link')).toHaveAttribute('href', 'mailto:support@sentry.io');
  113. expect(screen.getByTestId('managed-note')).toHaveTextContent(
  114. 'Contact us at support@sentry.io to make changes to your subscription.'
  115. );
  116. });
  117. });