Skip to content

Commit

Permalink
Merge pull request #432 from Arquisoft/dev
Browse files Browse the repository at this point in the history
Actualizacion
  • Loading branch information
uo285427 authored May 1, 2024
2 parents 1b02739 + 0746157 commit d74db27
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 155 deletions.
11 changes: 0 additions & 11 deletions webapp/e2e/features/settings.feature

This file was deleted.

18 changes: 12 additions & 6 deletions webapp/e2e/steps/login-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let page;
let browser;

defineFeature(feature, test => {

const username = "testUserLogin"
const password = "testUserLogin"
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
Expand All @@ -21,6 +22,10 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
})
.catch(() => {});
await expect(page).toClick("button", { text: "¿No tienes cuenta? Registrate aqui." });
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Añadir usuario' })
});

test('An user logs in with valid credentials', ({given,when,then}) => {
Expand All @@ -29,18 +34,19 @@ defineFeature(feature, test => {
let password;

given('An user is in the login page', async () => {
username = "jesus"
password = "jesus"
username = "testUserLogin"
password = "testUserLogin"
});

when('I fill the data in the form and press submit', async () => {
await expect(page).toFill('input[label="Username"]', username);
await expect(page).toFill('input[label="Password"]', password);
await expect(page).toClick("button", { text: "¿Ya tienes cuenta? Inicia sesión aqui." });
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Iniciar sesión' })
});

then('The user should be redirected to the home page', async () => {
await expect(getByText('Hola jesus!')).toBeInTheDocument();
await expect(page).toMatchElement("h1", { text: `Hola ${username}!` });
});
})

Expand Down
57 changes: 30 additions & 27 deletions webapp/e2e/steps/play-game.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 1 });
: await puppeteer.launch({ headless: false, slowMo: 1, defaultViewport: { width: 1200, height: 800 }});
page = await browser.newPage();
setDefaultOptions({ timeout: 10000 })

Expand All @@ -25,8 +25,10 @@ defineFeature(feature, test => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Añadir usuario' })
await page.waitForNavigation();
});
await expect(page).toClick("button", { text: "¿Ya tienes cuenta? Inicia sesión aqui." });
}, 60000);


beforeEach(async()=>{
await page
.goto("http://localhost:3000", {
Expand All @@ -42,23 +44,23 @@ defineFeature(feature, test => {
});
test('Starts a new game', ({given,when,then}) => {
given('A logged user in play view', async () => {
await expect(getByText('Hola '+ username +'!')).toBeInTheDocument();
await expect(page).toMatchElement("h1", { text: `Hola ${username}!` });
});

when('I press "COMENZAR A JUGAR"', async () => {
await expect(page).toClick('button', { text: 'COMENZAR A JUGAR' })
await expect(page).toClick('button', { text: 'Comenzar a jugar' })
});
then('A new game starts', async () => {
await page.waitForTimeout(3000);
await expect(getByText('Pregunta Número 1')).toBeInTheDocument();
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 1' });
});
});


/*
test('Results are shown', ({given,when,then}) => {
let buttonColor;
given('A logged user in a game', async () => {
await expect(page).toClick('button', { text: 'COMENZAR A JUGAR' })
await expect(page).toClick('button', { text: 'Comenzar a jugar' })
});
when('I choose an option', async () => {
buttonColor = await page.waitForSelector('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root').backgroundColor;
Expand All @@ -70,50 +72,51 @@ defineFeature(feature, test => {
expect(changedButton).toBe(true);
});
});


*/
/*
test('Shows the next questions',({given,when,then})=>{
let text;
given('A logged user in a game',async()=>{
await expect(page).toClick('button', { text: 'COMENZAR A JUGAR' })
await expect(page).toClick('button', { text: 'Comenzar a jugar' })
});
when('I choose an option',async()=>{
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
});
then('New Question appears',async()=>{
await expect(getByText('Pregunta Número 2')).toBeInTheDocument();
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 2' });
});
});

*/
/*
test('Finish the game',({given,when,then})=>{
given('A logged user in a game',async()=>{
await expect(page).toClick('button', { text: 'COMENZAR A JUGAR' })
await expect(page).toClick('button', { text: 'Comenzar a jugar' })
});
when('I play while the game is finished',async()=>{
await expect(getByText('Pregunta Número 1')).toBeInTheDocument();
when('I play until the game ends',async()=>{
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 1' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 2')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 2' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 3')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 3' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 4')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 4' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 5')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 5' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 6')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 6' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 7')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 7' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 8')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 8' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 9')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 9' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
await waitFor(() => expect(getByText('Pregunta Número 10')).toBeInTheDocument());
await expect(page).toMatchElement("h1", { text: 'Pregunta Número 10' });
await expect(page).toClick('.MuiGrid-root:nth-child(1) > .MuiButtonBase-root')
});
then('The game is finished',async()=>{
await expect(getByText('¡Gracias por jugar!')).toBeInTheDocument();
await expect(page).toMatchElement("h6", { text: '¡Gracias por jugar!' });
});
})
*/
});
2 changes: 1 addition & 1 deletion webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
})
.catch(() => {});
});
}, 60000);

test('The user is not registered in the site', ({given,when,then}) => {

Expand Down
109 changes: 0 additions & 109 deletions webapp/e2e/steps/settings.steps.js

This file was deleted.

3 changes: 3 additions & 0 deletions webapp/e2e/test-environment-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { MongoMemoryServer } = require('mongodb-memory-server');
const testQuestions = require('./testQuestions.js');


let mongoserver;
Expand All @@ -23,6 +24,8 @@ async function startServer() {
rankingservice = await require("../../users/rankingservice/ranking-service");
generatedquestservice = await require("../../questions/generatedquestservice/generatedquest-service");
questiongeneratorservice = await require("../../questions/questiongeneratorservice/questiongenerator-service");

testQuestions.insertTestData();
}

startServer();
Loading

0 comments on commit d74db27

Please sign in to comment.