featureDisabled.spec.jsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React from 'react';
  2. import {PanelAlert} from 'app/components/panels';
  3. import {mount} from 'enzyme';
  4. import FeatureDisabled from 'app/components/acl/featureDisabled';
  5. describe('FeatureDisabled', function() {
  6. const routerContext = TestStubs.routerContext();
  7. it('renders', function() {
  8. const wrapper = mount(
  9. <FeatureDisabled
  10. features={['organization:my-features']}
  11. featureName="Some Feature"
  12. />,
  13. routerContext
  14. );
  15. expect(
  16. wrapper
  17. .find('[data-test-id="feature-message"]')
  18. .first()
  19. .text()
  20. ).toEqual(
  21. expect.stringContaining('This feature is not enabled on your Sentry installation.')
  22. );
  23. expect(wrapper.exists('HelpButton')).toBe(true);
  24. });
  25. it('renders with custom message', function() {
  26. const customMessage = 'custom message';
  27. const wrapper = mount(
  28. <FeatureDisabled
  29. message={customMessage}
  30. features={['organization:my-features']}
  31. featureName="Some Feature"
  32. />,
  33. routerContext
  34. );
  35. expect(
  36. wrapper
  37. .find('[data-test-id="feature-message"]')
  38. .first()
  39. .text()
  40. ).toEqual(expect.stringContaining(customMessage));
  41. });
  42. it('renders as an Alert', function() {
  43. const wrapper = mount(
  44. <FeatureDisabled
  45. alert
  46. features={['organization:my-features']}
  47. featureName="Some Feature"
  48. />,
  49. routerContext
  50. );
  51. expect(wrapper.exists('Alert')).toBe(true);
  52. });
  53. it('renders with custom alert component', function() {
  54. const wrapper = mount(
  55. <FeatureDisabled
  56. alert={PanelAlert}
  57. features={['organization:my-features']}
  58. featureName="Some Feature"
  59. />,
  60. routerContext
  61. );
  62. expect(wrapper.exists('PanelAlert')).toBe(true);
  63. });
  64. it('displays instructions when help is clicked', function() {
  65. const wrapper = mount(
  66. <FeatureDisabled
  67. alert
  68. features={['organization:my-features']}
  69. featureName="Some Feature"
  70. />,
  71. routerContext
  72. );
  73. wrapper.find('HelpButton').simulate('click');
  74. wrapper.update();
  75. expect(wrapper.exists('HelpDescription')).toBe(true);
  76. });
  77. });