featureDisabledModal.spec.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import {ComponentProps} from 'react';
  2. import styled from '@emotion/styled';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import {FeatureDisabledModal} from 'sentry/components/acl/featureDisabledModal';
  5. import ModalStore from 'sentry/stores/modalStore';
  6. describe('FeatureTourModal', function () {
  7. const onCloseModal = jest.fn();
  8. const styledWrapper = styled(c => c.children);
  9. const renderComponent = (
  10. props: Partial<ComponentProps<typeof FeatureDisabledModal>> = {}
  11. ) =>
  12. render(
  13. <FeatureDisabledModal
  14. Body={styledWrapper()}
  15. Footer={styledWrapper()}
  16. Header={() => <span>Header</span>}
  17. closeModal={onCloseModal}
  18. CloseButton={() => <button>Close</button>}
  19. featureName="Default Feature"
  20. features={['organization:test-feature']}
  21. {...props}
  22. />
  23. );
  24. beforeEach(function () {
  25. ModalStore.reset();
  26. jest.clearAllMocks();
  27. });
  28. it('renders', function () {
  29. const featureName = 'Custom Feature';
  30. const features = ['organization:custom-feature'];
  31. renderComponent({
  32. featureName,
  33. features,
  34. });
  35. expect(
  36. screen.getByText('This feature is not enabled on your Sentry installation.')
  37. ).toBeInTheDocument();
  38. expect(screen.getByText(/# Enables the Custom Feature feature/)).toBeInTheDocument();
  39. expect(
  40. screen.getByText(/SENTRY_FEATURES\['organization:custom-feature'\] = True/)
  41. ).toBeInTheDocument();
  42. });
  43. it('renders with custom message', function () {
  44. const message = 'custom message';
  45. renderComponent({
  46. message,
  47. });
  48. expect(screen.getByText(message)).toBeInTheDocument();
  49. });
  50. });