setupAlertIntegrationButton.spec.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {ProjectFixture} from 'sentry-fixture/project';
  3. import {render} from 'sentry-test/reactTestingLibrary';
  4. import SetupAlertIntegrationButton from 'sentry/views/alerts/rules/issue/setupAlertIntegrationButton';
  5. jest.mock('sentry/actionCreators/modal');
  6. describe('SetupAlertIntegrationButton', function () {
  7. const organization = OrganizationFixture();
  8. const project = ProjectFixture();
  9. it('renders slack button if no alert integrations are installed', function () {
  10. MockApiClient.addMockResponse({
  11. url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
  12. body: {
  13. ...project,
  14. hasAlertIntegrationInstalled: false,
  15. },
  16. });
  17. const {container} = render(
  18. <SetupAlertIntegrationButton
  19. projectSlug={project.slug}
  20. organization={organization}
  21. refetchConfigs={jest.fn()}
  22. />
  23. );
  24. expect(container).toHaveTextContent('Set Up Slack Now');
  25. });
  26. it('does not render button if alert integration is installed', function () {
  27. MockApiClient.addMockResponse({
  28. url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
  29. body: {
  30. ...project,
  31. hasAlertIntegrationInstalled: true,
  32. },
  33. });
  34. const {container} = render(
  35. <SetupAlertIntegrationButton
  36. projectSlug={project.slug}
  37. organization={organization}
  38. refetchConfigs={jest.fn()}
  39. />
  40. );
  41. expect(container).not.toHaveTextContent('Set Up Slack Now');
  42. });
  43. });