diff --git a/webapp/e2e/features/customCategoryMode-form.feature b/webapp/e2e/features/customCategoryMode-form.feature deleted file mode 100644 index 76d79b6f..00000000 --- a/webapp/e2e/features/customCategoryMode-form.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: Custom Category Mode - -Scenario: The user is not registered in the site - Given An unregistered user - When I fill the data in the form and press submit - Then The user is logged - -Scenario: User play the custom category game - When I play the game - Then I should see a message with my game results diff --git a/webapp/e2e/features/dailyQuestionMode-form.feature b/webapp/e2e/features/dailyQuestionMode-form.feature index 9fe85be5..d93d60ec 100644 --- a/webapp/e2e/features/dailyQuestionMode-form.feature +++ b/webapp/e2e/features/dailyQuestionMode-form.feature @@ -9,6 +9,6 @@ Scenario: User play the daily question When I play the daily question Then I should see a message with my game results -Scenario: User wants to play the daily question but he/she/they already played it + Scenario: User wants to play the daily question but he/she/they already played it When I try to play the daily question - Then I should see a message \ No newline at end of file + Then I should see a message with a message \ No newline at end of file diff --git a/webapp/e2e/features/infinityMode-form.feature b/webapp/e2e/features/infinityMode-form.feature deleted file mode 100644 index 4b11a583..00000000 --- a/webapp/e2e/features/infinityMode-form.feature +++ /dev/null @@ -1,10 +0,0 @@ -Feature: Infinity Mode - -Scenario: The user is not registered in the site - Given An unregistered user - When I fill the data in the form and press submit - Then The user is logged - -Scenario: User play the infinity mode - When I play the infinity mode - Then I should see a message with my game results \ No newline at end of file diff --git a/webapp/e2e/steps/basicButtons-form.steps.js b/webapp/e2e/steps/basicButtons-form.steps.js index 08cd415a..45904773 100644 --- a/webapp/e2e/steps/basicButtons-form.steps.js +++ b/webapp/e2e/steps/basicButtons-form.steps.js @@ -11,10 +11,10 @@ defineFeature(feature, test => { beforeAll(async () => { browser = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 20 }); page = await browser.newPage(); //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) + setDefaultOptions({ timeout: 10000 }) await page .goto("http://localhost:3000/addUser", { @@ -82,7 +82,7 @@ defineFeature(feature, test => { }); then('I should see a list of past games played', async () => { - await expect(page).toMatchElement("#noplay-history"); + await expect(page).toMatchElement("#main-history"); }); }) @@ -186,9 +186,5 @@ defineFeature(feature, test => { await expect(page).toMatchElement("#loginButton"); }); }) - - afterAll(async ()=>{ - browser.close() - }) }); \ No newline at end of file diff --git a/webapp/e2e/steps/customCategoryMode-form.steps.js b/webapp/e2e/steps/customCategoryMode-form.steps.js deleted file mode 100644 index f11cd29c..00000000 --- a/webapp/e2e/steps/customCategoryMode-form.steps.js +++ /dev/null @@ -1,98 +0,0 @@ -const puppeteer = require('puppeteer'); -const { defineFeature, loadFeature }=require('jest-cucumber'); -const setDefaultOptions = require('expect-puppeteer').setDefaultOptions -const feature = loadFeature('./features/customCategoryMode-form.feature'); - -let page; -let browser; - -defineFeature(feature, test => { - - beforeAll(async () => { - browser = process.env.GITHUB_ACTIONS - ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080 }}); - page = await browser.newPage(); - //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) - - await page - .goto("http://localhost:3000/addUser", { - waitUntil: "networkidle0", - }) - .catch(() => {}); - - }); - - afterEach(async () => { - await page.waitForTimeout(1000); - - await page.goto("http://localhost:3000/home", { - waitUntil: "networkidle0", - }); - }); - - //test para crear el usuario - test('The user is not registered in the site', ({given,when,then}) => { - - let email; - let username; - let password; - let passwordConfirmation; - - given('An unregistered user', async () => { - email = "userTestDailyQuestionGame@email.com" - username = "userTestDailyQuestionGame" - password = "Contraseña_1?" - passwordConfirmation = "Contraseña_1?" - }); - - when('I fill the data in the form and press submit', async () => { - - await expect(page).toFill('input[name="email"]', email); - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - await expect(page).toFill('input[name="passwordConfirm"]', passwordConfirmation); - - await expect(page).toClick('#addRegister'); - - await page.goto("http://localhost:3000/login", { - waitUntil: "networkidle0", - }); - - //nos logeamos con ese usuario - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - - await expect(page).toClick('#login'); - }); - - then('The user is logged', async () => { - await expect(page).toMatchElement("#iconoUsuario"); - }); - }) - - test('User play the custom category game', ({when,then}) => { - - when('I play the game', async () => { - //como en la bd tenemos preguntas de arte vamos a elegir esa categoria - await expect(page).toClick("#button-samecat-game"); - await expect(page).toClick("#button-category-art"); - - //empieza el juego y responde 10 preguntas - for(let i = 0; i < 10; i++){ - await expect(page).toClick("#buttonAnswer0"); - } - }); - - then('I should see a message with my game results', async () => { - //comprobamos que se ha acabado el juego - await expect(page).toMatchElement(".finDelJuego"); - }); - }) - - afterAll(async ()=>{ - browser.close() - }) - -}); \ No newline at end of file diff --git a/webapp/e2e/steps/dailyQuestionMode-form.steps.js b/webapp/e2e/steps/dailyQuestionMode-form.steps.js index b504207e..d4ffeca0 100644 --- a/webapp/e2e/steps/dailyQuestionMode-form.steps.js +++ b/webapp/e2e/steps/dailyQuestionMode-form.steps.js @@ -11,10 +11,10 @@ defineFeature(feature, test => { beforeAll(async () => { browser = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 20 }); page = await browser.newPage(); //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) + setDefaultOptions({ timeout: 10000 }) await page .goto("http://localhost:3000/addUser", { @@ -75,6 +75,7 @@ defineFeature(feature, test => { test('User play the daily question', ({when,then}) => { when('I play the daily question', async () => { + //vamos a las opciones del usuario await expect(page).toClick("#button-diario-game"); //empieza el juego y respoonde la pregunta @@ -87,21 +88,18 @@ defineFeature(feature, test => { }); }) - test('User wants to play the daily question but he/she/they already played it', ({when,then}) => { when('I try to play the daily question', async () => { + //vamos a las opciones del usuario await expect(page).toClick("#button-diario-game"); - }); - then('I should see a message', async () => { - await expect(page).toMatchElement(".yaJugoDiaria"); + //pendiente de implementar }); - }) - - afterAll(async ()=>{ - browser.close() + then('I should see a message with a message', async () => { + //pendiente de implementar + }); }) }); \ No newline at end of file diff --git a/webapp/e2e/steps/gameBasicMode-form.steps.js b/webapp/e2e/steps/gameBasicMode-form.steps.js index db7a3b53..f077b68a 100644 --- a/webapp/e2e/steps/gameBasicMode-form.steps.js +++ b/webapp/e2e/steps/gameBasicMode-form.steps.js @@ -11,10 +11,10 @@ defineFeature(feature, test => { beforeAll(async () => { browser = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 20 }); page = await browser.newPage(); //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) + setDefaultOptions({ timeout: 10000 }) await page .goto("http://localhost:3000/addUser", { @@ -88,10 +88,7 @@ defineFeature(feature, test => { await expect(page).toMatchElement(".finDelJuego"); }); }) - - afterAll(async ()=>{ - browser.close() - }) + }); \ No newline at end of file diff --git a/webapp/e2e/steps/infinityMode-form.steps.js b/webapp/e2e/steps/infinityMode-form.steps.js deleted file mode 100644 index 43ad4532..00000000 --- a/webapp/e2e/steps/infinityMode-form.steps.js +++ /dev/null @@ -1,96 +0,0 @@ -const puppeteer = require('puppeteer'); -const { defineFeature, loadFeature }=require('jest-cucumber'); -const setDefaultOptions = require('expect-puppeteer').setDefaultOptions -const feature = loadFeature('./features/infinityMode-form.feature'); - -let page; -let browser; - -defineFeature(feature, test => { - - beforeAll(async () => { - browser = process.env.GITHUB_ACTIONS - ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080}}); - page = await browser.newPage(); - //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) - - await page - .goto("http://localhost:3000/addUser", { - waitUntil: "networkidle0", - }) - .catch(() => {}); - - }); - - afterEach(async () => { - await page.waitForTimeout(1000); - - await page.goto("http://localhost:3000/home", { - waitUntil: "networkidle0", - }); - }); - - //test para crear el usuario - test('The user is not registered in the site', ({given,when,then}) => { - - let email; - let username; - let password; - let passwordConfirmation; - - given('An unregistered user', async () => { - email = "userTestInfinityGame@email.com" - username = "userTestInfinityGame" - password = "Contraseña_1?" - passwordConfirmation = "Contraseña_1?" - }); - - when('I fill the data in the form and press submit', async () => { - - await expect(page).toFill('input[name="email"]', email); - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - await expect(page).toFill('input[name="passwordConfirm"]', passwordConfirmation); - - await expect(page).toClick('#addRegister'); - - await page.goto("http://localhost:3000/login", { - waitUntil: "networkidle0", - }); - - //nos logeamos con ese usuario - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - - await expect(page).toClick('#login'); - }); - - then('The user is logged', async () => { - await expect(page).toMatchElement("#iconoUsuario"); - }); - }) - - test('User play the infinity mode', ({when,then}) => { - - when('I play the infinity mode', async () => { - await expect(page).toClick("#button-infinite-game"); - - while (!(await page.$('.finDelJuego'))) { - await expect(page).toClick("#buttonAnswer0"); - } - }); - - then('I should see a message with my game results', async () => { - //comprobamos que se ha acabado el juego - await expect(page).toMatchElement(".finDelJuego"); - }); - }) - - - afterAll(async ()=>{ - browser.close() - }) - -}); \ No newline at end of file diff --git a/webapp/e2e/steps/login-form.steps.js b/webapp/e2e/steps/login-form.steps.js index 3b78a85f..5a800402 100644 --- a/webapp/e2e/steps/login-form.steps.js +++ b/webapp/e2e/steps/login-form.steps.js @@ -11,10 +11,10 @@ defineFeature(feature, test => { beforeAll(async () => { browser = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0 , defaultViewport: { width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 50 }); page = await browser.newPage(); //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) + setDefaultOptions({ timeout: 10000 }) await page .goto("http://localhost:3000/login", { diff --git a/webapp/e2e/steps/multiplayerMode-form.steps.js b/webapp/e2e/steps/multiplayerMode-form.steps.js index b6e2600a..cf0cfc69 100644 --- a/webapp/e2e/steps/multiplayerMode-form.steps.js +++ b/webapp/e2e/steps/multiplayerMode-form.steps.js @@ -13,15 +13,17 @@ defineFeature(feature, test => { beforeAll(async () => { browserHost = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 20 }); pageHost = await browserHost.newPage(); //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) + setDefaultOptions({ timeout: 10000 }) browserUser = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0 , defaultViewport: { width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 20 }); pageUser = await browserUser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }) await pageHost .goto("http://localhost:3000/addUser", { diff --git a/webapp/e2e/steps/register-form.steps.js b/webapp/e2e/steps/register-form.steps.js index fc2a49ed..822d142f 100644 --- a/webapp/e2e/steps/register-form.steps.js +++ b/webapp/e2e/steps/register-form.steps.js @@ -11,10 +11,10 @@ defineFeature(feature, test => { beforeAll(async () => { browser = process.env.GITHUB_ACTIONS ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 0 , defaultViewport: {width: 1920, height: 1080 }}); + : await puppeteer.launch({ headless: false, slowMo: 20 }); page = await browser.newPage(); //Way of setting up the timeout - setDefaultOptions({ timeout: 30000 }) + setDefaultOptions({ timeout: 10000 }) await page .goto("http://localhost:3000/login", { @@ -207,6 +207,7 @@ defineFeature(feature, test => { }); }) + afterAll(async ()=>{ browser.close() }) diff --git a/webapp/e2e/testQuestions.js b/webapp/e2e/testQuestions.js index bb747ff5..39a232aa 100644 --- a/webapp/e2e/testQuestions.js +++ b/webapp/e2e/testQuestions.js @@ -15,7 +15,7 @@ async function insertTestData() { const categoryCollection = database.collection('categorias'); const answersCollection = database.collection('respuestas'); const typesCollection = database.collection('tipos'); - + // insertamos las categorias await categoryCollection.insertMany([ { @@ -95,7 +95,8 @@ async function insertTestData() { testQuestions[0].diaria = formattedDate; // insertamos las preguntas - await questionsCollection.insertMany(testQuestions); + await questionsCollection.insertMany(testQuestions); + } finally { await client.close(); // Cerrar la conexión con la base de datos