messagingIntegrationModal.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 {t} from 'sentry/locale';
  11. import MessagingIntegrationModal from 'sentry/views/alerts/rules/issue/messagingIntegrationModal';
  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={t('Connect with a messaging tool')}
  25. bodyContent={t('Receive alerts and digests right where you work.')}
  26. providers={providers}
  27. CloseButton={makeCloseButton(() => {})}
  28. Footer={ModalFooter}
  29. {...props}
  30. />
  31. );
  32. it('renders', async function () {
  33. render(getComponent(), {organization: organization});
  34. const heading = await screen.findByRole('heading', {
  35. name: /connect with a messaging tool/i,
  36. });
  37. expect(heading).toBeInTheDocument();
  38. const buttons = await screen.findAllByRole('button', {name: /add integration/i});
  39. expect(buttons).toHaveLength(providerKeys.length);
  40. });
  41. });