Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding the home page and tests for it #84

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@
"username": "Username",
"password": "Password",
"email": "Email",
"confirm_password": "Confirm password"
"confirm_password": "Confirm password",
"welcome": "Welcome to the WIQ-EN2B page",
"account": "Don't have an account?"
},
"error": {
"login": "An ERROR occurred during login"
4 changes: 3 additions & 1 deletion webapp/public/locales/es/translation.json
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@
"username": "Nombre de usuario",
"password": "Contraseña",
"email": "Correo electrónico",
"confirm_password": "Confirmar contraseña"
"confirm_password": "Confirmar contraseña",
"welcome": "Bienvenido a la página principal de WIQ-EN2B",
"account": "¿No tienes una cuenta?"
},
"error": {
"login": "Ocurrió un ERROR en el login"
4 changes: 2 additions & 2 deletions webapp/src/pages/Root.jsx
Original file line number Diff line number Diff line change
@@ -13,10 +13,10 @@ export default function Root() {
<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>
<p>{t("session.welcome")}</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>
<p onClick={() => navigate("/signup")} style={{ cursor: 'pointer' }}>{t("session.account")}</p>
</Stack>
</Center>
);
8 changes: 4 additions & 4 deletions webapp/src/tests/Root.test.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ describe('Root component', () => {

it('renders welcome message', () => {
render(<MemoryRouter><Root /></MemoryRouter>);
const welcomeMessage = screen.getByText(/welcome to the WIQ-EN2B page/i);
const welcomeMessage = screen.getByText('session.welcome');
expect(welcomeMessage).toBeInTheDocument();
});

@@ -25,12 +25,12 @@ describe('Root component', () => {
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>');
expect(container.innerHTML).toMatch('<div class=\"css-xmmg5m\"><h1 class=\"chakra-heading css-p03q1r\">WIQ-EN2B</h1><p>session.welcome</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;\">session.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>');
fireEvent.click(screen.getByText('session.account'));
expect(container.innerHTML).toMatch('<div class=\"css-xmmg5m\"><h1 class=\"chakra-heading css-p03q1r\">WIQ-EN2B</h1><p>session.welcome</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;\">session.account</p></div></div>');
});
});