featureDisabled.spec.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 features="organization:my-features" featureName="Some Feature" />
  7. );
  8. expect(
  9. screen.getByText('This feature is not enabled on your Sentry installation.')
  10. ).toBeInTheDocument();
  11. expect(screen.getByText('Help')).toBeInTheDocument();
  12. });
  13. it('supports a list of disabled features', function () {
  14. render(
  15. <FeatureDisabled
  16. features={['organization:my-features', 'organization:other-feature']}
  17. featureName="Some Feature"
  18. />
  19. );
  20. expect(
  21. screen.getByText('This feature is not enabled on your Sentry installation.')
  22. ).toBeInTheDocument();
  23. expect(screen.getByText('Help')).toBeInTheDocument();
  24. });
  25. it('renders with custom message', function () {
  26. const customMessage = 'custom message';
  27. render(
  28. <FeatureDisabled
  29. message={customMessage}
  30. features="organization:my-features"
  31. featureName="Some Feature"
  32. />
  33. );
  34. expect(screen.getByText(customMessage)).toBeInTheDocument();
  35. });
  36. it('renders with custom alert component', function () {
  37. const customAlert = jest.fn().mockReturnValue(null);
  38. render(
  39. <FeatureDisabled
  40. alert={customAlert}
  41. features="organization:my-features"
  42. featureName="Some Feature"
  43. />
  44. );
  45. expect(customAlert).toHaveBeenCalled();
  46. });
  47. it('displays instructions when help is clicked', function () {
  48. render(
  49. <FeatureDisabled
  50. alert
  51. features="organization:my-features"
  52. featureName="Some Feature"
  53. />
  54. );
  55. fireEvent.click(
  56. screen.getByText('This feature is not enabled on your Sentry installation.')
  57. );
  58. expect(
  59. screen.getByText(/Enable this feature on your sentry installation/)
  60. ).toBeInTheDocument();
  61. });
  62. });