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

pabloYalberto work on style and format of the application #323

Merged
merged 71 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f4ed9b0
Inter in TheChallengeGame.js
PabloGOP Apr 24, 2024
03b14ec
Forgot to add the categories as their keys are in a bizarre place
PabloGOP Apr 24, 2024
80d27c3
Fixed some i18n words.
alagoconde Apr 24, 2024
a687a7c
Default page title formating
PabloGOP Apr 24, 2024
980943c
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
PabloGOP Apr 24, 2024
54e35c2
Refactored categories names in the internationalization dictionaries …
PabloGOP Apr 24, 2024
5c2214f
<- XIF <- the layout of the challenge form
PabloGOP Apr 24, 2024
208e36f
Changed html components for mui material
PabloGOP Apr 24, 2024
2434848
Beatify increment/decrement buttons
PabloGOP Apr 24, 2024
7f3121d
Beautify final form button
PabloGOP Apr 24, 2024
747362a
Final layout adjustement
PabloGOP Apr 24, 2024
f067811
Definitive "retoque"
PabloGOP Apr 24, 2024
d1f5b47
Customized login and register buttoms to match general style
PabloGOP Apr 24, 2024
f0483cf
Solved enormous visual issue in VSC code
PabloGOP Apr 24, 2024
ce1862b
Solved problem to display initial form with npm start
PabloGOP Apr 24, 2024
f884ce3
Changing all the Discovering Cities game style.
alagoconde Apr 24, 2024
5c26192
Improved the code in the Discovering CIties game.
alagoconde Apr 24, 2024
dabf639
Wise men stack configuration layout
PabloGOP Apr 24, 2024
1c872e6
Improved the game code
alagoconde Apr 24, 2024
da3d29c
MUI components in Wise Men and unifyied internationalization dict ele…
PabloGOP Apr 24, 2024
96e16ed
Final form button style
PabloGOP Apr 24, 2024
f4e353b
Magic
PabloGOP Apr 24, 2024
44a59d5
Removed strange console.log in onClick event
PabloGOP Apr 24, 2024
10963ee
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
alagoconde Apr 24, 2024
1022cfd
Fixing react components in Games.
alagoconde Apr 24, 2024
e6260bf
Fixed the Challenge game view.
alagoconde Apr 24, 2024
c0b2f36
Minor style changes in game
PabloGOP Apr 24, 2024
3e6a939
Style changes in Wise Men
PabloGOP Apr 24, 2024
7f5b664
Final style for WiseMen
PabloGOP Apr 24, 2024
18b2576
Remove test question
PabloGOP Apr 24, 2024
59bf639
Stylized pause & play button
PabloGOP Apr 24, 2024
d13cdf5
Fixed the Warm Question game view.
alagoconde Apr 24, 2024
a0f8211
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
alagoconde Apr 24, 2024
b068041
Improved pause button with labels and applied to other games
PabloGOP Apr 24, 2024
99a03f2
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
alagoconde Apr 24, 2024
4fa6b72
Finished fising Warm Question game.
alagoconde Apr 24, 2024
2363c30
Removed the question template.
alagoconde Apr 24, 2024
e52776c
Included the new pause button in the last game that needed it.
alagoconde Apr 24, 2024
045ad6b
Solved code duplicity and change of texts in Wise Men tests
PabloGOP Apr 24, 2024
0f28bdc
Added tests to Wise Men until reach > 80%
PabloGOP Apr 24, 2024
ef57f93
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
PabloGOP Apr 24, 2024
38882e9
Added test-ids to test progress bars in games
PabloGOP Apr 24, 2024
962e911
Why TF is this test suite failing if i execute all but passes individ…
PabloGOP Apr 24, 2024
4f9ffaa
OMG I am a genius
PabloGOP Apr 25, 2024
9fb0592
Áureo update of the challenge form
PabloGOP Apr 25, 2024
b328472
Auricidad applied also to Wise Men
PabloGOP Apr 25, 2024
3d4c221
Updated multiplayer first screen style
PabloGOP Apr 25, 2024
ccdb76e
Improved the default game managment.
alagoconde Apr 25, 2024
8c72e62
Adapted the Wise Men Stack tests to the new style of its view.
alagoconde Apr 25, 2024
ee9cd43
Improved Warm Question Game calling.
alagoconde Apr 25, 2024
1c32683
Updated the Warm Question Game tests to match the new view style.
alagoconde Apr 25, 2024
6c6d2d0
Improved and adapted the Challenge game tests to the new style.
alagoconde Apr 25, 2024
ea51299
Fixed the Challenge game tests.
alagoconde Apr 25, 2024
fcf5359
Upgraded tests of the Discovering Cities game.
alagoconde Apr 25, 2024
9249d81
I don't know wtf happened with the tests that they were like, bad done.
alagoconde Apr 25, 2024
73109e5
Code improvements in the games.
alagoconde Apr 25, 2024
c34a620
Updated de Multiplayer Game principal view.
alagoconde Apr 25, 2024
333a5b6
Finished updating the Multiplayer style.
alagoconde Apr 25, 2024
1060b5c
Updated the multiplayer tests to match the new style.
alagoconde Apr 25, 2024
4d82448
Removed absolute height in circular progress in games
PabloGOP Apr 26, 2024
bf49165
Solved not passing e2e discovering cities tests
PabloGOP Apr 26, 2024
00fa20e
Solved failing e2e wise men tests
PabloGOP Apr 26, 2024
03273bd
Solved style dependant e2e tests
PabloGOP Apr 26, 2024
c35c96c
Minor error in test-id for the answers
PabloGOP Apr 26, 2024
118c961
Usual duplication problem in unit tests for warm question
PabloGOP Apr 26, 2024
7c37444
Same for thechallenge + failing test
PabloGOP Apr 26, 2024
b558dc6
Removed incorrect prog bar test in Game
PabloGOP Apr 26, 2024
f2f29f3
Fixed sonar cloud issue with label for the pause button
PabloGOP Apr 26, 2024
899b4cb
Removed flaky e2e test (note the two last action runs)
PabloGOP Apr 26, 2024
8ad436b
Added tests for warm question (fuck sonar cloud)
PabloGOP Apr 26, 2024
17462bd
Duplicity in unit tests in multiplayer + added test for the coverage
PabloGOP Apr 26, 2024
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: 2 additions & 2 deletions webapp/e2e/features/discoveringCitiesGame.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Feature: Answer a question
Scenario: Answering a question correctly
Given A question
When I click on the correct answer button
Then The button turns green
Then The selected answer is marked as right

