featureDisabled.spec.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {fireEvent, render, screen} from 'sentry-test/reactTestingLibrary';
  2. import FeatureDisabled from 'sentry/components/acl/featureDisabled';
  3. describe('FeatureDisabled', function () {
  4. it('renders', function () {
  5. render(
  6. <FeatureDisabled
  7. features={['organization:my-features']}
  8. featureName="Some Feature"
  9. />
  10. );
  11. expect(
  12. screen.getByText('This feature is not enabled on your Sentry installation.')
  13. ).toBeInTheDocument();
  14. expect(screen.getByText('Help')).toBeInTheDocument();
  15. });
  16. it('renders with custom message', function () {
  17. const customMessage = 'custom message';
  18. render(
  19. <FeatureDisabled
  20. message={customMessage}
  21. features={['organization:my-features']}
  22. featureName="Some Feature"
  23. />
  24. );
  25. expect(screen.getByText(customMessage)).toBeInTheDocument();
  26. });
  27. it('renders with custom alert component', function () {
  28. const customAlert = jest.fn().mockReturnValue(null);
  29. render(
  30. <FeatureDisabled
  31. alert={customAlert}
  32. features={['organization:my-features']}
  33. featureName="Some Feature"
  34. />
  35. );
  36. expect(customAlert).toHaveBeenCalled();
  37. });
  38. it('displays instructions when help is clicked', function () {
  39. render(
  40. <FeatureDisabled
  41. alert
  42. features={['organization:my-features']}
  43. featureName="Some Feature"
  44. />
  45. );
  46. fireEvent.click(
  47. screen.getByText('This feature is not enabled on your Sentry installation.')
  48. );
  49. expect(
  50. screen.getByText(/Enable this feature on your sentry installation/)
  51. ).toBeInTheDocument();
  52. });
  53. });