diff --git a/frontend/src/auth/LoginPage.test.tsx b/frontend/src/auth/LoginPage.test.tsx index 5a98fe4..bd51a4e 100644 --- a/frontend/src/auth/LoginPage.test.tsx +++ b/frontend/src/auth/LoginPage.test.tsx @@ -122,4 +122,24 @@ describe('LoginPage', () => { expect(await screen.findByText('SCENARIOS')).toBeInTheDocument() }) + + it('links to the register page', async () => { + server.use( + http.get('http://localhost/api/me', () => + HttpResponse.json({ message: 'unauthorized' }, { status: 401 }), + ), + ) + + render( + + + , + ) + + const registerLink = await screen.findByRole('link', { + name: /register|sign up|create account/i, + }) + + expect(registerLink).toHaveAttribute('href', '/register') + }) }) diff --git a/frontend/src/auth/LoginPage.tsx b/frontend/src/auth/LoginPage.tsx index ade5a94..be74053 100644 --- a/frontend/src/auth/LoginPage.tsx +++ b/frontend/src/auth/LoginPage.tsx @@ -1,4 +1,5 @@ import { useState, type FormEvent } from 'react' +import { Link } from 'react-router' import AppLayout from '../components/layout/AppLayout' import Button from '../components/ui/Button' import Input from '../components/ui/Input' @@ -73,6 +74,13 @@ export default function LoginPage() { {pending ? 'Logging In…' : 'Log In'} + +

+ No account?{' '} + + Register + +

) diff --git a/frontend/src/auth/RegisterPage.test.tsx b/frontend/src/auth/RegisterPage.test.tsx index 7ada828..9b26582 100644 --- a/frontend/src/auth/RegisterPage.test.tsx +++ b/frontend/src/auth/RegisterPage.test.tsx @@ -169,4 +169,24 @@ describe('RegisterPage', () => { expect(await screen.findByText('LOGIN')).toBeInTheDocument() }) + + it('links to the login page', async () => { + server.use( + http.get('http://localhost/api/me', () => + HttpResponse.json({ message: 'unauthorized' }, { status: 401 }), + ), + ) + + render( + + + , + ) + + const loginLink = await screen.findByRole('link', { + name: /log ?in|sign in/i, + }) + + expect(loginLink).toHaveAttribute('href', '/login') + }) }) diff --git a/frontend/src/auth/RegisterPage.tsx b/frontend/src/auth/RegisterPage.tsx index 60749e5..dab4016 100644 --- a/frontend/src/auth/RegisterPage.tsx +++ b/frontend/src/auth/RegisterPage.tsx @@ -1,5 +1,5 @@ import { useState, type FormEvent } from 'react' -import { useNavigate } from 'react-router' +import { Link, useNavigate } from 'react-router' import AppLayout from '../components/layout/AppLayout' import Button from '../components/ui/Button' import FieldError from '../components/ui/FieldError' @@ -87,6 +87,13 @@ export default function RegisterPage() { {pending ? 'Registering…' : 'Register'} + +

+ Already have an account?{' '} + + Log In + +

)