From d1c18e4edb88cb57b8382846db6ed02aeb34b6d7 Mon Sep 17 00:00:00 2001 From: Pedro Limeres <113518495+plg22@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:10:40 +0200 Subject: [PATCH 01/12] update part 6 of the docs --- docs/src/06_runtime_view.adoc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/docs/src/06_runtime_view.adoc b/docs/src/06_runtime_view.adoc index 4faafae..27e9e70 100644 --- a/docs/src/06_runtime_view.adoc +++ b/docs/src/06_runtime_view.adoc @@ -16,10 +16,10 @@ collections UsersService database DB User -> FrontEnd: Request login -FrontEnd -> UsersService: loginUser() -UsersService -> DB: checkUserData() +FrontEnd -> UsersService: "/users/login" +UsersService -> DB: validateRequiredFields() DB -> UsersService: Confirm data -UsersService -> UsersService: login() +UsersService -> UsersService: loginUser() UsersService -> FrontEnd: Confirm login ---- @@ -35,12 +35,11 @@ collections UsersService database DB User -> FrontEnd: Request sign up -FrontEnd -> UsersService: registerUser() +FrontEnd -> UsersService: "/users/adduser" UsersService -> DB: checkCredentialsExist() DB -> UsersService: Confirm data -UsersService -> DB: CreateUserData() +UsersService -> DB: Create new user DB -> UsersService: Confirm data -UsersService -> UsersService: signUp() UsersService -> FrontEnd: Redirect to login page @enduml ---- @@ -53,16 +52,15 @@ Sequence diagram for the process of retrieving data from WikiData ---- actor User collections FrontEnd -collections QuestionGenerator +collections WikidataService database Wikidata -User -> FrontEnd: Request a game -FrontEnd -> QuestionGenerator: createGame() -QuestionGenerator-> Wikidata: Sparql query -Wikidata-> QuestionGenerator : entitites data -QuestionGenerator-> QuestionGenerator: fillQuestionStack() -QuestionGenerator-> QuestionGenerator: popGameQuestions() -QuestionGenerator-> FrontEnd: Send game +User -> FrontEnd: Start Game +FrontEnd -> WikidataService: "/GetQuestions" +WikidataService-> Wikidata: Sparql query +Wikidata-> WikidataService : entitites data +WikidataService-> WikidataService: createQuestions() +WikidataService-> FrontEnd: Send 10 questions FrontEnd -> User: Question 1 User-> FrontEnd: Answer 1 ---- From c96ac7b2456a8e9e0da971395a3632e900f6141f Mon Sep 17 00:00:00 2001 From: ritacatuxo <87928858+ritacatuxo@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:29:23 +0200 Subject: [PATCH 02/12] remove svelte from glossary.adoc --- docs/src/12_glossary.adoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/src/12_glossary.adoc b/docs/src/12_glossary.adoc index 9cd9498..fca9993 100644 --- a/docs/src/12_glossary.adoc +++ b/docs/src/12_glossary.adoc @@ -65,9 +65,6 @@ See https://docs.arc42.org/section-12/[Glossary] in the arc42 documentation. |MongoDB |A popular open-source NoSQL database management system known for its flexibility, scalability, and ease of use. It stores data in a flexible, JSON-like format called BSON and is commonly used for applications requiring high-volume data storage and real-time data processing. -|Svelte -|A modern JavaScript framework for building user interfaces. Unlike traditional frameworks that require the runtime presence of a virtual DOM, Svelte shifts the work to compile-time, resulting in highly optimized and efficient code with smaller bundle sizes. - |API (Application programming interface) |Set of rules and protocols that allows different software applications to communicate and interact with each other. APIs define the methods and data formats that applications can use to request and exchange information. They enable developers to access the functionality of other software components or services without having to understand their internal workings. APIs are commonly used to integrate third-party services, access data from remote servers, and build modular and interoperable software systems. From 876aab77b7494a89426b90c0f08400eff1f629ce Mon Sep 17 00:00:00 2001 From: Pedro Limeres <113518495+plg22@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:36:50 +0200 Subject: [PATCH 03/12] More decisions and fixes --- docs/src/06_runtime_view.adoc | 2 -- docs/src/09_architecture_decisions.adoc | 1 + docs/src/11_technical_risks.adoc | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/src/06_runtime_view.adoc b/docs/src/06_runtime_view.adoc index 27e9e70..c595a83 100644 --- a/docs/src/06_runtime_view.adoc +++ b/docs/src/06_runtime_view.adoc @@ -64,5 +64,3 @@ WikidataService-> FrontEnd: Send 10 questions FrontEnd -> User: Question 1 User-> FrontEnd: Answer 1 ---- - -=== diff --git a/docs/src/09_architecture_decisions.adoc b/docs/src/09_architecture_decisions.adoc index 4418192..d361214 100644 --- a/docs/src/09_architecture_decisions.adoc +++ b/docs/src/09_architecture_decisions.adoc @@ -17,6 +17,7 @@ The following table contains the most interesting the design decisions that we h |ADR4| Docker | Fast deployment, ease of moving/maintaining your applications. Easy as we already have DockerFiles example| We do not have much experience using Docker |ADR5| PlantUML | Allows drawing diagrams very easily, with a simple syntax.| Does not allow as much control over the exact layout of the elements in the diagram as other tools. |ADR6| Node.js | For small applications it's a very fast techonology. It's easy to learn and we already know a bit about it| Its performance is reduced with heavy computational tasks +|ADR7| Wikidata API in C# | Better structure and two people knew about the language| Dificulties with deployment, using another editor to run it, problems when committing new files. |=== diff --git a/docs/src/11_technical_risks.adoc b/docs/src/11_technical_risks.adoc index f59104f..7ada8de 100644 --- a/docs/src/11_technical_risks.adoc +++ b/docs/src/11_technical_risks.adoc @@ -17,11 +17,11 @@ self-explanatory description, the probability of its occurrence, its impact on t | High | Each member will try to maximize its knowledge on some aspect of the project in the first weeks, in order to be able to be something similar to a leader in each one of the posible key aspects of the project. -|*Problems with Svelte* -| As a team we decided to try a new language for the front-end. +|*Problems with C#* +| As a team we decided to try .NET to code the API of wikidata. | High | High -| The team will practice with the language to be able to do a good job when implementing the front-end. +| The team will practice with the language to be able to do a good job when implementing the back-end. |*Problems with wikidata* | The team only used wikidata once before and not even everyone of us. From 31ae608218ae3af728ac76d2fb4ff066d0335a1b Mon Sep 17 00:00:00 2001 From: Pedro Limeres <113518495+plg22@users.noreply.github.com> Date: Wed, 10 Apr 2024 16:37:24 +0200 Subject: [PATCH 04/12] Another new decision --- docs/src/09_architecture_decisions.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/09_architecture_decisions.adoc b/docs/src/09_architecture_decisions.adoc index d361214..583c0fc 100644 --- a/docs/src/09_architecture_decisions.adoc +++ b/docs/src/09_architecture_decisions.adoc @@ -12,12 +12,13 @@ The following table contains the most interesting the design decisions that we h |=== |Code|Decision|Advantages|Disadvantages |ADR1| React.js | Quite easy to learn in comparison to other front-end libraries. Increasingly popular in the web.| Not all of us know about its usage -|ADR2| Tawilwind CSS | Consistent and unified design system and its ability to speed up the development process. Rapidly growing utility-first CSS framework | Quite new for most of us +|ADR2| Tailwind CSS | Consistent and unified design system and its ability to speed up the development process. Rapidly growing utility-first CSS framework | Quite new for most of us |ADR3| MongoDB | It does not need to be started manually. Free and easy to understand| We are quite new with MongoDB. |ADR4| Docker | Fast deployment, ease of moving/maintaining your applications. Easy as we already have DockerFiles example| We do not have much experience using Docker |ADR5| PlantUML | Allows drawing diagrams very easily, with a simple syntax.| Does not allow as much control over the exact layout of the elements in the diagram as other tools. |ADR6| Node.js | For small applications it's a very fast techonology. It's easy to learn and we already know a bit about it| Its performance is reduced with heavy computational tasks |ADR7| Wikidata API in C# | Better structure and two people knew about the language| Dificulties with deployment, using another editor to run it, problems when committing new files. +|ADR8| Database for questions | Support if wikidata service stops working | New different relational database into the aplication, new api to develop, dependency on the database server we choose to use. |=== From 133abab7a7be1f7a9dc45b5da1e25416112f7b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Mac=C3=ADas?= Date: Wed, 10 Apr 2024 16:48:08 +0200 Subject: [PATCH 05/12] test commented --- webapp/src/components/Game/Countdown.test.tsx | 38 +++++++++++++++++++ webapp/src/components/Game/Counter.test.tsx | 31 +++++++++++++++ webapp/src/components/Game/Counter.tsx | 2 +- webapp/src/components/Game/Game.test.tsx | 7 +++- webapp/src/components/general/Home.tsx | 2 +- 5 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 webapp/src/components/Game/Countdown.test.tsx create mode 100644 webapp/src/components/Game/Counter.test.tsx diff --git a/webapp/src/components/Game/Countdown.test.tsx b/webapp/src/components/Game/Countdown.test.tsx new file mode 100644 index 0000000..6b8af40 --- /dev/null +++ b/webapp/src/components/Game/Countdown.test.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { render, fireEvent, screen } from '@testing-library/react'; +import Answer from './Answer'; + +describe('Answer component', () => { + const mockedProps = { + answered: false, + correctAnswer: true, + answer: 'Correct Answer', + score: 0, + setAnswered: jest.fn(), + setScore: jest.fn(), + setCorrectSelected: jest.fn(), + }; + + test('renders the answer', () => { + render(); + expect(screen.getByText('Correct Answer')).toBeInTheDocument(); + }); + + test('calls the setAnswered, setCorrectSelected, and setScore functions when clicked', () => { + render(); + fireEvent.click(screen.getByText('Correct Answer')); + expect(mockedProps.setAnswered).toHaveBeenCalledWith(true); + expect(mockedProps.setCorrectSelected).toHaveBeenCalledWith(true); + expect(mockedProps.setScore).toHaveBeenCalledWith(10); + }); + + test('changes the button class when answered', () => { + render(); + expect(screen.getByText('Correct Answer')).toHaveClass('bg-primary'); + }); + + test('disables the button when answered', () => { + render(); + expect(screen.getByText('Correct Answer')).toBeDisabled(); + }); +}); \ No newline at end of file diff --git a/webapp/src/components/Game/Counter.test.tsx b/webapp/src/components/Game/Counter.test.tsx new file mode 100644 index 0000000..c1bce1e --- /dev/null +++ b/webapp/src/components/Game/Counter.test.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { render, fireEvent, screen } from '@testing-library/react'; +import Counter from './Counter'; + +describe('Counter component', () => { + const mockedProps = { + answered: false, + setAnswered: jest.fn(), + duration: 1000, + count: 0, + setCount: jest.fn(), + initialCount: 1000, + }; + + test('renders the counter', () => { + render(); + expect(screen.findByTestId('counter')); + }); + + // test('checks that the progress bar decreases in time', () => { + // // Importa la función que simula el paso del tiempo + // jest.useFakeTimers(); + // render(); + + // jest.advanceTimersByTime(10000); + + // expect(screen.findByTestId('counter')); + // }); + + +}); \ No newline at end of file diff --git a/webapp/src/components/Game/Counter.tsx b/webapp/src/components/Game/Counter.tsx index e49cfaf..5a23a82 100644 --- a/webapp/src/components/Game/Counter.tsx +++ b/webapp/src/components/Game/Counter.tsx @@ -30,7 +30,7 @@ const Counter = (props: props) => { } }, [props.count]); - return ; + return ; }; export default Counter; \ No newline at end of file diff --git a/webapp/src/components/Game/Game.test.tsx b/webapp/src/components/Game/Game.test.tsx index 8115a4b..c940103 100644 --- a/webapp/src/components/Game/Game.test.tsx +++ b/webapp/src/components/Game/Game.test.tsx @@ -5,5 +5,10 @@ import Game from './Game'; test('always true test', () => { - expect(true).toBe(true); + // render(); + + // // Verifica que el componente Game se renderizó correctamente + // const gameComponent = screen.getByTestId('game-component'); + // expect(gameComponent).toBeInTheDocument(); + expect(true).toBe(true); }); \ No newline at end of file diff --git a/webapp/src/components/general/Home.tsx b/webapp/src/components/general/Home.tsx index 27b66c0..a1564ab 100644 --- a/webapp/src/components/general/Home.tsx +++ b/webapp/src/components/general/Home.tsx @@ -20,7 +20,7 @@ export const Home = () => {