messagingIntegrationModal.spec.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {GitHubIntegrationProviderFixture} from 'sentry-fixture/githubIntegrationProvider';
  2. import {OrganizationFixture} from 'sentry-fixture/organization';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import {
  5. makeClosableHeader,
  6. makeCloseButton,
  7. ModalBody,
  8. ModalFooter,
  9. } from 'sentry/components/globalModal/components';
  10. import MessagingIntegrationModal from 'sentry/views/alerts/rules/issue/messagingIntegrationModal';
  11. import {MessagingIntegrationAnalyticsView} from 'sentry/views/alerts/rules/issue/setupMessagingIntegrationButton';
  12. jest.mock('sentry/actionCreators/modal');
  13. describe('MessagingIntegrationModal', function () {
  14. const organization = OrganizationFixture();
  15. const providerKeys = ['slack', 'discord', 'msteams'];
  16. const providers = providerKeys.map(providerKey =>
  17. GitHubIntegrationProviderFixture({key: providerKey})
  18. );
  19. const getComponent = (closeModal = jest.fn(), props = {}) => (
  20. <MessagingIntegrationModal
  21. closeModal={closeModal}
  22. Header={makeClosableHeader(() => {})}
  23. Body={ModalBody}
  24. headerContent={'Connect with a messaging tool'}
  25. bodyContent={'Receive alerts and digests right where you work.'}
  26. providers={providers}
  27. CloseButton={makeCloseButton(() => {})}
  28. Footer={ModalFooter}
  29. analyticsView={MessagingIntegrationAnalyticsView.PROJECT_CREATION}
  30. {...props}
  31. />
  32. );
  33. it('renders', async function () {
  34. render(getComponent(), {organization});
  35. const heading = await screen.findByRole('heading', {
  36. name: /connect with a messaging tool/i,
  37. });
  38. expect(heading).toBeInTheDocument();
  39. const buttons = await screen.findAllByRole('button', {name: /add integration/i});
  40. expect(buttons).toHaveLength(providerKeys.length);
  41. });
  42. });