Scenario: Answering a question incorrectly
Given A question
When I click on an incorrect answer button
Then The button turns red
Then The selected answer is marked as wrong
7 changes: 1 addition & 6 deletions webapp/e2e/features/wiseMenStackGame.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@ Feature: Answer a question
Scenario: Answering a question correctly
Given A question
When I click on the correct answer button
Then The button turns green

Scenario: Answering a question incorrectly
Given A question
When I click on an incorrect answer button
Then The button turns red
Then The selected answer is marked as right
56 changes: 26 additions & 30 deletions webapp/e2e/steps/discoveringCitiesGame.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,52 +65,48 @@ defineFeature(feature, test => {
test('Answering a question correctly', ({given,when,then}) => {

given('A question', async () => {
//await expect(page.findByText('Which is the capital of Spain?'));
const question = await page.$['data-testid="question"'];
await expect(page).toMatchElement("div", { text: 'Which is the capital of Spain?'});
expect(question).not.toBeNull();

const answers = await page.$x('//*[@data-testid="answer"]');
expect(answers.length).toBe(4);
const question = await page.$['data-testid="question"'];
await expect(page).toMatchElement("div", { text: 'WHICH IS THE CAPITAL OF SPAIN?'});
expect(question).not.toBeNull();

const answers = await page.$x('//*[contains(@data-testid, "answer")]');
expect(answers.length).toBe(4);
});

when('I click on the correct answer button', async () => {
const answers = await page.$x('(//*[@data-testid="answer"])[1]');
await answers[0].click();
const answers = await page.$x('//*[contains(@data-testid, "answer")]');
await answers[0].click();
});

then('The button turns green', async () => {
const answerButton = await page.$x('(//*[@data-testid="answer"])[1]');
const textoBoton = await page.evaluate(button => button.innerText, answerButton[0]);
await expect(textoBoton).toMatch(/Madrid/i);
await expect(page).toMatchElement("button", { style: { color: 'green' } });
then('The selected answer is marked as right', async () => {
const answer = await page.$x('//*[contains(@data-testid, "success")]');
expect(answer.length).toBe(1);
const textoBoton = await page.evaluate(button => button.innerText, answer[0]);
await expect(textoBoton).toMatch(/Madrid/i);
});
})

test('Answering a question incorrectly', ({given,when,then}) => {

given('A question', async () => {
//await expect(page.findByText('Which is the capital of Spain?'));
const question = await page.$['data-testid="question"'];
await expect(page).toMatchElement("div", { text: 'Which is the capital of Spain?'});
expect(question).not.toBeNull();

const answers = await page.$x('//*[@data-testid="answer"]');
expect(answers.length).toBe(4);
const question = await page.$['data-testid="question"'];
await expect(page).toMatchElement("div", { text: 'WHICH IS THE CAPITAL OF SPAIN?'});
expect(question).not.toBeNull();

const answers = await page.$x('//*[contains(@data-testid, "answer")]');
expect(answers.length).toBe(4);
});

when('I click on an incorrect answer button', async () => {
const answers = await page.$x('(//*[@data-testid="answer"])[2]');
await answers[0].click();
const answers = await page.$x('//*[contains(@data-testid, "answer")]');
await answers[1].click();
});

then('The button turns red', async () => {
const answerButton = await page.$x('(//*[@data-testid="answer"])[2]');
const textoBoton = await page.evaluate(button => button.innerText, answerButton[0]);
await expect(textoBoton).toMatch(/Barcelona/i);
await expect(page).toMatchElement("button", { style: { color: 'red' } });
await expect(page).toMatchElement("button", { style: { color: 'green' } });

then('The selected answer is marked as wrong', async () => {
const answer = await page.$x('//*[contains(@data-testid, "fail")]');
expect(answer.length).toBe(1);
const textoBoton = await page.evaluate(button => button.innerText, answer[0]);
await expect(textoBoton).toMatch(/Barcelona/i);
});
})

Expand Down
87 changes: 21 additions & 66 deletions webapp/e2e/steps/wiseMenStackGame.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ defineFeature(feature, test => {

beforeAll(async () => {

browser = process.env.GITHUB_ACTIONS
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 40 });
page = await browser.newPage();
Expand Down Expand Up @@ -65,77 +65,32 @@ defineFeature(feature, test => {
test('Answering a question correctly', ({given,when,then}) => {

given('A question', async () => {
const button = await page.$('[data-testid="start-button"]');
await button.click();
const button = await page.$('[data-testid="start-button"]');
await button.click();

//await expect(page.findByText('Which is the capital of Spain?'));
const question = await page.$['data-testid="question"'];
await expect(page).toMatchElement("div", { text: 'Which is the capital of Spain?'});
expect(question).not.toBeNull();

const answers = await page.$x('//*[@data-testid="answer"]');
expect(answers.length).toBe(2);
const question = await page.$['data-testid="question"'];
expect(question).not.toBeNull();
await expect(page).toMatchElement("div", { text: 'WHICH IS THE CAPITAL OF SPAIN?'});

const answers = await page.$x('//*[contains(@data-testid, "answer")]');
expect(answers.length).toBe(2);
});

when('I click on the correct answer button', async () => {
const answers = await page.$x('//*[@data-testid="answer"]');
const textoBoton1 = await page.evaluate(button => button.innerText, answers[0]);
if(textoBoton1 === "Madrid") {
await answers[0].click();
} else {
await answers[1].click();
}
});

then('The button turns green', async () => {
/*const answerButton = await page.$x('(//*[@data-testid="answer"])[1]');
const textoBoton1 = await page.evaluate(button => button.innerText, answerButton[0]);
const textoBoton2 = await page.evaluate(button => button.innerText, answerButton[1]);
if(textoBoton1 === "Madrid") {
await expect(textoBoton1).toMatch(/Madrid/i);
} else {
await expect(textoBoton2).toMatch(/Madrid/i);
}*/
await expect(page).toMatchElement("button", { style: { color: 'green' } });
});
})

test('Answering a question incorrectly', ({given,when,then}) => {

given('A question', async () => {
const button = await page.$('[data-testid="start-button"]');
await button.click();

//await expect(page.findByText('Which is the capital of Spain?'));
const question = await page.$['data-testid="question"'];
await expect(page).toMatchElement("div", { text: 'Which is the capital of Spain?'});
expect(question).not.toBeNull();

const answers = await page.$x('//*[@data-testid="answer"]');
expect(answers.length).toBe(2);
});

when('I click on an incorrect answer button', async () => {
const answers = await page.$x('//*[@data-testid="answer"]');
const textoBoton1 = await page.evaluate(button => button.innerText, answers[0]);
if(textoBoton1 !== "Madrid") {
await answers[0].click();
} else {
await answers[1].click();
}
const answers = await page.$x('//*[contains(@data-testid, "answer")]');
const textoBoton1 = await page.evaluate(button => button.innerText, answers[0]);
if(textoBoton1 === "MADRID") {
await answers[0].click();
} else {
await answers[1].click();
}
});

then('The button turns red', async () => {
/*const answerButton = await page.$x('(//*[@data-testid="answer"])[2]');
const textoBoton1 = await page.evaluate(button => button.innerText, answerButton[0]);
const textoBoton2 = await page.evaluate(button => button.innerText, answerButton[1]);
if(textoBoton1 !== "Madrid") {
await expect(textoBoton1).not.toMatch(/Madrid/i);
} else {
await expect(textoBoton2).toMatch(/Madrid/i);
}*/
await expect(page).toMatchElement("button", { style: { color: 'red' } });
await expect(page).toMatchElement("button", { style: { color: 'green' } });
then('The selected answer is marked as right', async () => {
const answer = await page.$x('//*[contains(@data-testid, "success")]');
expect(answer.length).toBe(1);
const textoBoton = await page.evaluate(button => button.innerText, answer[0]);
await expect(textoBoton).toMatch(/Madrid/i);
});
})

Expand Down
4 changes: 2 additions & 2 deletions webapp/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Profile from './pages/Profile'
import MultiplayerRoom from './pages/MultiplayerRoom';
import MultiplayerGame from './pages/MultiplayerGame';
import TheChallengeGame from './pages/TheChallengeGame';
import WarmQuestion from './pages/WarmQuestionGame';
import WarmQuestionGame from './pages/WarmQuestionGame';
import {Route, Routes} from 'react-router-dom';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { Box } from '@mui/material';
Expand Down Expand Up @@ -66,7 +66,7 @@ function App() {
<Route path="/multiplayerRoom" element={<PrivateRoute element={MultiplayerRoom}/>}/>
<Route path="/theChallengeGame" element={<PrivateRoute element={TheChallengeGame}/>}/>
<Route path="/multiplayerGame" element={<PrivateRoute element={MultiplayerGame}/>}/>
<Route path="/warmQuestionGame" element={<PrivateRoute element={WarmQuestion}/>}/>
<Route path="/warmQuestionGame" element={<PrivateRoute element={WarmQuestionGame}/>}/>
<Route path="/group/menu" element={<PrivateRoute element={Groups}/>}/>
<Route path="/group/:groupName" element={<PrivateRoute element={GroupDetails}/>} />
<Route path="/statistics/:user" element={<PrivateRoute element={Statistics }/>}/>
Expand Down
59 changes: 36 additions & 23 deletions webapp/src/__tests__/pages/DiscoveringCitiesGame.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { SessionContext } from '../../SessionContext'; // Importa el contexto ne
import { BrowserRouter as Router } from 'react-router-dom';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Game from '../../pages/DiscoveringCitiesGame';
import DiscoveringCitiesGame from '../../pages/DiscoveringCitiesGame';
import '../../localize/i18n';

const mockAxios = new MockAdapter(axios);

describe('Game component', () => {
describe('Discovering Cities component', () => {
beforeEach(() => {
mockAxios.reset();
// Mock the axios.post request to simulate a successful response
Expand All @@ -32,85 +32,78 @@ describe('Game component', () => {
render(
<SessionContext.Provider value={{ username: 'exampleUser' }}>
<Router>
<Game />
<DiscoveringCitiesGame />
</Router>
</SessionContext.Provider>
);

expect(screen.getByRole('progressbar'));
//expect(screen.findByText('1'));
//expect(screen.findByText('1/5'));

// waits for the question to appear
await waitFor(() => screen.getByText('Which is the capital of Spain?'));
await waitFor(() => screen.getByTestId('question'));

expect(screen.findByText('Which is the capital of Spain?'));
expect(screen.getByTestId('question'));
expect(screen.findByText('Madrid'));
expect(screen.findByText('Barcelona'));
expect(screen.findByText('Paris'));
expect(screen.findByText('London'));

expect(screen.getByRole('button', { name: /Pause/i }));

});

it('should guess correct answer', async () => {
render(
<SessionContext.Provider value={{ username: 'exampleUser' }}>
<Router>
<Game />
<DiscoveringCitiesGame />
</Router>
</SessionContext.Provider>
);

// waits for the question to appear
await waitFor(() => screen.getByText('Which is the capital of Spain?'));
await waitFor(() => screen.getByTestId('question'));
const correctAnswer = screen.getByRole('button', { name: 'Madrid' });

expect(correctAnswer).not.toHaveStyle({ backgroundColor: 'green' });
expect(correctAnswer).toHaveStyle({ backgroundColor: 'rgb(0, 102, 153);' });

//selects correct answer
fireEvent.click(correctAnswer);

//expect(screen.findByText('1')).toHaveStyle({ backgroundColor: 'lightgreen' });

expect(correctAnswer).toHaveStyle({ backgroundColor: 'green' });
expect(correctAnswer).toHaveStyle({ backgroundColor: 'rgb(51, 153, 102);' });

});

it('should choose incorrect answer', async () => {
render(
<SessionContext.Provider value={{ username: 'exampleUser' }}>
<Router>
<Game />
<DiscoveringCitiesGame />
</Router>
</SessionContext.Provider>
);
// waits for the question to appear
await waitFor(() => screen.getByText('Which is the capital of Spain?'));
await waitFor(() => screen.getByTestId('question'));
const incorrectAnswer = screen.getByRole('button', { name: 'Barcelona' });

expect(incorrectAnswer).not.toHaveStyle({ backgroundColor: 'red' });
expect(incorrectAnswer).toHaveStyle({ backgroundColor: 'rgb(0, 102, 153);' });

//selects correct answer
fireEvent.click(incorrectAnswer);

expect(incorrectAnswer).toHaveStyle({ backgroundColor: 'red' });
//expect(screen.findByText('1')).toHaveStyle({ backgroundColor: 'salmon' });
expect(incorrectAnswer).toHaveStyle({ backgroundColor: 'rgb(153, 0, 0);' });

});

it('should not answer the question', async () => {
render(
<SessionContext.Provider value={{ username: 'exampleUser' }}>
<Router>
<Game />
<DiscoveringCitiesGame />
</Router>
</SessionContext.Provider>
);

// waits for the question to appear
await waitFor(() => screen.getByText('Which is the capital of Spain?'));
await waitFor(() => screen.getByTestId('question'));

setTimeout(() => {
// Comprobamos que el callback ha sido llamado después del tiempo especificado
Expand All @@ -119,4 +112,24 @@ describe('Game component', () => {

}, 4500);

it('should pause and resume the game after answering a question', async () => {
render(
<SessionContext.Provider value={{ username: 'exampleUser' }}>
<Router>
<DiscoveringCitiesGame />
</Router>
</SessionContext.Provider>
);

await waitFor(() => screen.getByTestId('question'));

fireEvent.click(screen.getByRole('button', { name: 'Madrid' }));

await waitFor(() => screen.getByTestId('pause'));

fireEvent.click(screen.getByTestId('pause'));

expect(screen.getByTestId('play')).toBeInTheDocument();
});

});
14 changes: 8 additions & 6 deletions webapp/src/__tests__/pages/Game.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ describe('Game component', () => {
);
});

it('should render question, answers and other ', async () => {
expect(screen.getByRole('progressbar'));
expect(screen.findByText('1'));
//expect(screen.findByText('1/3'));

it('should render question', async () => {
// waits for the question to appear
await waitFor(() => screen.getByText('Which is the capital of Spain?'.toUpperCase()));

Expand Down Expand Up @@ -94,6 +90,12 @@ describe('Game component', () => {
expect(pauseButton);
fireEvent.click(pauseButton);
expect(screen.getByTestId("play"));
})
});

it('should render progress bar', async () => {
await waitFor(() => screen.getByText('Which is the capital of Spain?'.toUpperCase()));
const progressBar = screen.getByTestId('prog_bar0');
await expect(progressBar).toBeInTheDocument();
});

});
Loading