setupAlertIntegrationButton.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. describe('SetupAlertIntegrationButton', function () {
  6. const organization = OrganizationFixture();
  7. const project = ProjectFixture();
  8. it('renders button if no alert integrations', function () {
  9. MockApiClient.addMockResponse({
  10. url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
  11. body: {
  12. ...project,
  13. hasAlertIntegrationInstalled: false,
  14. },
  15. });
  16. const {container} = render(
  17. <SetupAlertIntegrationButton
  18. projectSlug={project.slug}
  19. organization={organization}
  20. />
  21. );
  22. expect(container).toHaveTextContent('Set Up Slack Now');
  23. });
  24. it('does not renders button if alert integration installed', function () {
  25. MockApiClient.addMockResponse({
  26. url: `/projects/${organization.slug}/${project.slug}/?expand=hasAlertIntegration`,
  27. body: {
  28. ...project,
  29. hasAlertIntegrationInstalled: true,
  30. },
  31. });
  32. const {container} = render(
  33. <SetupAlertIntegrationButton
  34. projectSlug={project.slug}
  35. organization={organization}
  36. />
  37. );
  38. expect(container).not.toHaveTextContent('Set Up Slack Now');
  39. });
  40. });