cronsOnDemandStepWarning.spec.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 {PlanFixture} from 'getsentry/__fixtures__/plan';
  5. import {CronsOnDemandStepWarning} from 'getsentry/components/cronsOnDemandStepWarning';
  6. describe('CronsOnDemandStepWarning', function () {
  7. const organization = OrganizationFixture();
  8. const subscription = SubscriptionFixture({organization, plan: 'am2_team'});
  9. it('shows warning only for insufficient funds', async function () {
  10. const plan = PlanFixture({});
  11. const url = `/organizations/${organization.slug}/monitor-count/`;
  12. const mockApiCall = MockApiClient.addMockResponse({
  13. url,
  14. body: {enabledMonitorCount: 5, disabledMonitorCount: 0},
  15. });
  16. // Allocating only 1 dollar
  17. const currentOnDemand = 100;
  18. const {rerender} = render(
  19. <CronsOnDemandStepWarning
  20. activePlan={plan}
  21. currentOnDemand={currentOnDemand}
  22. organization={organization}
  23. subscription={subscription}
  24. />,
  25. {organization}
  26. );
  27. expect(mockApiCall).toHaveBeenCalled();
  28. expect(
  29. await screen.findByText(
  30. "These changes will take effect at the start of your next billing cycle. Heads up that you're currently using $3.12 of Cron Monitors. These monitors will be turned off at the start of your next billing cycle unless you increase your on-demand budget."
  31. )
  32. ).toBeInTheDocument();
  33. // Allocating enough to support 4 cron monitors + 1 free
  34. const newOnDemand = 400;
  35. rerender(
  36. <CronsOnDemandStepWarning
  37. activePlan={plan}
  38. currentOnDemand={newOnDemand}
  39. organization={organization}
  40. subscription={subscription}
  41. />
  42. );
  43. expect(
  44. screen.queryByText(
  45. "These changes will take effect at the start of your next billing cycle. Heads up that you're currently using $3.12 of Cron Monitors. These monitors will be turned off at the start of your next billing cycle unless you increase your on-demand budget."
  46. )
  47. ).not.toBeInTheDocument();
  48. });
  49. });