setupAlertIntegrationButton.spec.tsx 1.3 KB

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