diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPassword/index.js b/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPassword/index.js index aea578b97d..6dff21f58c 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPassword/index.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPassword/index.js @@ -33,28 +33,47 @@ const ForgotPassword = ({ onSubmit, schema }) => { - {formatMessage({ id: 'Auth.form.button.password-forgotten' })} + {formatMessage({ + id: 'Auth.form.button.password-forgotten', + defaultMessage: 'Password forgotten', + })} {errors.errorMessage && ( - {formatMessage({ id: errors.errorMessage })} + {formatMessage({ + id: errors.errorMessage, + defaultMessage: 'An error occurred', + })} )} - {formatMessage({ id: 'Auth.form.button.forgot-password' })} + {formatMessage({ + id: 'Auth.form.button.forgot-password', + defaultMessage: 'Send Email', + })} @@ -64,7 +83,9 @@ const ForgotPassword = ({ onSubmit, schema }) => { - {formatMessage({ id: 'Auth.link.ready' })} + + {formatMessage({ id: 'Auth.link.ready', defaultMessage: 'Ready to sign in?' })} + diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPasswordSuccess/index.js b/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPasswordSuccess/index.js index f04613b9dc..70ee4534de 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPasswordSuccess/index.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/ForgotPasswordSuccess/index.js @@ -18,18 +18,24 @@ const ForgotPasswordSuccess = () => { - {formatMessage({ id: 'app.containers.AuthPage.ForgotPasswordSuccess.title' })} + {formatMessage({ + id: 'app.containers.AuthPage.ForgotPasswordSuccess.title', + defaultMessage: 'Email sent', + })} {formatMessage({ id: 'app.containers.AuthPage.ForgotPasswordSuccess.text.email', + defaultMessage: 'It can take a few minutes to receive your password recovery link.', })} {formatMessage({ id: 'app.containers.AuthPage.ForgotPasswordSuccess.text.contact-admin', + defaultMessage: + 'If you do not receive this link, please contact your administrator.', })} @@ -38,7 +44,7 @@ const ForgotPasswordSuccess = () => { - {formatMessage({ id: 'Auth.link.signin' })} + {formatMessage({ id: 'Auth.link.signin', defaultMessage: 'Sign in' })} diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Login/BaseLogin.js b/packages/core/admin/admin/src/pages/AuthPage/components/Login/BaseLogin.js index be20f41b3b..7c18cec0e7 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/Login/BaseLogin.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Login/BaseLogin.js @@ -45,11 +45,19 @@ const Login = ({ onSubmit, schema, children }) => { - {formatMessage({ id: 'Auth.form.welcome.title' })} + + {formatMessage({ + id: 'Auth.form.welcome.title', + defaultMessage: 'Welcome back!', + })} + - {formatMessage({ id: 'Auth.form.welcome.subtitle' })} + {formatMessage({ + id: 'Auth.form.welcome.subtitle', + defaultMessage: 'Log in to your Strapi account', + })} {errors.errorMessage && ( @@ -61,19 +69,39 @@ const Login = ({ onSubmit, schema, children }) => { { e.stopPropagation(); setPasswordShown(prev => !prev); }} - label={formatMessage({ - id: passwordShown - ? 'Auth.form.password.show-password' - : 'Auth.form.password.hide-password', - })} + label={formatMessage( + passwordShown + ? { + id: 'Auth.form.password.show-password', + defaultMessage: 'Show password', + } + : { + id: 'Auth.form.password.hide-password', + defaultMessage: 'Hide password', + } + )} > {passwordShown ? : } @@ -100,10 +134,13 @@ const Login = ({ onSubmit, schema, children }) => { value={values.rememberMe} name="rememberMe" > - {formatMessage({ id: 'Auth.form.rememberMe.label' })} + {formatMessage({ + id: 'Auth.form.rememberMe.label', + defaultMessage: 'Remember me', + })} - {formatMessage({ id: 'Auth.form.button.login' })} + {formatMessage({ id: 'Auth.form.button.login', defaultMessage: 'Login' })} @@ -114,7 +151,12 @@ const Login = ({ onSubmit, schema, children }) => { - {formatMessage({ id: 'Auth.link.forgot-password' })} + + {formatMessage({ + id: 'Auth.link.forgot-password', + defaultMessage: 'Forgot your password?', + })} + diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Login/tests/BaseLogin.test.js b/packages/core/admin/admin/src/pages/AuthPage/components/Login/tests/BaseLogin.test.js new file mode 100644 index 0000000000..044f100b99 --- /dev/null +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Login/tests/BaseLogin.test.js @@ -0,0 +1,165 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { ThemeProvider } from '@strapi/parts/ThemeProvider'; +import { lightTheme } from '@strapi/parts/themes'; +import { Router } from 'react-router-dom'; +import * as yup from 'yup'; +import { createMemoryHistory } from 'history'; +import BaseLogin from '../BaseLogin'; + +jest.mock('react-intl', () => { + const reactIntl = jest.requireActual('react-intl'); + const intl = reactIntl.createIntl({ + locale: 'en', + }); + + return { + ...reactIntl, + useIntl: () => intl, + }; +}); +jest.mock('@strapi/helper-plugin', () => ({ + useQuery: () => ({ + get: () => '', + }), + Form: () => , +})); + +describe('ADMIN | PAGES | AUTH | BaseLogin', () => { + it('should render and match the snapshot', () => { + const history = createMemoryHistory(); + const { container } = render( + + + {}} schema={yup.object()} /> + + + ); + + expect(container.firstChild).toMatchInlineSnapshot(` + .c6 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #4945ff; + } + + .c9 { + font-weight: 400; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c7 { + font-weight: 600; + line-height: 1.14; + } + + .c8 { + font-weight: 600; + font-size: 0.6875rem; + line-height: 1.45; + text-transform: uppercase; + } + + .c1 { + background: #ffffff; + padding-top: 48px; + padding-right: 56px; + padding-bottom: 48px; + padding-left: 56px; + border-radius: 4px; + box-shadow: 0px 1px 4px rgba(33,33,52,0.1); + } + + .c4 { + padding-top: 16px; + } + + .c3 { + 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: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c5 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + text-transform: uppercase; + -webkit-text-decoration: none; + text-decoration: none; + } + + .c5 svg path { + fill: #4945ff; + } + + .c5 svg { + font-size: 0.625rem; + } + + .c0 { + outline: none; + } + + .c2 { + margin: 0 auto; + width: 552px; + } + + + + + + + + + + + Forgot your password? + + + + + + + `); + }); +}); diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Logo/index.js b/packages/core/admin/admin/src/pages/AuthPage/components/Logo/index.js index ca2f2edb37..d334a72032 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/Logo/index.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Logo/index.js @@ -3,7 +3,7 @@ import styled from 'styled-components'; import { useConfigurations } from '../../../../hooks'; const Img = styled.img` - height: 72px; + height: ${72 / 16}rem; `; const Logo = () => { diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Oops/index.js b/packages/core/admin/admin/src/pages/AuthPage/components/Oops/index.js index bedb2802c5..0fb01e8d0f 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/Oops/index.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Oops/index.js @@ -12,7 +12,12 @@ const Oops = () => { const { formatMessage } = useIntl(); const query = useQuery(); - const message = query.get('info') || formatMessage({ id: 'Auth.components.Oops.text' }); + const message = + query.get('info') || + formatMessage({ + id: 'Auth.components.Oops.text', + defaultMessage: 'Your account has been suspended.', + }); return ( @@ -21,13 +26,16 @@ const Oops = () => { - {formatMessage({ id: 'Auth.components.Oops.title' })} + + {formatMessage({ id: 'Auth.components.Oops.title', defaultMessage: 'Oops...' })} + {message} {formatMessage({ id: 'Auth.components.Oops.text.admin', + defaultMessage: 'If this is a mistake, please contact your administrator.', })} @@ -36,7 +44,7 @@ const Oops = () => { - {formatMessage({ id: 'Auth.link.signin' })} + {formatMessage({ id: 'Auth.link.signin', defaultMessage: 'Sign in' })} diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Oops/tests/index.test.js b/packages/core/admin/admin/src/pages/AuthPage/components/Oops/tests/index.test.js new file mode 100644 index 0000000000..c34f383aac --- /dev/null +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Oops/tests/index.test.js @@ -0,0 +1,336 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { ThemeProvider } from '@strapi/parts/ThemeProvider'; +import { lightTheme } from '@strapi/parts/themes'; +import { Router } from 'react-router-dom'; +import { createMemoryHistory } from 'history'; +import Oops from '..'; + +jest.mock('react-intl', () => { + const reactIntl = jest.requireActual('react-intl'); + const intl = reactIntl.createIntl({ + locale: 'en', + }); + + return { + ...reactIntl, + useIntl: () => intl, + }; +}); +jest.mock('../../../../../components/LocalesProvider/useLocalesProvider', () => () => ({ + changeLocale: () => {}, + localeNames: ['en'], + messages: ['test'], +})); +jest.mock('@strapi/helper-plugin', () => ({ + useQuery: () => ({ + get: () => '', + }), +})); + +describe('ADMIN | PAGES | AUTH | Oops', () => { + it('should render and match the snapshot', () => { + const history = createMemoryHistory(); + const { container } = render( + + + + + + ); + + expect(container.firstChild).toMatchInlineSnapshot(` + .c14 { + font-weight: 600; + font-size: 2rem; + line-height: 1.25; + color: #32324d; + } + + .c4 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #32324d; + } + + .c18 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #4945ff; + } + + .c5 { + font-weight: 600; + line-height: 1.14; + } + + .c19 { + font-weight: 600; + font-size: 0.6875rem; + line-height: 1.45; + text-transform: uppercase; + } + + .c1 { + padding-top: 24px; + padding-right: 40px; + } + + .c3 { + padding-right: 4px; + } + + .c6 { + padding-top: 64px; + padding-bottom: 64px; + } + + .c8 { + background: #ffffff; + padding-top: 48px; + padding-right: 56px; + padding-bottom: 48px; + padding-left: 56px; + border-radius: 4px; + box-shadow: 0px 1px 4px rgba(33,33,52,0.1); + } + + .c13 { + padding-top: 24px; + padding-bottom: 32px; + } + + .c15 { + padding-top: 16px; + } + + .c0 { + 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: end; + -webkit-justify-content: flex-end; + -ms-flex-pack: end; + justify-content: flex-end; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c10 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c16 { + 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: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c2 { + border: none; + background: transparent; + 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; + font-size: 0.75rem; + } + + .c2 svg { + height: 0.25rem; + } + + .c2 svg path { + fill: #8e8ea9; + } + + .c17 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + text-transform: uppercase; + -webkit-text-decoration: none; + text-decoration: none; + } + + .c17 svg path { + fill: #4945ff; + } + + .c17 svg { + font-size: 0.625rem; + } + + .c7 { + outline: none; + } + + .c9 { + margin: 0 auto; + width: 552px; + } + + .c11 { + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c12 { + height: 4.5rem; + } + + + + + + + + + + + + + + + + + + + + + + + + Oops... + + + + Your account has been suspended. + + + + If this is a mistake, please contact your administrator. + + + + + + + + + + Sign in + + + + + + + + + `); + }); +}); diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Register/index.js b/packages/core/admin/admin/src/pages/AuthPage/components/Register/index.js index 69f0b30aea..69700c066e 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/Register/index.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Register/index.js @@ -110,11 +110,20 @@ const Register = ({ fieldsToDisable, noSignin, onSubmit, schema }) => { - {formatMessage({ id: 'Auth.form.welcome.title' })} + + {formatMessage({ + id: 'Auth.form.welcome.title', + defaultMessage: 'Welcome back!', + })} + - {formatMessage({ id: 'Auth.form.register.subtitle' })} + {formatMessage({ + id: 'Auth.form.register.subtitle', + defaultMessage: + 'Your credentials are only used to authenticate yourself on the admin panel. All saved data will be stored in your own database.', + })} @@ -126,20 +135,38 @@ const Register = ({ fieldsToDisable, noSignin, onSubmit, schema }) => { required value={values.firstname} error={ - errors.firstname ? formatMessage({ id: errors.firstname }) : undefined + errors.firstname + ? formatMessage({ + id: errors.firstname, + defaultMessage: 'This value is required.', + }) + : undefined } onChange={handleChange} - label={formatMessage({ id: 'Auth.form.firstname.label' })} + label={formatMessage({ + id: 'Auth.form.firstname.label', + defaultMessage: 'Firstname', + })} /> @@ -148,16 +175,30 @@ const Register = ({ fieldsToDisable, noSignin, onSubmit, schema }) => { disabled={fieldsToDisable.includes('email')} value={values.email} onChange={handleChange} - error={errors.email ? formatMessage({ id: errors.email }) : undefined} + error={ + errors.email + ? formatMessage({ + id: errors.email, + defaultMessage: 'This value is required.', + }) + : undefined + } required - label={formatMessage({ id: 'Auth.form.email.label' })} + label={formatMessage({ id: 'Auth.form.email.label', defaultMessage: 'Email' })} type="email" /> { e.preventDefault(); setPasswordShown(prev => !prev); }} - label={formatMessage({ - id: passwordShown - ? 'Auth.form.password.show-password' - : 'Auth.form.password.hide-password', - })} + label={formatMessage( + passwordShown + ? { + id: 'Auth.form.password.show-password', + defaultMessage: 'Show password', + } + : { + id: 'Auth.form.password.hide-password', + defaultMessage: 'Hide password', + } + )} > {passwordShown ? : } } - hint={formatMessage({ id: 'Auth.form.password.hint' })} + hint={formatMessage({ + id: 'Auth.form.password.hint', + defaultMessage: + 'Password must contain at least 8 characters, 1 uppercase, 1 lowercase and 1 number', + })} required - label={formatMessage({ id: 'Auth.form.password.label' })} + label={formatMessage({ + id: 'Auth.form.password.label', + defaultMessage: 'Password', + })} type={passwordShown ? 'text' : 'password'} /> { value={values.confirmPassword} error={ errors.confirmPassword - ? formatMessage({ id: errors.confirmPassword }) + ? formatMessage({ + id: errors.confirmPassword, + defaultMessage: 'This value is required.', + }) : undefined } endAction={ @@ -195,17 +252,26 @@ const Register = ({ fieldsToDisable, noSignin, onSubmit, schema }) => { e.preventDefault(); setConfirmPasswordShown(prev => !prev); }} - label={formatMessage({ - id: confirmPasswordShown - ? 'Auth.form.password.show-password' - : 'Auth.form.password.hide-password', - })} + label={formatMessage( + confirmPasswordShown + ? { + id: 'Auth.form.password.show-password', + defaultMessage: 'Show password', + } + : { + id: 'Auth.form.password.hide-password', + defaultMessage: 'Hide password', + } + )} > {confirmPasswordShown ? : } } required - label={formatMessage({ id: 'Auth.form.confirmPassword.label' })} + label={formatMessage({ + id: 'Auth.form.confirmPassword.label', + defaultMessage: 'Confirmation Password', + })} type={confirmPasswordShown ? 'text' : 'password'} /> { name="news" > {formatMessage( - { id: 'Auth.form.register.news.label' }, + { + id: 'Auth.form.register.news.label', + defaultMessage: + 'Keep me updated about the new features and upcoming improvements (by doing this you accept the {terms} and the {policy}).', + }, { terms: ( - {formatMessage({ id: 'Auth.privacy-policy-agreement.terms' })} + {formatMessage({ + id: 'Auth.privacy-policy-agreement.terms', + defaultMessage: 'terms', + })} ), policy: ( - {formatMessage({ id: 'Auth.privacy-policy-agreement.policy' })} + {formatMessage({ + id: 'Auth.privacy-policy-agreement.policy', + defaultMessage: 'policy', + })} ), } )} - {formatMessage({ id: 'Auth.form.button.register' })} + {formatMessage({ + id: 'Auth.form.button.register', + defaultMessage: "Let's start", + })} @@ -243,7 +322,10 @@ const Register = ({ fieldsToDisable, noSignin, onSubmit, schema }) => { - {formatMessage({ id: 'Auth.link.signin.account' })} + {formatMessage({ + id: 'Auth.link.signin.account', + defaultMessage: 'Already have an account?', + })} diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/Register/tests/index.test.js b/packages/core/admin/admin/src/pages/AuthPage/components/Register/tests/index.test.js new file mode 100644 index 0000000000..930c393f7e --- /dev/null +++ b/packages/core/admin/admin/src/pages/AuthPage/components/Register/tests/index.test.js @@ -0,0 +1,180 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { ThemeProvider } from '@strapi/parts/ThemeProvider'; +import { lightTheme } from '@strapi/parts/themes'; +import { Router } from 'react-router-dom'; +import { createMemoryHistory } from 'history'; +import * as yup from 'yup'; +import Register from '..'; + +jest.mock('react-intl', () => { + const reactIntl = jest.requireActual('react-intl'); + const intl = reactIntl.createIntl({ + locale: 'en', + }); + + return { + ...reactIntl, + useIntl: () => intl, + }; +}); +jest.mock('../../../../../components/LocalesProvider/useLocalesProvider', () => () => ({ + changeLocale: () => {}, + localeNames: ['en'], + messages: ['test'], +})); +jest.mock('@strapi/helper-plugin', () => ({ + useNotification: () => jest.fn({}), + useQuery: () => ({ + get: () => '', + }), + Form: () => , +})); + +describe('ADMIN | PAGES | AUTH | Register', () => { + it('should render and match the snapshot', () => { + const history = createMemoryHistory(); + const { container } = render( + + + {}} schema={yup.object()} /> + + + ); + + expect(container.firstChild).toMatchInlineSnapshot(` + .c4 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #32324d; + } + + .c5 { + font-weight: 600; + line-height: 1.14; + } + + .c1 { + padding-top: 24px; + padding-right: 40px; + } + + .c3 { + padding-right: 4px; + } + + .c6 { + padding-top: 64px; + padding-bottom: 64px; + } + + .c7 { + background: #ffffff; + padding-top: 48px; + padding-right: 56px; + padding-bottom: 48px; + padding-left: 56px; + border-radius: 4px; + box-shadow: 0px 1px 4px rgba(33,33,52,0.1); + } + + .c0 { + 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: end; + -webkit-justify-content: flex-end; + -ms-flex-pack: end; + justify-content: flex-end; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c2 { + border: none; + background: transparent; + 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; + font-size: 0.75rem; + } + + .c2 svg { + height: 0.25rem; + } + + .c2 svg path { + fill: #8e8ea9; + } + + .c8 { + margin: 0 auto; + width: 552px; + } + + + + + + + + + + + + + + + + + + + + + + + `); + }); +}); diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/index.js b/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/index.js index 3b13f63209..d2e2db1e57 100644 --- a/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/index.js +++ b/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/index.js @@ -38,12 +38,18 @@ const ForgotPassword = ({ onSubmit, schema }) => { - {formatMessage({ id: 'Auth.reset-password.title' })} + {formatMessage({ + id: 'Auth.reset-password.title', + defaultMessage: 'Reset password', + })} {errors.errorMessage && ( - {formatMessage({ id: errors.errorMessage })} + {formatMessage({ + id: errors.errorMessage, + defaultMessage: 'An error occurred', + })} )} @@ -53,25 +59,45 @@ const ForgotPassword = ({ onSubmit, schema }) => { name="password" onChange={handleChange} value={values.password} - error={errors.password ? formatMessage({ id: errors.password }) : undefined} + error={ + errors.password + ? formatMessage({ + id: errors.password, + defaultMessage: 'This field is required.', + }) + : undefined + } endAction={ { e.preventDefault(); setPasswordShown(prev => !prev); }} - label={formatMessage({ - id: passwordShown - ? 'Auth.form.password.show-password' - : 'Auth.form.password.hide-password', - })} + label={formatMessage( + passwordShown + ? { + id: 'Auth.form.password.show-password', + defaultMessage: 'Show password', + } + : { + id: 'Auth.form.password.hide-password', + defaultMessage: 'Hide password', + } + )} > {passwordShown ? : } } - hint={formatMessage({ id: 'Auth.form.password.hint' })} + hint={formatMessage({ + id: 'Auth.form.password.hint', + defaultMessage: + 'Password must contain at least 8 characters, 1 uppercase, 1 lowercase and 1 number', + })} required - label={formatMessage({ id: 'Auth.form.password.label' })} + label={formatMessage({ + id: 'Auth.form.password.label', + defaultMessage: 'Password', + })} type={passwordShown ? 'text' : 'password'} /> { value={values.confirmPassword} error={ errors.confirmPassword - ? formatMessage({ id: errors.confirmPassword }) + ? formatMessage({ + id: errors.confirmPassword, + defaultMessage: 'This value is required.', + }) : undefined } endAction={ @@ -89,21 +118,33 @@ const ForgotPassword = ({ onSubmit, schema }) => { e.preventDefault(); setConfirmPasswordShown(prev => !prev); }} - label={formatMessage({ - id: confirmPasswordShown - ? 'Auth.form.password.show-password' - : 'Auth.form.password.hide-password', - })} + label={formatMessage( + passwordShown + ? { + id: 'Auth.form.password.show-password', + defaultMessage: 'Show password', + } + : { + id: 'Auth.form.password.hide-password', + defaultMessage: 'Hide password', + } + )} > {confirmPasswordShown ? : } } required - label={formatMessage({ id: 'Auth.form.confirmPassword.label' })} + label={formatMessage({ + id: 'Auth.form.confirmPassword.label', + defaultMessage: 'Confirmation Password', + })} type={confirmPasswordShown ? 'text' : 'password'} /> - {formatMessage({ id: 'Auth.form.button.reset-password' })} + {formatMessage({ + id: 'Auth.form.button.reset-password', + defaultMessage: 'Change password', + })} @@ -113,7 +154,9 @@ const ForgotPassword = ({ onSubmit, schema }) => { - {formatMessage({ id: 'Auth.link.ready' })} + + {formatMessage({ id: 'Auth.link.ready', defaultMessage: 'Ready to sign in?' })} + diff --git a/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/tests/index.test.js b/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/tests/index.test.js new file mode 100644 index 0000000000..273cccae56 --- /dev/null +++ b/packages/core/admin/admin/src/pages/AuthPage/components/ResetPassword/tests/index.test.js @@ -0,0 +1,686 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { ThemeProvider } from '@strapi/parts/ThemeProvider'; +import { lightTheme } from '@strapi/parts/themes'; +import { Router } from 'react-router-dom'; +import { createMemoryHistory } from 'history'; +import * as yup from 'yup'; +import ResetPassword from '..'; + +jest.mock('react-intl', () => { + const reactIntl = jest.requireActual('react-intl'); + const intl = reactIntl.createIntl({ + locale: 'en', + }); + + return { + ...reactIntl, + useIntl: () => intl, + }; +}); +jest.mock('../../../../../components/LocalesProvider/useLocalesProvider', () => () => ({ + changeLocale: () => {}, + localeNames: ['en'], + messages: ['test'], +})); + +describe('ADMIN | PAGES | AUTH | ResetPassword', () => { + it('should render and match the snapshot', () => { + const history = createMemoryHistory(); + const { container } = render( + + + {}} schema={yup.object()} /> + + + ); + + expect(container.firstChild).toMatchInlineSnapshot(` + .c14 { + font-weight: 600; + font-size: 2rem; + line-height: 1.25; + color: #32324d; + } + + .c4 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #32324d; + } + + .c18 { + font-weight: 500; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c25 { + font-weight: 400; + font-size: 0.75rem; + line-height: 1.33; + color: #666687; + } + + .c34 { + font-weight: 400; + font-size: 0.875rem; + line-height: 1.43; + color: #4945ff; + } + + .c36 { + font-weight: 400; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c5 { + font-weight: 600; + line-height: 1.14; + } + + .c35 { + font-weight: 600; + font-size: 0.6875rem; + line-height: 1.45; + text-transform: uppercase; + } + + .c1 { + padding-top: 24px; + padding-right: 40px; + } + + .c3 { + padding-right: 4px; + } + + .c6 { + padding-top: 64px; + padding-bottom: 64px; + } + + .c8 { + background: #ffffff; + padding-top: 48px; + padding-right: 56px; + padding-bottom: 48px; + padding-left: 56px; + border-radius: 4px; + box-shadow: 0px 1px 4px rgba(33,33,52,0.1); + } + + .c13 { + padding-top: 24px; + padding-bottom: 32px; + } + + .c22 { + padding-right: 12px; + padding-left: 8px; + } + + .c32 { + padding-top: 16px; + } + + .c0 { + 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: end; + -webkit-justify-content: flex-end; + -ms-flex-pack: end; + justify-content: flex-end; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c10 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c19 { + 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; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c31 { + 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: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + } + + .c15 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c15 > * + * { + margin-top: 24px; + } + + .c17 > * { + margin-top: 0; + margin-bottom: 0; + } + + .c17 > * + * { + margin-top: 4px; + } + + .c21 { + border: none; + padding-left: 16px; + padding-right: 0; + color: #32324d; + font-weight: 400; + font-size: 0.875rem; + display: block; + width: 100%; + height: 2.5rem; + } + + .c21::-webkit-input-placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c21::-moz-placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c21:-ms-input-placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c21::placeholder { + color: #8e8ea9; + opacity: 1; + } + + .c21:disabled { + background: inherit; + color: inherit; + } + + .c21:focus { + outline: none; + } + + .c20 { + border: 1px solid #dcdce4; + border-radius: 4px; + background: #ffffff; + overflow: hidden; + } + + .c20:focus-within { + border: 1px solid #4945ff; + } + + .c16 textarea { + height: 5rem; + } + + .c2 { + border: none; + background: transparent; + 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; + font-size: 0.75rem; + } + + .c2 svg { + height: 0.25rem; + } + + .c2 svg path { + fill: #8e8ea9; + } + + .c33 { + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + text-transform: uppercase; + -webkit-text-decoration: none; + text-decoration: none; + } + + .c33 svg path { + fill: #4945ff; + } + + .c33 svg { + font-size: 0.625rem; + } + + .c7 { + outline: none; + } + + .c9 { + margin: 0 auto; + width: 552px; + } + + .c11 { + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + } + + .c30 { + font-weight: 500; + font-size: 0.75rem; + line-height: 1.33; + color: #32324d; + } + + .c26 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + cursor: pointer; + padding: 8px; + border-radius: 4px; + background: #ffffff; + border: 1px solid #dcdce4; + } + + .c26 svg { + height: 12px; + width: 12px; + } + + .c26 svg > g, + .c26 svg path { + fill: #ffffff; + } + + .c26[aria-disabled='true'] { + pointer-events: none; + } + + .c27 { + padding: 8px 16px; + background: #4945ff; + border: none; + border: 1px solid #4945ff; + background: #4945ff; + } + + .c27 .c29 { + color: #ffffff; + } + + .c27[aria-disabled='true'] { + border: 1px solid #dcdce4; + background: #eaeaef; + } + + .c27[aria-disabled='true'] .c29 { + color: #666687; + } + + .c27[aria-disabled='true'] svg > g, + .c27[aria-disabled='true'] svg path { + fill: #666687; + } + + .c27[aria-disabled='true']:active { + border: 1px solid #dcdce4; + background: #eaeaef; + } + + .c27[aria-disabled='true']:active .c29 { + color: #666687; + } + + .c27[aria-disabled='true']:active svg > g, + .c27[aria-disabled='true']:active svg path { + fill: #666687; + } + + .c27:hover { + border: 1px solid #7b79ff; + background: #7b79ff; + } + + .c27:active { + border: 1px solid #4945ff; + background: #4945ff; + } + + .c28 { + display: inline-block; + width: 100%; + } + + .c12 { + height: 4.5rem; + } + + .c23 { + border: none; + background: transparent; + font-size: 1.6rem; + width: auto; + padding: 0; + 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; + } + + .c24 svg { + height: 1rem; + width: 1rem; + } + + .c24 svg path { + fill: #666687; + } + + + + + + + + + + + + + + + + + + + + + + + + + Reset password + + + + + + + + + + Password + + + + + + + + + + + + + + Password must contain at least 8 characters, 1 uppercase, 1 lowercase and 1 number + + + + + + + + + + Confirmation Password + + + + + + + + + + + + + + + + + + Change password + + + + + + + + + + + Ready to sign in? + + + + + + + + + `); + }); +});
+ Password must contain at least 8 characters, 1 uppercase, 1 lowercase and 1 number +