ondemandDisabled.spec.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 {textWithMarkupMatcher} from 'sentry-test/utils';
  5. import {PlanTier} from 'getsentry/types';
  6. import OnDemandDisabled from './ondemandDisabled';
  7. describe('OnDemandDisabled', function () {
  8. const organization = OrganizationFixture();
  9. it('renders nothing when onDemandDisabled is false', function () {
  10. const subscription = SubscriptionFixture({
  11. organization,
  12. onDemandDisabled: false,
  13. onDemandMaxSpend: 1000,
  14. });
  15. render(<OnDemandDisabled subscription={subscription} />);
  16. expect(screen.queryByTestId('ondemand-disabled-alert')).not.toBeInTheDocument();
  17. });
  18. it('renders nothing when onDemandMaxSpend is 0', function () {
  19. const subscription = SubscriptionFixture({
  20. organization,
  21. onDemandDisabled: true,
  22. onDemandMaxSpend: 0,
  23. });
  24. render(<OnDemandDisabled subscription={subscription} />);
  25. expect(screen.queryByTestId('ondemand-disabled-alert')).not.toBeInTheDocument();
  26. });
  27. it('renders alert for AM1 plan with on-demand terminology', function () {
  28. const subscription = SubscriptionFixture({
  29. organization,
  30. onDemandDisabled: true,
  31. onDemandMaxSpend: 1000,
  32. planTier: PlanTier.AM1,
  33. });
  34. render(<OnDemandDisabled subscription={subscription} />);
  35. expect(screen.getByTestId('ondemand-disabled-alert')).toBeInTheDocument();
  36. expect(
  37. screen.getByText(
  38. textWithMarkupMatcher(
  39. 'On-demand billing is disabled for your organization due to an unpaid on-demand invoice.'
  40. )
  41. )
  42. ).toBeInTheDocument();
  43. });
  44. it('renders alert for AM2 plan with on-demand terminology', function () {
  45. const subscription = SubscriptionFixture({
  46. organization,
  47. onDemandDisabled: true,
  48. onDemandMaxSpend: 1000,
  49. planTier: PlanTier.AM2,
  50. });
  51. render(<OnDemandDisabled subscription={subscription} />);
  52. expect(screen.getByTestId('ondemand-disabled-alert')).toBeInTheDocument();
  53. expect(
  54. screen.getByText(
  55. textWithMarkupMatcher(
  56. 'On-demand billing is disabled for your organization due to an unpaid on-demand invoice.'
  57. )
  58. )
  59. ).toBeInTheDocument();
  60. });
  61. it('renders alert for AM3 plan with pay-as-you-go terminology', function () {
  62. const subscription = SubscriptionFixture({
  63. organization,
  64. onDemandDisabled: true,
  65. onDemandMaxSpend: 1000,
  66. planTier: PlanTier.AM3,
  67. });
  68. render(<OnDemandDisabled subscription={subscription} />);
  69. expect(screen.getByTestId('ondemand-disabled-alert')).toBeInTheDocument();
  70. expect(
  71. screen.getByText(
  72. textWithMarkupMatcher(
  73. 'Pay-as-you-go billing is disabled for your organization due to an unpaid pay-as-you-go invoice.'
  74. )
  75. )
  76. ).toBeInTheDocument();
  77. });
  78. it('includes links to receipts, support email and documentation', function () {
  79. const subscription = SubscriptionFixture({
  80. organization,
  81. onDemandDisabled: true,
  82. onDemandMaxSpend: 1000,
  83. });
  84. render(<OnDemandDisabled subscription={subscription} />);
  85. expect(
  86. screen.getByRole('link', {name: 'closed/outstanding invoices'})
  87. ).toHaveAttribute('href', '/settings/billing/receipts/');
  88. expect(screen.getByRole('link', {name: 'support@sentry.io'})).toHaveAttribute(
  89. 'href',
  90. 'mailto:support@sentry.io'
  91. );
  92. expect(
  93. screen.getByRole('link', {name: 'Learn more about this process'})
  94. ).toHaveAttribute(
  95. 'href',
  96. 'https://sentry.zendesk.com/hc/en-us/articles/23622477256987-We-can-t-pay-our-on-demand-pay-as-you-go-invoice-and-have-an-annual-contract-What-happens'
  97. );
  98. });
  99. });