diff --git a/webapp/src/pages/Root.jsx b/webapp/src/pages/Root.jsx index c334a10c..2f907990 100644 --- a/webapp/src/pages/Root.jsx +++ b/webapp/src/pages/Root.jsx @@ -1,5 +1,23 @@ +import { Center } from "@chakra-ui/layout"; +import { Heading, Stack } from "@chakra-ui/react"; import React from "react"; +import { useTranslation } from "react-i18next"; +import { useNavigate } from "react-router-dom"; +import ButtonEf from '../components/ButtonEf'; export default function Root() { - return

Proof of concept

+ const navigate = useNavigate(); + const { t } = useTranslation(); + + return ( +
+ {"WIQ-EN2B"} +

Welcome to the WIQ-EN2B page

+ + navigate("/login")}/> +

navigate("/signup")} style={{ cursor: 'pointer' }}>You don´t have an account?

+
+
+ ); } \ No newline at end of file diff --git a/webapp/src/tests/Root.test.js b/webapp/src/tests/Root.test.js new file mode 100644 index 00000000..554312bb --- /dev/null +++ b/webapp/src/tests/Root.test.js @@ -0,0 +1,36 @@ +import React from 'react'; +import { render, screen, fireEvent, getByTestId } from '@testing-library/react'; +import { MemoryRouter, createMemoryRouter } from 'react-router'; +import Root from '../pages/Root'; + +describe('Root component', () => { + + it('renders WIQ-EN2B heading', () => { + render(); + const headingElement = screen.getByText('WIQ-EN2B'); + expect(headingElement).toBeInTheDocument(); + }); + + it('renders welcome message', () => { + render(); + const welcomeMessage = screen.getByText(/welcome to the WIQ-EN2B page/i); + expect(welcomeMessage).toBeInTheDocument(); + }); + + it('renders Log In button', () => { + render(); + expect(getByTestId(document.body, 'Login')).toBeInTheDocument(); + }); + + it('navigates to /login when Log In button is clicked', () => { + const { container } = render(); + fireEvent.click(getByTestId(document.body, 'Login')); + expect(container.innerHTML).toMatch('

WIQ-EN2B

Welcome to the WIQ-EN2B page

You don´t have an account?

'); + }); + + it('navigates to /signup when "You don\'t have an account?" message is clicked', () => { + const { container } = render(); + fireEvent.click(screen.getByText('You don´t have an account?')); + expect(container.innerHTML).toMatch('

WIQ-EN2B

Welcome to the WIQ-EN2B page

You don´t have an account?

'); + }); +}); \ No newline at end of file