diff --git a/apps/frontend/src/app/components/NewPasswordForm.tsx b/apps/frontend/src/app/components/NewPasswordForm.tsx new file mode 100644 index 0000000..6822694 --- /dev/null +++ b/apps/frontend/src/app/components/NewPasswordForm.tsx @@ -0,0 +1,21 @@ +'use client'; + +import React from 'react'; +import TextInputField from './TextInputField'; +import { Button } from '@chakra-ui/react'; + +export default function NewPasswordForm() { + return ( +
+

Reset Password

+
+ + +
+ {/* TODO: form validation*/} + +
+ ); +} \ No newline at end of file diff --git a/apps/frontend/src/app/components/ResetPasswordConfirmation.tsx b/apps/frontend/src/app/components/ResetPasswordConfirmation.tsx new file mode 100644 index 0000000..fc5682e --- /dev/null +++ b/apps/frontend/src/app/components/ResetPasswordConfirmation.tsx @@ -0,0 +1,24 @@ +'use client'; + +import React from 'react'; +import { Button } from '@chakra-ui/react'; +import { useRouter } from 'next/navigation'; + + +export default function ResetPasswordConfirmation() { + const router = useRouter(); + + return ( +
+
+

Password Changed

+
Your password has been successfully changed!
+
+ {/*TODO: figure out how to connect the button to login page */} + +
+ ); +} \ No newline at end of file diff --git a/apps/frontend/src/app/components/LoginPage.tsx b/apps/frontend/src/app/login/page.tsx similarity index 95% rename from apps/frontend/src/app/components/LoginPage.tsx rename to apps/frontend/src/app/login/page.tsx index 08bfd2c..b883d1f 100644 --- a/apps/frontend/src/app/components/LoginPage.tsx +++ b/apps/frontend/src/app/login/page.tsx @@ -1,7 +1,7 @@ 'use client'; import React from 'react'; -import TextInputField from './TextInputField'; +import TextInputField from '../components/TextInputField'; import Link from 'next/link'; import { Button } from '@chakra-ui/react'; diff --git a/apps/frontend/test/components/LoginPage.test.tsx b/apps/frontend/test/components/LoginPage.test.tsx index e1418b8..d6b9a90 100644 --- a/apps/frontend/test/components/LoginPage.test.tsx +++ b/apps/frontend/test/components/LoginPage.test.tsx @@ -1,5 +1,5 @@ import { render, screen } from '../utils'; -import LoginPage from '@/app/components/LoginPage'; +import LoginPage from '@/app/login/page'; describe('Login Page Component', () => { diff --git a/apps/frontend/test/components/NewPasswordForm.test.tsx b/apps/frontend/test/components/NewPasswordForm.test.tsx new file mode 100644 index 0000000..031971a --- /dev/null +++ b/apps/frontend/test/components/NewPasswordForm.test.tsx @@ -0,0 +1,22 @@ +import { render, screen } from '../utils'; +import NewPasswordForm from '@/app/components/NewPasswordForm'; + + +describe('New Password Form Component', () => { + it('renders the form heading', () => { + render(); + expect(screen.getByText('Reset Password', { selector: 'h1' })).toBeInTheDocument(); + }); + + it('renders the 2 password input fields', () => { + render(); + expect(screen.getByPlaceholderText('Enter new password')).toBeInTheDocument(); + expect(screen.getByPlaceholderText('Retype password')).toBeInTheDocument(); + }); + + it('renders the reset password button', () => { + render(); + const button = screen.getByRole('button', { name: 'Reset Password' }); + expect(button).toBeInTheDocument(); + }) +}); \ No newline at end of file diff --git a/apps/frontend/test/components/ResetPasswordConfirmation.test.tsx b/apps/frontend/test/components/ResetPasswordConfirmation.test.tsx new file mode 100644 index 0000000..c291105 --- /dev/null +++ b/apps/frontend/test/components/ResetPasswordConfirmation.test.tsx @@ -0,0 +1,37 @@ +import { render, screen } from '../utils'; +import ResetPasswordConfirmation from '@/app/components/ResetPasswordConfirmation'; + +const mockPush = jest.fn(); + +jest.mock('next/navigation', () => ({ + useRouter: () => ({ + push: mockPush, + }), +})); + + +describe('Reset Password Confirmation Page Component', () => { + + it('renders the page heading', () => { + render(); + expect(screen.getByText('Password Changed', { selector: 'h1' })).toBeInTheDocument(); + }); + + it('renders the subheading', () => { + render(); + expect(screen.getByText('Your password has been successfully changed!', { selector: 'h5' })).toBeInTheDocument(); + }); + + it('renders the back to login button', () => { + render(); + const button = screen.getByRole('button', { name: 'Back to login' }); + expect(button).toBeInTheDocument(); + }) + + it('navigates to login page when back to login button is clicked', () => { + render(); + const button = screen.getByRole('button', { name: 'Back to login' }); + button.click(); + expect(mockPush).toHaveBeenCalledWith('/login'); + }); +}); \ No newline at end of file