-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(password reset): create password reset pages
- create password email verifier page - create password reset page - refactor withCheckAuth HOC to formHandler helper - write test for file changes [Finishes #167590028]
- Loading branch information
Showing
23 changed files
with
469 additions
and
155 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import 'react-toastify/dist/ReactToastify.css'; | ||
import PageLayout from '<templates>/PageLayout/PageLayout'; | ||
import AuthForm from '<organisms>/AuthForm/AuthForm'; | ||
import { emailData, emailRules } from './passwordItems'; | ||
import FlexContainer from '<atoms>/layouts/FlexContainer/FlexContainer'; | ||
import Image from '<atoms>/Image/Image'; | ||
import imageUrl from '<image>/home.png'; | ||
import { passwordReset } from './navItems'; | ||
import headerMapper from '<helpers>/headerMapper'; | ||
import formHandler from '<helpers>/formHandler'; | ||
|
||
|
||
const navItems = headerMapper(passwordReset); | ||
|
||
const PasswordReset = (props) => { | ||
const handleSubmit = (values) => { | ||
const data = { | ||
method: 'post', | ||
path: 'recoverEmail', | ||
redirectTo: '/', | ||
}; | ||
|
||
formHandler(values, props.history, data); | ||
}; | ||
|
||
return ( | ||
<PageLayout navItems={navItems}> | ||
<FlexContainer> | ||
<FlexContainer flexDirection='row' height='80%'> | ||
<FlexContainer> | ||
<Image | ||
imageUrl={imageUrl} | ||
boxShadow='none' | ||
altText='welcome' | ||
/> | ||
</FlexContainer> | ||
<FlexContainer padding='zero'> | ||
<AuthForm | ||
title="Password Reset" | ||
rules={emailRules} | ||
inputData={emailData} | ||
callback={handleSubmit} | ||
/> | ||
<ToastContainer /> | ||
</FlexContainer> | ||
</FlexContainer> | ||
</FlexContainer> | ||
</PageLayout> | ||
); | ||
}; | ||
|
||
PasswordReset.propTypes = { | ||
history: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default PasswordReset; |
44 changes: 44 additions & 0 deletions
44
src/components/pages/AuthPages/PasswordEmailVerifier.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { render, cleanup, fireEvent } from '<src>/helpers/testUtils'; | ||
import PasswordEmailVerifier from './PasswordEmailVerifier'; | ||
import formHandler from '<helpers>/formHandler'; | ||
|
||
jest.mock('<helpers>/formHandler'); | ||
afterEach(cleanup); | ||
|
||
const setup = () => { | ||
const utils = render( | ||
<MemoryRouter> | ||
<PasswordEmailVerifier history={{}} /> | ||
</MemoryRouter>, | ||
); | ||
|
||
return { | ||
...utils, | ||
}; | ||
}; | ||
|
||
describe('PasswordEmailVerifier', () => { | ||
it('should render PasswordEmailVerifier page', () => { | ||
const { container } = setup(); | ||
|
||
expect(container.firstChild).toBeTruthy(); | ||
}); | ||
|
||
it('should render with sign in text', () => { | ||
const { getByText } = setup(); | ||
|
||
expect(getByText('Sign In')).toBeTruthy(); | ||
}); | ||
|
||
it('should call handleSubmit once', () => { | ||
const { getByText, getByTestId } = setup(); | ||
|
||
fireEvent.change(getByTestId('email'), { target: { value: 'abc@de.com' } }); | ||
|
||
fireEvent.click(getByText('Submit')); | ||
|
||
expect(formHandler).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
Oops, something went wrong.