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.
Merge pull request #79 from Arquisoft/feat/webapp/new-dashboard
Feat/webapp/new dashboard
- Loading branch information
Showing
9 changed files
with
154 additions
and
6 deletions.
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
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
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
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
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,33 @@ | ||
import { Center } from "@chakra-ui/layout"; | ||
import { Grid, Flex, Heading, Button, Box } from "@chakra-ui/react"; | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useTranslation } from "react-i18next"; | ||
import ButtonEf from '../components/ButtonEf'; | ||
|
||
export default function Dashboard() { | ||
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="h2" color="blue.400">{t("common.dashboard")}</Heading> | ||
|
||
<Box bg="white" p={4} borderRadius="md" boxShadow="md" mt={4} mb={4} w="fit-content"> | ||
<Grid templateColumns="repeat(3, 1fr)" gap={4}> | ||
<ButtonEf dataTestId={"Rules"} variant={"outline"} colorScheme={"blue"} text={t("common.rules")} onClick={() => navigate("/dashboard/rules")}/> | ||
<ButtonEf dataTestId={"Play"} variant={"solid"} colorScheme={"blue"} text={t("common.play")} onClick={() => navigate("/dashboard/game")}/> | ||
<Button isDisabled data-testid={"Statistics"} type="submit" colorScheme={"blue"} margin={"10px"} className={"custom-button effect1"} onClick={() => navigate("/dashboard/statistics")}> | ||
{t("common.statistics.title")} | ||
</Button> | ||
</Grid> | ||
|
||
<Flex direction="row" justifyContent="center" alignItems="center"> | ||
<Button type="submit" colorScheme="red" margin={"10px"} className={"custom-button effect1"} onClick={() => navigate("/login")} w="100%"> | ||
{t("common.logout")} | ||
</Button> | ||
</Flex> | ||
</Box> | ||
</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,31 @@ | ||
import { Center } from "@chakra-ui/layout"; | ||
import { Text, Flex, Heading, Button, Box } from "@chakra-ui/react"; | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export default function Rules() { | ||
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="h2" color="blue.400">{t("common.rules")}</Heading> | ||
|
||
<Box bg="white" p={4} borderRadius="md" boxShadow="md" mt={4} mb={4} w={{ base: "90%", md: "70%", lg: "50%" }} textAlign={"justify"}> | ||
<Text>The <strong>WIQ</strong> game consists of quick games of 9 rounds. In each round there is one question and two possible answers. The key to earning points lies in choosing the correct answer.</Text> | ||
<br/> | ||
<Text>There is only one correct answer.</Text> | ||
<br/> | ||
<Text>You have to select a question before time runs out.</Text> | ||
<br/> | ||
<Text>To start playing you have to click on the Play button.</Text> | ||
<Flex direction="row" justifyContent="center" alignItems="center"> | ||
<Button data-testid={"GoBack"} type="submit" variant="solid" colorScheme="blue" margin={"10px"} className={"custom-button effect1"} onClick={() => navigate("/dashboard")} w="100%"> | ||
{t("common.goBack")} | ||
</Button> | ||
</Flex> | ||
</Box> | ||
</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,45 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, screen } from '@testing-library/react'; | ||
import { MemoryRouter } from 'react-router'; | ||
import Dashboard from '../pages/Dashboard'; | ||
|
||
describe('Dashboard component', () => { | ||
it('renders dashboard elements correctly', async () => { | ||
const { getByText } = render(<MemoryRouter><Dashboard/></MemoryRouter>); | ||
|
||
// Check if the heading is rendered | ||
expect(getByText("common.dashboard")).toBeInTheDocument(); | ||
|
||
// Check if the buttons are rendered | ||
expect(screen.getByTestId('Rules')).toBeInTheDocument(); | ||
expect(screen.getByTestId('Play')).toBeInTheDocument(); | ||
expect(screen.getByTestId('Statistics')).toBeInTheDocument(); | ||
|
||
// Check if the logout button is rendered | ||
expect(screen.getByText(/logout/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it('navigates to the rules route on button click', () => { | ||
// Render the component | ||
render(<MemoryRouter><Dashboard /></MemoryRouter>); | ||
|
||
const rulesButton = screen.getByTestId('Rules'); | ||
fireEvent.click(rulesButton); | ||
|
||
// Check the change of path | ||
expect(screen.getByText("common.rules")).toBeInTheDocument(); | ||
}); | ||
|
||
it('do not navigates to the statistics route on button click', () => { | ||
// Render the component | ||
render(<MemoryRouter><Dashboard /></MemoryRouter>); | ||
|
||
const statisticsButton = screen.getByTestId('Statistics'); | ||
fireEvent.click(statisticsButton); | ||
|
||
// Check the change of path | ||
expect(screen.getByText("common.dashboard")).toBeInTheDocument(); | ||
}); | ||
|
||
// Test the play and log out buttons. | ||
}); |
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,16 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { MemoryRouter } from 'react-router'; | ||
import Rules from '../pages/Rules'; | ||
|
||
describe('Rules component', () => { | ||
it('renders rules elements correctly', async () => { | ||
const { getByText, getByTestId } = render(<MemoryRouter><Rules/></MemoryRouter>); | ||
|
||
// Check if the heading is rendered | ||
expect(getByText("common.rules")).toBeInTheDocument(); | ||
|
||
// Check if the button is rendered | ||
expect(getByTestId('GoBack')).toBeInTheDocument(); | ||
}); | ||
}); |
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