generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding the home page and tests for it
- Loading branch information
1 parent
7e20141
commit 4c10145
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
@@ -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 <p>Proof of concept</p> | ||
const navigate = useNavigate(); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Center display={"flex"} flexDirection={"column"} w={"100wh"} h={"100vh"} | ||
bg={"blue.50"} justifyContent={"center"} alignItems={"center"}> | ||
<Heading as="h1" color="blue.400">{"WIQ-EN2B"}</Heading> | ||
<p>Welcome to the WIQ-EN2B page</p> | ||
<Stack spacing={4} p="3rem"> | ||
<ButtonEf dataTestId={"Login"} variant={"solid"} colorScheme={"blue"} text={t("common.login")} onClick={() => navigate("/login")}/> | ||
<p onClick={() => navigate("/signup")} style={{ cursor: 'pointer' }}>You don´t have an account?</p> | ||
</Stack> | ||
</Center> | ||
); | ||
} |
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,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(<MemoryRouter><Root /></MemoryRouter>); | ||
const headingElement = screen.getByText('WIQ-EN2B'); | ||
expect(headingElement).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders welcome message', () => { | ||
render(<MemoryRouter><Root /></MemoryRouter>); | ||
const welcomeMessage = screen.getByText(/welcome to the WIQ-EN2B page/i); | ||
expect(welcomeMessage).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders Log In button', () => { | ||
render(<MemoryRouter><Root /></MemoryRouter>); | ||
expect(getByTestId(document.body, 'Login')).toBeInTheDocument(); | ||
}); | ||
|
||
it('navigates to /login when Log In button is clicked', () => { | ||
const { container } = render(<MemoryRouter><Root /></MemoryRouter>); | ||
fireEvent.click(getByTestId(document.body, 'Login')); | ||
expect(container.innerHTML).toMatch('<div class=\"css-xmmg5m\"><h1 class=\"chakra-heading css-p03q1r\">WIQ-EN2B</h1><p>Welcome to the WIQ-EN2B page</p><div class=\"chakra-stack css-gjlptk\"><button type=\"submit\" class=\"chakra-button custom-button effect1 css-1vdwnhw\" data-testid=\"Login\">common.login</button><p style=\"cursor: pointer;\">You don´t have an account?</p></div></div>'); | ||
}); | ||
|
||
it('navigates to /signup when "You don\'t have an account?" message is clicked', () => { | ||
const { container } = render(<MemoryRouter><Root /></MemoryRouter>); | ||
fireEvent.click(screen.getByText('You don´t have an account?')); | ||
expect(container.innerHTML).toMatch('<div class=\"css-xmmg5m\"><h1 class=\"chakra-heading css-p03q1r\">WIQ-EN2B</h1><p>Welcome to the WIQ-EN2B page</p><div class=\"chakra-stack css-gjlptk\"><button type=\"submit\" class=\"chakra-button custom-button effect1 css-1vdwnhw\" data-testid=\"Login\">common.login</button><p style=\"cursor: pointer;\">You don´t have an account?</p></div></div>'); | ||
}); | ||
}); |