Skip to content

Commit

Permalink
Merge pull request #49 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Aumento de tiempo y arreglo
  • Loading branch information
Verzidee authored Apr 7, 2024
2 parents 77d9907 + 994cc40 commit 9c5a867
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions users/historyservice/history-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ app.get('/gethistory', async (req, res) => {
let username = req.query.username;

// Buscar el historial en la base de datos basado en el nombre de usuario
let historyEntry = await History.findOne({ username: username });
let historyEntry = await History.findOne({ username: username.toString() });

if (historyEntry === null) {

Expand Down Expand Up @@ -90,7 +90,7 @@ app.get('/gethistory/:username', async (req, res) => {


// Buscar el historial en la base de datos basado en el nombre de usuario
let historyEntry = await History.findOne({ username:username });
let historyEntry = await History.findOne({ username: username.toString() });

if (historyEntry === null) {
res.status(404).json({ error: 'No se encontro historial para este usuario'});
Expand Down
18 changes: 9 additions & 9 deletions webapp/e2e/steps/history.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let browser;

defineFeature(feature, test => {

let username = "usuario12"
let username = "usuario30"
let password = "contraseña"

beforeAll(async () => {
Expand All @@ -34,7 +34,7 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
}).catch(() => {});

}, 60000);
}, 600000);

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

Expand All @@ -56,20 +56,20 @@ defineFeature(feature, test => {
test('The user is loged in the site so he can see history', ({given,when,then}) => {

given('A registered user, i fill the login', async () => {
await page.goto("http://localhost:3000/login", {
waitUntil: "networkidle0",
}).catch(() => {});
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="entrarPage"]');
//await page.waitForTimeout(1500);

await page.goto("http://localhost:3000/", {
waitUntil: "networkidle0",
}).catch(() => {});
});

when('I press history', async () => {
// Espera a que el enlace <a> con el texto "Historial" esté presente y sea clickeable
await page.waitForSelector('a', { text: 'Historial' });

await expect(page).toClick('a', { text: 'Historial' });
await page.goto("http://localhost:3000/historial", {
waitUntil: "networkidle0",
}).catch(() => {});
});

then('I see my history', async () => {
Expand Down
22 changes: 11 additions & 11 deletions webapp/e2e/steps/jugar-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let page;
let browser;

defineFeature(feature, (test) => {
let username = "usuario13"
let username = "usuario31"
let password = "contraseña"

beforeAll(async () => {
Expand All @@ -30,31 +30,31 @@ defineFeature(feature, (test) => {
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="registrarsePage"]');

await page.waitForTimeout(1500);
}, 60000);
}, 600000);

test('User Initiates a Game', ({ given, when, then }) => {

given('a registered user exists', async () => {
await expect(page).toClick('button',{text: "Entrar"});
await page.goto("http://localhost:3000/login", {
waitUntil: "networkidle0",
}).catch(() => {});
});

when('the user enters their details on the login form and submits', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="entrarPage"]');
//await page.waitForTimeout(1500);
await page.goto("http://localhost:3000/", {
waitUntil: "networkidle0",
}).catch(() => {});
});

when('the user clicks the "Play" button on the homepage', async () => {


// Espera a que el botón con el texto "JUGAR" esté presente y sea clickeable
await page.waitForSelector('button', { text: 'JUGAR' })

//NO LO ENCUENTRA
await expect(page).toClick('button', { text: 'JUGAR' })
await page.waitForTimeout(1500);
await page.goto("http://localhost:3000/jugar", {
waitUntil: "networkidle0",
}).catch(() => {});
});

then('the questions should be displayed', async () => {
Expand Down
18 changes: 11 additions & 7 deletions webapp/e2e/steps/login-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let browser;

defineFeature(feature, test => {

let username = "usuario11"
let username = "usuario29"
let password = "contraseña"

beforeAll(async () => {
Expand All @@ -32,9 +32,12 @@ defineFeature(feature, test => {
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="registrarsePage"]');

await page.waitForTimeout(1500);
await page.goto("http://localhost:3000/login", {
waitUntil: "networkidle0",
}).catch(() => {});


}, 60000);
}, 600000);

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

Expand All @@ -45,14 +48,15 @@ defineFeature(feature, test => {

when('Presses submit', async () => {
await expect(page).toClick('button[name="entrarPage"]');
//await page.waitForTimeout(1500);

await page.goto("http://localhost:3000/", {
waitUntil: "networkidle0",
}).catch(() => {});
});


then('The user is redirected', async () => {
// Espera a que el elemento <p> con el texto deseado esté presente en la página
await page.waitForSelector('p', { text: '¿A que estás esperando?' });

//No lo encuentra
await expect(page).toMatchElement("p", { text: "¿A que estás esperando?" });
});
})
Expand Down
6 changes: 3 additions & 3 deletions webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ defineFeature(feature, test => {
await page.goto("http://localhost:3000/login", {
waitUntil: "networkidle0",
}).catch(() => {});
}, 60000);
}, 600000);

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

let username;
let password;

given('An unregistered user', async () => {
username = "ProbandoV12"
username = "ProbandoV18"
password = "pabloasw"
await expect(page).toClick("a", { text: "¿No tienes una cuenta? Registrate aquí." });
});
Expand All @@ -41,7 +41,7 @@ defineFeature(feature, test => {
});

then('A confirmation message should be shown in the screen', async () => {
await expect(page).toMatchElement("div", { text: "Usuario añadido correctamente" });
await expect(page).toMatchElement('button[name="entrarPage"]');
});
})

Expand Down

0 comments on commit 9c5a867

Please sign in to comment.