forcedTrialModal.spec.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import moment from 'moment-timezone';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {SubscriptionFixture} from 'getsentry-test/fixtures/subscription';
  4. import {render, screen} from 'sentry-test/reactTestingLibrary';
  5. import ForcedTrialModal from 'getsentry/components/forcedTrialModal';
  6. import SubscriptionStore from 'getsentry/stores/subscriptionStore';
  7. const slug = 'my-org';
  8. describe('ForcedTrialModal', function () {
  9. let org: any, sub: any;
  10. const populateOrgAndSub = (orgParams = {}, subParams = {}) => {
  11. const now = moment();
  12. org = OrganizationFixture({
  13. slug,
  14. access: ['org:billing'],
  15. ...orgParams,
  16. });
  17. sub = SubscriptionFixture({
  18. organization: org,
  19. trialEnd: now.add(14, 'day').toString(),
  20. ...subParams,
  21. });
  22. SubscriptionStore.set(org.slug, sub);
  23. };
  24. describe('member limit', function () {
  25. beforeEach(function () {
  26. MockApiClient.addMockResponse({
  27. url: `/organizations/${slug}/integrations/?includeConfig=0`,
  28. method: 'GET',
  29. body: [
  30. {
  31. provider: {
  32. slug: 'msteams',
  33. name: 'Microsoft Teams',
  34. },
  35. },
  36. ],
  37. });
  38. });
  39. it('shows request upgrade when user does not have billing permissions', function () {
  40. populateOrgAndSub({access: []});
  41. render(<ForcedTrialModal closeModal={jest.fn()} organization={org} />);
  42. expect(screen.getByLabelText('Request Upgrade')).toBeInTheDocument();
  43. expect(
  44. screen.getByText('You may lose access to Sentry in 14 days')
  45. ).toBeInTheDocument();
  46. });
  47. it('shows upgrade now when user has billing permissions', function () {
  48. populateOrgAndSub();
  49. render(<ForcedTrialModal closeModal={jest.fn()} organization={org} />);
  50. expect(screen.getByLabelText('Upgrade')).toBeInTheDocument();
  51. expect(
  52. screen.getByText('Members may lose access to Sentry in 14 days')
  53. ).toBeInTheDocument();
  54. });
  55. });
  56. describe('disallowed integration', function () {
  57. beforeEach(function () {
  58. MockApiClient.addMockResponse({
  59. url: `/organizations/${slug}/integrations/?includeConfig=0`,
  60. method: 'GET',
  61. body: [
  62. {
  63. provider: {
  64. slug: 'slack',
  65. name: 'Slack',
  66. },
  67. },
  68. ],
  69. });
  70. });
  71. it('shows upgrade button if has slack', function () {
  72. populateOrgAndSub();
  73. render(<ForcedTrialModal closeModal={jest.fn()} organization={org} />);
  74. expect(screen.getByLabelText('Upgrade')).toBeInTheDocument();
  75. expect(
  76. screen.getByText('Your Slack integration will stop working in 14 days')
  77. ).toBeInTheDocument();
  78. });
  79. });
  80. });