diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index d34988d..0179e3d 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -91,21 +91,7 @@ app.post('/getUser', async (req, res) => { app.get('/GetQuestions', async (_req, res) => { - try { - const wikiResponse = await axios.get(wikidataServiceUrl + '/getQuestions', { timeout: 10000 }); - if (wikiResponse.status !== 200) { - let statusCode = wikiResponse.status ? wikiResponse.status : 500; - - console.error('Error with the wikidata service:', statusCode); - res.status(statusCode).json({ error: 'Error with the wikidata service' }); - - } else { - res.json(wikiResponse.data); - } - } catch (error) { - console.error(error); - res.status(500).json({ error: error }); - } + getQuestions('/getQuestions', res); }); app.get('/GetCapitalsQuestions', async (_req, res) => { diff --git a/webapp/public/penguins.webp b/webapp/public/penguins.webp new file mode 100644 index 0000000..a5b9291 Binary files /dev/null and b/webapp/public/penguins.webp differ diff --git a/webapp/src/App.tsx b/webapp/src/App.tsx index a6ab857..ca773b1 100644 --- a/webapp/src/App.tsx +++ b/webapp/src/App.tsx @@ -3,6 +3,7 @@ import { loginWithToken } from './services/auth-service'; import Authentication from './components/auth/Authentication'; import { useUserStore } from './stores/user-store'; import { Home } from './components/general/Home'; +import Info from './components/general/Info'; import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; import { SimpleNav } from './components/general/SimpleNav'; import { TriviaGame } from './components/Game/Trivia/TriviaGame'; @@ -36,6 +37,7 @@ function App() { } /> }/> }/> + } /> } /> } /> diff --git a/webapp/src/components/Game/GameOver.tsx b/webapp/src/components/Game/GameOver.tsx index 52f43fd..f0a2275 100644 --- a/webapp/src/components/Game/GameOver.tsx +++ b/webapp/src/components/Game/GameOver.tsx @@ -38,7 +38,7 @@ const GameOver = (props: props) => { ) { imageToShow = images.lowScore; message = "You are NOT smarter than a penguin"; - } else if (scorePercentage < 75) { + } else if (scorePercentage < 100) { imageToShow = images.mediumScore; message = "You ARE smarter than a penguin"; } else { diff --git a/webapp/src/components/general/Info.test.tsx b/webapp/src/components/general/Info.test.tsx new file mode 100644 index 0000000..f30fb45 --- /dev/null +++ b/webapp/src/components/general/Info.test.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import Info from './Info'; + +test('renders Info component', () => { + render(); + + // Check if the header is present + const headerElement = screen.getByText(/INFORMATION/i); + expect(headerElement).toBeInTheDocument(); + + // Check if the image is present + const imageElement = screen.getByAltText(/Descripción de la imagen/i); + expect(imageElement).toBeInTheDocument(); + + // Check if the rules are present + const rulesElement = screen.getByText(/Rules:/i); + expect(rulesElement).toBeInTheDocument(); + + // Check if the game modes are present + const normalGameElement = screen.getByText(/Normal Game:/i); + expect(normalGameElement).toBeInTheDocument(); + + const triviaGameElement = screen.getByText(/Trivia game:/i); + expect(triviaGameElement).toBeInTheDocument(); + + // Check if the links are present + const linksElement = screen.getByText(/Links:/i); + expect(linksElement).toBeInTheDocument(); + + // Check if the GitHub link is present + const githubLinkElement = screen.getByText(/GitHub/i); + expect(githubLinkElement).toBeInTheDocument(); + expect(githubLinkElement).toHaveAttribute('href', 'https://github.com/Arquisoft/wiq_en3a'); + + // Check if the Documentation link is present + const documentationLinkElement = screen.getByText(/Documentation/i); + expect(documentationLinkElement).toBeInTheDocument(); + expect(documentationLinkElement).toHaveAttribute('href', 'https://arquisoft.github.io/wiq_en3a/'); + + // Check if the OpenAPI link is present + const openApiLinkElement = screen.getByText(/OpenAPI/i); + expect(openApiLinkElement).toBeInTheDocument(); + expect(openApiLinkElement).toHaveAttribute('href', 'http://51.103.210.249:8000/api-doc/'); +}); \ No newline at end of file diff --git a/webapp/src/components/general/Info.tsx b/webapp/src/components/general/Info.tsx new file mode 100644 index 0000000..9e6c0c3 --- /dev/null +++ b/webapp/src/components/general/Info.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import { FaLink, FaSkullCrossbones, FaSmile, FaGithub, FaBook, FaFileAlt, FaBrain, FaGamepad } from 'react-icons/fa'; + +const Info = () => { + return ( +
+

INFORMATION

+ Descripción de la imagen + +
+

Rules:

+

Welcome to the game when you can became the penguins emperor! But... it will not be so easy...

+

For you to become the king, you should pass the game without errors. Show off your knowledge 🧠 in our two exciting game modes:

+
+
+

Normal Game:

+

+ You will have to go through 10 different questions of random topics. Each of the questions will have 4 different options but only 1 is correct! +

+
+

Easy :

+

You have 10 seconds to answer each question.

+
+
+

Hard:

+

You have 4 second to answer each question.

+
+ +
+

Trivia game:

+

Our favorite, the trivial mode. Test your skills across five categories: Sports, Science, History, Geography, and Entertainment. + Earn a "cheese🧀" for every correct answer, and collect all five to win. + The game will end when you gain all the chesses or if you fail a number of questions depending of the difficulty. +

+
+

Easy:

+

If you fail 6 questions, you will lose the game.

+
+
+

Hard:

+

If you fail 3 questions, you will lose the game.

+
+
+ +
+

Links:

+ + +
+ ); +} + +export default Info; \ No newline at end of file diff --git a/webapp/src/components/general/SimpleNav.test.tsx b/webapp/src/components/general/SimpleNav.test.tsx index f01dbd0..94feb03 100644 --- a/webapp/src/components/general/SimpleNav.test.tsx +++ b/webapp/src/components/general/SimpleNav.test.tsx @@ -64,31 +64,4 @@ describe('SimpleNav', () => { fireEvent.click(getByTestId('audio-button')); }); - - /*test('toggles audio playback when button is clicked', () => { - const { getByTestId } = render( ); - - // Mock HTML audio element - const playMock = jest.fn(); - const pauseMock = jest.fn(); - const audioMock = { - current: { - play: playMock, - pause: pauseMock - } - }; - jest.spyOn(React, 'useRef').mockReturnValue(audioMock); - - // Click on audio button - fireEvent.click(getByTestId('audio-button')); - - // Check if audio play function is called - expect(playMock).toHaveBeenCalled(); - - // Click on audio button again - fireEvent.click(getByTestId('audio-button')); - - // Check if audio pause function is called - expect(pauseMock).toHaveBeenCalled(); - });*/ }); \ No newline at end of file diff --git a/webapp/src/components/general/SimpleNav.tsx b/webapp/src/components/general/SimpleNav.tsx index 8e5063e..cfffaf7 100644 --- a/webapp/src/components/general/SimpleNav.tsx +++ b/webapp/src/components/general/SimpleNav.tsx @@ -2,12 +2,10 @@ import { Avatar, AvatarFallback } from "../ui/avatar"; import React, { useState, useRef } from 'react'; import { Link } from "react-router-dom"; -import { useUserStore, getUsername } from '../../stores/user-store'; - +import { getUsername } from '../../stores/user-store'; +import { FaInfoCircle, FaVolumeUp, FaVolumeMute } from 'react-icons/fa'; export const SimpleNav = () => { - //let user = useUserStore(state => state.user!); - const getLinkStyle = ():string => { return "text-text text-sm font-bold hover:text-primary transition-colors duration-300 ease-in-out" } @@ -41,14 +39,17 @@ export const SimpleNav = () => { -
+
Home Leaderboard Statistics - Logout + Logout + { isPlaying ? : } + + + +