import React from 'react'; import { render, waitFor, screen } from '@testing-library/react'; import { IntlProvider } from 'react-intl'; import { QueryClient, QueryClientProvider } from 'react-query'; import { ThemeProvider, lightTheme } from '@strapi/design-system'; import { useRBAC } from '@strapi/helper-plugin'; import ProtectedAdvancedSettingsPage from '../index'; import server from './utils/server'; jest.mock('@strapi/helper-plugin', () => ({ ...jest.requireActual('@strapi/helper-plugin'), useNotification: jest.fn(), useFocusWhenNavigate: jest.fn(), useOverlayBlocker: jest.fn(() => ({ lockApp: jest.fn, unlockApp: jest.fn() })), useRBAC: jest.fn(), CheckPagePermissions: ({ children }) => children, })); const client = new QueryClient({ defaultOptions: { queries: { retry: false, }, }, }); const App = ( ); describe('ADMIN | Pages | Settings | Advanced Settings', () => { beforeAll(() => server.listen()); beforeEach(() => { jest.clearAllMocks(); }); afterEach(() => { server.resetHandlers(); }); afterAll(() => { jest.resetAllMocks(); server.close(); }); it('renders and matches the snapshot', async () => { useRBAC.mockImplementation(() => ({ isLoading: false, allowedActions: { canUpdate: true }, })); const { container } = render(App); await waitFor(() => { expect(screen.getByText('Default role for authenticated users')).toBeInTheDocument(); }); expect(container.firstChild).toMatchInlineSnapshot(` .c13 { background: #ffffff; padding-top: 24px; padding-right: 32px; padding-bottom: 24px; padding-left: 32px; border-radius: 4px; box-shadow: 0px 1px 4px rgba(33,33,52,0.1); } .c11 { font-weight: 600; color: #32324d; font-size: 0.75rem; line-height: 1.33; } .c8 { padding-right: 8px; } .c5 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; cursor: pointer; padding: 8px; border-radius: 4px; background: #ffffff; border: 1px solid #dcdce4; position: relative; outline: none; } .c5 svg { height: 12px; width: 12px; } .c5 svg > g, .c5 svg path { fill: #ffffff; } .c5[aria-disabled='true'] { pointer-events: none; } .c5:after { -webkit-transition-property: all; transition-property: all; -webkit-transition-duration: 0.2s; transition-duration: 0.2s; border-radius: 8px; content: ''; position: absolute; top: -4px; bottom: -4px; left: -4px; right: -4px; border: 2px solid transparent; } .c5:focus-visible { outline: none; } .c5:focus-visible:after { border-radius: 8px; content: ''; position: absolute; top: -5px; bottom: -5px; left: -5px; right: -5px; border: 2px solid #4945ff; } .c9 { height: 100%; } .c6 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; padding: 8px 16px; background: #4945ff; border: 1px solid #4945ff; } .c6 .c7 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } .c6 .c10 { color: #ffffff; } .c6[aria-disabled='true'] { border: 1px solid #dcdce4; background: #eaeaef; } .c6[aria-disabled='true'] .c10 { color: #666687; } .c6[aria-disabled='true'] svg > g, .c6[aria-disabled='true'] svg path { fill: #666687; } .c6[aria-disabled='true']:active { border: 1px solid #dcdce4; background: #eaeaef; } .c6[aria-disabled='true']:active .c10 { color: #666687; } .c6[aria-disabled='true']:active svg > g, .c6[aria-disabled='true']:active svg path { fill: #666687; } .c6:hover { border: 1px solid #7b79ff; background: #7b79ff; } .c6:active { border: 1px solid #4945ff; background: #4945ff; } .c6 svg > g, .c6 svg path { fill: #ffffff; } .c24 { position: absolute; left: 0; right: 0; bottom: 0; top: 0; width: 100%; background: transparent; border: none; } .c24:focus { outline: none; } .c24[aria-disabled='true'] { cursor: not-allowed; } .c27 { padding-right: 16px; padding-left: 16px; } .c29 { padding-left: 12px; } .c19 { -webkit-align-items: stretch; -webkit-box-align: stretch; -ms-flex-align: stretch; align-items: stretch; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } .c22 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; } .c25 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between; } .c21 { font-weight: 600; color: #32324d; font-size: 0.75rem; line-height: 1.33; } .c28 { color: #32324d; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.875rem; line-height: 1.43; } .c32 { color: #666687; font-size: 0.75rem; line-height: 1.33; } .c20 > * { margin-top: 0; margin-bottom: 0; } .c20 > * + * { margin-top: 4px; } .c23 { position: relative; border: 1px solid #dcdce4; padding-right: 12px; border-radius: 4px; background: #ffffff; overflow: hidden; min-height: 2.5rem; outline: none; box-shadow: 0; -webkit-transition-property: border-color,box-shadow,fill; transition-property: border-color,box-shadow,fill; -webkit-transition-duration: 0.2s; transition-duration: 0.2s; } .c23:focus-within { border: 1px solid #4945ff; box-shadow: #4945ff 0px 0px 0px 2px; } .c30 { background: transparent; border: none; position: relative; z-index: 1; } .c30 svg { height: 0.6875rem; width: 0.6875rem; } .c30 svg path { fill: #666687; } .c31 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; background: none; border: none; } .c31 svg { width: 0.375rem; } .c26 { width: 100%; } .c14 { -webkit-align-items: stretch; -webkit-box-align: stretch; -ms-flex-align: stretch; align-items: stretch; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } .c15 > * { margin-top: 0; margin-bottom: 0; } .c15 > * + * { margin-top: 16px; } .c51 { -webkit-align-items: stretch; -webkit-box-align: stretch; -ms-flex-align: stretch; align-items: stretch; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } .c54 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; } .c55 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between; } .c53 { font-weight: 600; color: #32324d; font-size: 0.75rem; line-height: 1.33; } .c58 { color: #666687; font-size: 0.75rem; line-height: 1.33; } .c57 { border: none; border-radius: 4px; padding-bottom: 0.65625rem; padding-left: 16px; padding-right: 16px; padding-top: 0.65625rem; color: #32324d; font-weight: 400; font-size: 0.875rem; display: block; width: 100%; background: inherit; } .c57::-webkit-input-placeholder { color: #8e8ea9; opacity: 1; } .c57::-moz-placeholder { color: #8e8ea9; opacity: 1; } .c57:-ms-input-placeholder { color: #8e8ea9; opacity: 1; } .c57::placeholder { color: #8e8ea9; opacity: 1; } .c57[aria-disabled='true'] { color: inherit; } .c57:focus { outline: none; box-shadow: none; } .c60 { border: none; border-radius: 4px; padding-bottom: 0.65625rem; padding-left: 16px; padding-right: 16px; padding-top: 0.65625rem; cursor: not-allowed; color: #32324d; font-weight: 400; font-size: 0.875rem; display: block; width: 100%; background: inherit; } .c60::-webkit-input-placeholder { color: #8e8ea9; opacity: 1; } .c60::-moz-placeholder { color: #8e8ea9; opacity: 1; } .c60:-ms-input-placeholder { color: #8e8ea9; opacity: 1; } .c60::placeholder { color: #8e8ea9; opacity: 1; } .c60[aria-disabled='true'] { color: inherit; } .c60:focus { outline: none; box-shadow: none; } .c56 { border: 1px solid #dcdce4; border-radius: 4px; background: #ffffff; outline: none; box-shadow: 0; -webkit-transition-property: border-color,box-shadow,fill; transition-property: border-color,box-shadow,fill; -webkit-transition-duration: 0.2s; transition-duration: 0.2s; } .c56:focus-within { border: 1px solid #4945ff; box-shadow: #4945ff 0px 0px 0px 2px; } .c59 { border: 1px solid #dcdce4; border-radius: 4px; background: #ffffff; outline: none; box-shadow: 0; -webkit-transition-property: border-color,box-shadow,fill; transition-property: border-color,box-shadow,fill; -webkit-transition-duration: 0.2s; transition-duration: 0.2s; color: #666687; background: #eaeaef; } .c59:focus-within { border: 1px solid #4945ff; box-shadow: #4945ff 0px 0px 0px 2px; } .c52 > * { margin-top: 0; margin-bottom: 0; } .c52 > * + * { margin-top: 4px; } .c41 { background: #f6f6f9; padding: 4px; border-radius: 4px; border-style: solid; border-width: 1px; border-color: #dcdce4; display: -webkit-inline-box; display: -webkit-inline-flex; display: -ms-inline-flexbox; display: inline-flex; } .c43 { padding-right: 32px; padding-left: 32px; border-radius: 4px; } .c35 { -webkit-align-items: stretch; -webkit-box-align: stretch; -ms-flex-align: stretch; align-items: stretch; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; } .c37 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; } .c38 { font-weight: 600; color: #32324d; font-size: 0.75rem; line-height: 1.33; } .c45 { font-weight: 600; color: #b72b1a; text-transform: uppercase; font-size: 0.75rem; line-height: 1.33; } .c47 { font-weight: 600; color: #666687; text-transform: uppercase; font-size: 0.75rem; line-height: 1.33; } .c49 { color: #666687; font-size: 0.75rem; line-height: 1.33; } .c36 > * { margin-top: 0; margin-bottom: 0; } .c36 > * + * { margin-top: 4px; } .c40 { border: 0; -webkit-clip: rect(0 0 0 0); clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } .c39 { position: relative; display: inline-block; } .c42 { height: 2.5rem; overflow: hidden; outline: none; box-shadow: 0; -webkit-transition-property: border-color,box-shadow,fill; transition-property: border-color,box-shadow,fill; -webkit-transition-duration: 0.2s; transition-duration: 0.2s; } .c42:focus-within { border: 1px solid #4945ff; box-shadow: #4945ff 0px 0px 0px 2px; } .c44 { background-color: #ffffff; border: 1px solid #dcdce4; position: relative; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; z-index: 2; } .c46 { background-color: transparent; border: 1px solid #f6f6f9; position: relative; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; z-index: 2; } .c48 { height: 100%; left: 0; opacity: 0; position: absolute; top: 0; z-index: 1; width: 100%; } .c34 { width: -webkit-fit-content; width: -moz-fit-content; width: fit-content; } .c16 { color: #32324d; font-weight: 500; font-size: 1rem; line-height: 1.25; } .c0:focus-visible { outline: none; } .c1 { background: #f6f6f9; padding-top: 40px; padding-right: 56px; padding-bottom: 40px; padding-left: 56px; } .c12 { padding-right: 56px; padding-left: 56px; } .c2 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between; } .c3 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; } .c4 { color: #32324d; font-weight: 600; font-size: 2rem; line-height: 1.25; } .c17 { display: grid; grid-template-columns: repeat(12,1fr); gap: 24px; } .c18 { grid-column: span 6; max-width: 100%; } .c33 { grid-column: span 12; max-width: 100%; } .c50 { grid-column: span 6; max-width: 100%; } @media (max-width:68.75rem) { .c18 { grid-column: span 12; } } @media (max-width:34.375rem) { .c18 { grid-column: span; } } @media (max-width:68.75rem) { .c33 { grid-column: span; } } @media (max-width:34.375rem) { .c33 { grid-column: span 12; } } @media (max-width:68.75rem) { .c50 { grid-column: span; } } @media (max-width:34.375rem) { .c50 { grid-column: span 12; } } Advanced Settings Save Settings Default role for authenticated users Authenticated It will attach the new authenticated user to the selected role. One account per email address One account per email address False True Disallow the user to create multiple accounts using the same email address with different authentication providers. Enable sign-ups Enable sign-ups False True When disabled (OFF), the registration process is forbidden. No one can subscribe anymore no matter the used provider. Reset password page URL of your application's reset password page. Enable email confirmation Enable email confirmation False True When enabled (ON), new registered users receive a confirmation email. Redirection url After you confirmed your email, choose where you will be redirected. `); }); });
It will attach the new authenticated user to the selected role.
Disallow the user to create multiple accounts using the same email address with different authentication providers.
When disabled (OFF), the registration process is forbidden. No one can subscribe anymore no matter the used provider.
URL of your application's reset password page.
When enabled (ON), new registered users receive a confirmation email.
After you confirmed your email, choose where you will be redirected.