organizationAuthList.spec.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import OrganizationAuthList from 'sentry/views/settings/organizationAuth/organizationAuthList';
  3. describe('OrganizationAuthList', function () {
  4. it('renders with no providers', function () {
  5. const {container} = render(<OrganizationAuthList providerList={[]} />);
  6. expect(container).toSnapshot();
  7. });
  8. it('renders', function () {
  9. const {container} = render(
  10. <OrganizationAuthList
  11. orgId="org-slug"
  12. onSendReminders={() => {}}
  13. providerList={TestStubs.AuthProviders()}
  14. />
  15. );
  16. expect(container).toSnapshot();
  17. });
  18. it('renders for members', function () {
  19. const context = TestStubs.routerContext([
  20. {organization: TestStubs.Organization({access: ['org:read']})},
  21. ]);
  22. render(
  23. <OrganizationAuthList
  24. orgId="org-slug"
  25. onSendReminders={() => {}}
  26. providerList={TestStubs.AuthProviders()}
  27. activeProvider={TestStubs.AuthProviders()[0]}
  28. />,
  29. {context}
  30. );
  31. expect(screen.getByText('Active')).toBeInTheDocument();
  32. });
  33. describe('with 2fa warning', function () {
  34. const require2fa = {require2FA: true};
  35. const withSSO = {features: ['sso-basic']};
  36. const withSAML = {features: ['sso-saml2']};
  37. it('renders', function () {
  38. const context = TestStubs.routerContext([
  39. {organization: TestStubs.Organization({...require2fa, ...withSSO})},
  40. ]);
  41. render(
  42. <OrganizationAuthList
  43. orgId="org-slug"
  44. onSendReminders={() => {}}
  45. providerList={TestStubs.AuthProviders()}
  46. />,
  47. {context}
  48. );
  49. expect(
  50. screen.getByText('Require 2FA will be disabled if you enable SSO.')
  51. ).toBeInTheDocument();
  52. });
  53. it('renders with saml available', function () {
  54. const context = TestStubs.routerContext([
  55. {organization: TestStubs.Organization({...require2fa, ...withSAML})},
  56. ]);
  57. render(
  58. <OrganizationAuthList
  59. orgId="org-slug"
  60. onSendReminders={() => {}}
  61. providerList={TestStubs.AuthProviders()}
  62. />,
  63. {context}
  64. );
  65. expect(
  66. screen.getByText('Require 2FA will be disabled if you enable SSO.')
  67. ).toBeInTheDocument();
  68. });
  69. it('does not render without sso available', function () {
  70. const context = TestStubs.routerContext([
  71. {organization: TestStubs.Organization({...require2fa})},
  72. ]);
  73. render(
  74. <OrganizationAuthList
  75. orgId="org-slug"
  76. onSendReminders={() => {}}
  77. providerList={TestStubs.AuthProviders()}
  78. />,
  79. {context}
  80. );
  81. expect(
  82. screen.queryByText('Require 2FA will be disabled if you enable SSO.')
  83. ).not.toBeInTheDocument();
  84. });
  85. it('does not render with sso and require 2fa disabled', function () {
  86. const context = TestStubs.routerContext([
  87. {organization: TestStubs.Organization({...withSSO})},
  88. ]);
  89. render(
  90. <OrganizationAuthList
  91. orgId="org-slug"
  92. onSendReminders={() => {}}
  93. providerList={TestStubs.AuthProviders()}
  94. />,
  95. {context}
  96. );
  97. expect(
  98. screen.queryByText('Require 2FA will be disabled if you enable SSO.')
  99. ).not.toBeInTheDocument();
  100. });
  101. it('does not render with saml and require 2fa disabled', function () {
  102. const context = TestStubs.routerContext([
  103. {organization: TestStubs.Organization({...withSAML})},
  104. ]);
  105. render(
  106. <OrganizationAuthList
  107. orgId="org-slug"
  108. onSendReminders={() => {}}
  109. providerList={TestStubs.AuthProviders()}
  110. />,
  111. {context}
  112. );
  113. expect(
  114. screen.queryByText('Require 2FA will be disabled if you enable SSO.')
  115. ).not.toBeInTheDocument();
  116. });
  117. });
  118. });