From 5dbed1ebc40d71fd3b15602ec4d29cf8bc7dc49f Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 12:59:30 +0200 Subject: [PATCH 01/47] =?UTF-8?q?A=C3=B1adida=20validacion=20de=20gamemode?= =?UTF-8?q?=20al=20guardar=20partida?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/userservice/user-service.js | 14 +++++++++----- users/userservice/user-service.test.js | 25 +++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 35c97942..eae3ca76 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -250,7 +250,7 @@ app.get("/userGames", async (req, res) => { username, }); if (!user) { - return res.status(404).json({ error: "Usuario no encontrado" }); + return res.status(404).json({ error: "User not found" }); } res.status(200).json(user.games); } catch (error) { @@ -268,17 +268,21 @@ app.post("/saveGameList", async (req, res) => { let user = await User.findOne({ username: username }); if (!user) { - return res.status(404).json({ error: "Usuario no encontrado" }); + return res.status(404).json({ error: "User not found" }); } const gameDataWithGamemode = { ...gameData, gamemode, questions }; - console.log(gameDataWithGamemode); + + if(gamemode!=="classic" && gamemode!=="bateria" && gamemode!=="calculadora"){ + return res.status(422).json({ error: "Invalid gamemode" }); + } + user.games.push(gameDataWithGamemode); await user.save(); - res.status(200).json({ message: "Partida guardada exitosamente" }); + res.status(200).json({ message: "Game saved successfully" }); } catch (error) { - res.status(400).json({ error: "Error al guardar partida en la lista: " + error.message }); + res.status(400).json({ error: "Error while saving game on users list: " + error.message }); } }); diff --git a/users/userservice/user-service.test.js b/users/userservice/user-service.test.js index f9bfa7ef..9b993b09 100644 --- a/users/userservice/user-service.test.js +++ b/users/userservice/user-service.test.js @@ -108,7 +108,7 @@ describe("User Service", () => { // Verificar la respuesta expect(response.status).toBe(200); - expect(response.body).toEqual({ message: "Partida guardada exitosamente" }); + expect(response.body).toEqual({ message: "Game saved successfully" }); }); it("should send error POST /saveGameList", async () => { @@ -129,7 +129,28 @@ describe("User Service", () => { // Verificar la respuesta expect(response.status).toBe(404); - expect(response.body).toEqual({ error: "Usuario no encontrado" }); + expect(response.body).toEqual({ error: "User not found" }); + }); + + it("should send error POST /saveGameList for invalid gamemode", async () => { + // Datos de la partida a guardar + const gameData = { + username: "testuser", + gameMode: "a", + gameData: { + points: 100, + correctAnswers: 8, + incorrectAnswers: 2, + avgTime: 30, + }, + }; + + // Realizar la solicitud POST /saveGameList + const response = await request(app).post("/saveGameList").send(gameData); + + // Verificar la respuesta + expect(response.status).toBe(422); + expect(response.body).toEqual({ error: "Invalid gamemode" }); }); it("should add friend on POST /users/add-friend", async () => { From 8ae83f2d5064fe80dece180e28319a57e309263c Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 23:07:39 +0200 Subject: [PATCH 02/47] =?UTF-8?q?A=C3=B1adido=20test=20e2e=20de=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/features/login-form.feature | 6 +++ webapp/e2e/features/register-form.feature | 2 +- webapp/e2e/steps/login-form.steps.js | 57 +++++++++++++++++++++++ webapp/e2e/steps/register-form.steps.js | 4 +- 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 webapp/e2e/features/login-form.feature create mode 100644 webapp/e2e/steps/login-form.steps.js diff --git a/webapp/e2e/features/login-form.feature b/webapp/e2e/features/login-form.feature new file mode 100644 index 00000000..19152cc4 --- /dev/null +++ b/webapp/e2e/features/login-form.feature @@ -0,0 +1,6 @@ +Feature: Login a registered user + +Scenario: The user is registered in the site + Given A registered user + When I fill the data in the form and press submit + Then The home screen should be shown \ No newline at end of file diff --git a/webapp/e2e/features/register-form.feature b/webapp/e2e/features/register-form.feature index aad790a5..545cb989 100644 --- a/webapp/e2e/features/register-form.feature +++ b/webapp/e2e/features/register-form.feature @@ -3,4 +3,4 @@ Feature: Registering a new user 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 A confirmation message should be shown in the screen \ No newline at end of file + Then The home screen should be shown \ No newline at end of file diff --git a/webapp/e2e/steps/login-form.steps.js b/webapp/e2e/steps/login-form.steps.js new file mode 100644 index 00000000..8f681948 --- /dev/null +++ b/webapp/e2e/steps/login-form.steps.js @@ -0,0 +1,57 @@ +const puppeteer = require("puppeteer"); +const { defineFeature, loadFeature } = require("jest-cucumber"); +const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; +const { expect } = require("expect-puppeteer"); +const feature = loadFeature("./features/register-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: 100 }); + page = await browser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }); + + await page + .goto("http://localhost:3000", { + waitUntil: "networkidle0", + }) + .catch(() => {}); + }); + + test("The user is registered in the site", ({ given, when, then }) => { + let username; + let password; + + given("A registered user", async () => { + username = "pablo"; + password = "pabloasw"; + await expect(page).toClick("a", { text: "Regístrate" }); + }); + + when("I fill the data in the form and press submit", async () => { + username = "testuser"; + password = "Testpassword1"; + await page.waitForSelector('#login-username'); + await page.type('#login-username', username); + await page.waitForSelector('#register-password'); + await page.type('#register-password', password); + await page.click("button", { text: "Login" }); + }); + + then("The home screen should be shown", async () => { + await page.waitForTimeout(1000); + const url = page.url(); + expect(url).toContain("/home"); + browser.close(); + }); + }); + + afterAll(async () => { + browser.close(); + }); +}); diff --git a/webapp/e2e/steps/register-form.steps.js b/webapp/e2e/steps/register-form.steps.js index 04c92ecb..6a2435cf 100644 --- a/webapp/e2e/steps/register-form.steps.js +++ b/webapp/e2e/steps/register-form.steps.js @@ -35,7 +35,7 @@ defineFeature(feature, (test) => { when("I fill the data in the form and press submit", async () => { username = "testuser"; - password = "testpassword"; + password = "Testpassword1"; await page.waitForSelector('#register-username'); await page.type('#register-username', username); await page.waitForSelector('#register-password'); @@ -45,7 +45,7 @@ defineFeature(feature, (test) => { await page.click("button", { text: "Registrarse" }); }); - then("A confirmation message should be shown in the screen", async () => { + then("The home screen should be shown", async () => { await page.waitForTimeout(1000); const url = page.url(); expect(url).toContain("/home"); From 08844843dca24c7ce6e91b79d0f08745b25d74a3 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 23:17:32 +0200 Subject: [PATCH 03/47] =?UTF-8?q?A=C3=B1adido=20test=20e2e=20de=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/features/profile.feature | 6 +++ webapp/e2e/steps/login-form.steps.js | 31 ++++++++------- webapp/e2e/steps/profile.steps.js | 57 ++++++++++++++++++++++++++++ webapp/e2e/test-environment-setup.js | 1 + 4 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 webapp/e2e/features/profile.feature create mode 100644 webapp/e2e/steps/profile.steps.js diff --git a/webapp/e2e/features/profile.feature b/webapp/e2e/features/profile.feature new file mode 100644 index 00000000..17562d96 --- /dev/null +++ b/webapp/e2e/features/profile.feature @@ -0,0 +1,6 @@ +Feature: Seeing logged user's profile + +Scenario: The user is logged in and can view their profile + Given A logged-in user + When I press the Profile link + Then The user's profile shoud be shown on screen \ 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 8f681948..69502dc1 100644 --- a/webapp/e2e/steps/login-form.steps.js +++ b/webapp/e2e/steps/login-form.steps.js @@ -27,27 +27,26 @@ defineFeature(feature, (test) => { let username; let password; - given("A registered user", async () => { - username = "pablo"; - password = "pabloasw"; - await expect(page).toClick("a", { text: "Regístrate" }); + given("A logged-in user", async () => { + await page.waitForSelector("#login-username"); + await page.type("#login-username", "testuser"); + await page.waitForSelector("#register-password"); + await page.type("#register-password", "Testpassword1"); + await page.click("button", { text: "Login" }); + await page.waitForNavigation({ waitUntil: "networkidle0" }); }); - when("I fill the data in the form and press submit", async () => { - username = "testuser"; - password = "Testpassword1"; - await page.waitForSelector('#login-username'); - await page.type('#login-username', username); - await page.waitForSelector('#register-password'); - await page.type('#register-password', password); - await page.click("button", { text: "Login" }); + when("The user clicks on their profile", async () => { + await page.waitForSelector('[data-testid="profile-menu"]'); + await page.click('[data-testid="profile-menu"]'); + await page.waitForSelector('[data-testid="profile-link"]'); + await page.click('[data-testid="profile-link"]'); + await page.waitForNavigation({ waitUntil: "networkidle0" }); }); - then("The home screen should be shown", async () => { - await page.waitForTimeout(1000); + then("The user's profile page should be displayed", async () => { const url = page.url(); - expect(url).toContain("/home"); - browser.close(); + expect(url).toContain("/perfil/testuser"); }); }); diff --git a/webapp/e2e/steps/profile.steps.js b/webapp/e2e/steps/profile.steps.js new file mode 100644 index 00000000..706aba85 --- /dev/null +++ b/webapp/e2e/steps/profile.steps.js @@ -0,0 +1,57 @@ +const puppeteer = require("puppeteer"); +const { defineFeature, loadFeature } = require("jest-cucumber"); +const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; +const { expect } = require("expect-puppeteer"); +const feature = loadFeature("./features/register-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: 100 }); + page = await browser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }); + + await page + .goto("http://localhost:3000", { + waitUntil: "networkidle0", + }) + .catch(() => {}); + }); + + test("The user is logged in and can view their profile", ({ given, when, then }) => { + let username; + let password; + + given("A registered user", async () => { + username = "pablo"; + password = "pabloasw"; + await expect(page).toClick("a", { text: "Regístrate" }); + }); + + when("I press the Profile link", async () => { + username = "testuser"; + password = "Testpassword1"; + await page.waitForSelector('#login-username'); + await page.type('#login-username', username); + await page.waitForSelector('#register-password'); + await page.type('#register-password', password); + await page.click("button", { text: "Login" }); + }); + + then("The user's profile shoud be shown on screen", async () => { + await page.waitForTimeout(1000); + const url = page.url(); + expect(url).toContain("/home"); + browser.close(); + }); + }); + + afterAll(async () => { + browser.close(); + }); +}); \ No newline at end of file diff --git a/webapp/e2e/test-environment-setup.js b/webapp/e2e/test-environment-setup.js index 4120d25c..c17b5fd5 100644 --- a/webapp/e2e/test-environment-setup.js +++ b/webapp/e2e/test-environment-setup.js @@ -5,6 +5,7 @@ let mongoserver; let userservice; let authservice; let gatewayservice; +let statsservice; async function startServer() { console.log('Starting MongoDB memory server...'); From 14ea51241ed8fcb6dd498c0e858bb9a3d98086cd Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 23:28:46 +0200 Subject: [PATCH 04/47] =?UTF-8?q?Corregidos=20errores=20y=20a=C3=B1adido?= =?UTF-8?q?=20test=20e2e=20de=20Sobre=20nosotros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/features/aboutus.feature | 6 +++ webapp/e2e/features/profile.feature | 4 +- webapp/e2e/steps/aboutus.steps.js | 56 ++++++++++++++++++++++++++++ webapp/e2e/steps/login-form.steps.js | 30 +++++++-------- webapp/e2e/steps/profile.steps.js | 35 ++++++++--------- 5 files changed, 96 insertions(+), 35 deletions(-) create mode 100644 webapp/e2e/features/aboutus.feature create mode 100644 webapp/e2e/steps/aboutus.steps.js diff --git a/webapp/e2e/features/aboutus.feature b/webapp/e2e/features/aboutus.feature new file mode 100644 index 00000000..090d0a01 --- /dev/null +++ b/webapp/e2e/features/aboutus.feature @@ -0,0 +1,6 @@ +Feature: Seeing logged user's profile + +Scenario: The user can view the about us page + Given A logged-in user + When I click on the About Us link + Then The About Us page should be shown on screen \ No newline at end of file diff --git a/webapp/e2e/features/profile.feature b/webapp/e2e/features/profile.feature index 17562d96..8edc5b87 100644 --- a/webapp/e2e/features/profile.feature +++ b/webapp/e2e/features/profile.feature @@ -1,6 +1,6 @@ Feature: Seeing logged user's profile -Scenario: The user is logged in and can view their profile +Scenario: The user can see his Profile page Given A logged-in user - When I press the Profile link + When I click on the Profile link Then The user's profile shoud be shown on screen \ No newline at end of file diff --git a/webapp/e2e/steps/aboutus.steps.js b/webapp/e2e/steps/aboutus.steps.js new file mode 100644 index 00000000..69ad46d6 --- /dev/null +++ b/webapp/e2e/steps/aboutus.steps.js @@ -0,0 +1,56 @@ +const puppeteer = require("puppeteer"); +const { defineFeature, loadFeature } = require("jest-cucumber"); +const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; +const { expect } = require("expect-puppeteer"); +const feature = loadFeature("./features/register-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: 100 }); + page = await browser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }); + + await page + .goto("http://localhost:3000", { + waitUntil: "networkidle0", + }) + .catch(() => {}); + }); + + test("User can view the about us page", ({ given, when, then }) => { + let username; + let password; + + given("A logged-in user", async () => { + username = "testuser"; + password = "Testuser1"; + await page.waitForSelector("#login-username"); + await page.type("#login-username", username); + await page.waitForSelector("#login-password"); + await page.type("#login-password", password); + await page.click("button", { text: "Login" }); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + when("I click on the About Us link", async () => { + await page.waitForSelector('[data-testid="about-us-link"]'); + await page.click('[data-testid="about-us-link"]'); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + then("The About Us page should be shown on screen", async () => { + const url = page.url(); + expect(url).toContain("/sobre"); + }); + }); + + 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 69502dc1..7a958605 100644 --- a/webapp/e2e/steps/login-form.steps.js +++ b/webapp/e2e/steps/login-form.steps.js @@ -27,30 +27,28 @@ defineFeature(feature, (test) => { let username; let password; - given("A logged-in user", async () => { - await page.waitForSelector("#login-username"); - await page.type("#login-username", "testuser"); - await page.waitForSelector("#register-password"); - await page.type("#register-password", "Testpassword1"); - await page.click("button", { text: "Login" }); - await page.waitForNavigation({ waitUntil: "networkidle0" }); + given("A registered user", async () => { + username = "testuser"; + password = "Testpassword1"; }); - when("The user clicks on their profile", async () => { - await page.waitForSelector('[data-testid="profile-menu"]'); - await page.click('[data-testid="profile-menu"]'); - await page.waitForSelector('[data-testid="profile-link"]'); - await page.click('[data-testid="profile-link"]'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); + when("I fill the data in the form and press submit", async () => { + await page.waitForSelector('#login-username'); + await page.type('#login-username', username); + await page.waitForSelector('#login-password'); + await page.type('#login-password', password); + await page.click("button", { text: "Login" }); }); - then("The user's profile page should be displayed", async () => { + then("The home screen should be shown", async () => { + await page.waitForTimeout(1000); const url = page.url(); - expect(url).toContain("/perfil/testuser"); + expect(url).toContain("/home"); + browser.close(); }); }); afterAll(async () => { browser.close(); }); -}); +}); \ No newline at end of file diff --git a/webapp/e2e/steps/profile.steps.js b/webapp/e2e/steps/profile.steps.js index 706aba85..5966f726 100644 --- a/webapp/e2e/steps/profile.steps.js +++ b/webapp/e2e/steps/profile.steps.js @@ -23,35 +23,36 @@ defineFeature(feature, (test) => { .catch(() => {}); }); - test("The user is logged in and can view their profile", ({ given, when, then }) => { + test("The user can see his Profile page", ({ given, when, then }) => { let username; let password; - given("A registered user", async () => { - username = "pablo"; - password = "pabloasw"; - await expect(page).toClick("a", { text: "Regístrate" }); + given("A logged-in user", async () => { + username="testuser"; + password="Testpassword1"; + await page.waitForSelector("#login-username"); + await page.type("#login-username", username); + await page.waitForSelector("#login-password"); + await page.type("#login-password", password); + await page.click("button", { text: "Login" }); + await page.waitForNavigation({ waitUntil: "networkidle0" }); }); - when("I press the Profile link", async () => { - username = "testuser"; - password = "Testpassword1"; - await page.waitForSelector('#login-username'); - await page.type('#login-username', username); - await page.waitForSelector('#register-password'); - await page.type('#register-password', password); - await page.click("button", { text: "Login" }); + when("I click on the Profile link", async () => { + await page.waitForSelector('[data-testid="profile-menu"]'); + await page.click('[data-testid="profile-menu"]'); + await page.waitForSelector('[data-testid="profile-link"]'); + await page.click('[data-testid="profile-link"]'); + await page.waitForNavigation({ waitUntil: "networkidle0" }); }); then("The user's profile shoud be shown on screen", async () => { - await page.waitForTimeout(1000); const url = page.url(); - expect(url).toContain("/home"); - browser.close(); + expect(url).toContain("/perfil/testuser"); }); }); afterAll(async () => { browser.close(); }); -}); \ No newline at end of file +}); From 4cb91028208880457f0561c414f4fa4f87fdc789 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 23:37:52 +0200 Subject: [PATCH 05/47] =?UTF-8?q?A=C3=B1adido=20test=20e2e=20de=20logout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/features/logout.feature | 6 ++++ webapp/e2e/steps/aboutus.steps.js | 2 +- webapp/e2e/steps/logout.steps.js | 58 ++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 webapp/e2e/features/logout.feature create mode 100644 webapp/e2e/steps/logout.steps.js diff --git a/webapp/e2e/features/logout.feature b/webapp/e2e/features/logout.feature new file mode 100644 index 00000000..59fe36a9 --- /dev/null +++ b/webapp/e2e/features/logout.feature @@ -0,0 +1,6 @@ +Feature: Logging out + +Scenario: The user can logout + Given A logged-in user + When I click on the Logout link + Then The user should be logged out and the Login screen should be shown \ No newline at end of file diff --git a/webapp/e2e/steps/aboutus.steps.js b/webapp/e2e/steps/aboutus.steps.js index 69ad46d6..3d4939f2 100644 --- a/webapp/e2e/steps/aboutus.steps.js +++ b/webapp/e2e/steps/aboutus.steps.js @@ -29,7 +29,7 @@ defineFeature(feature, (test) => { given("A logged-in user", async () => { username = "testuser"; - password = "Testuser1"; + password = "Testpassword1"; await page.waitForSelector("#login-username"); await page.type("#login-username", username); await page.waitForSelector("#login-password"); diff --git a/webapp/e2e/steps/logout.steps.js b/webapp/e2e/steps/logout.steps.js new file mode 100644 index 00000000..4f1710e0 --- /dev/null +++ b/webapp/e2e/steps/logout.steps.js @@ -0,0 +1,58 @@ +const puppeteer = require("puppeteer"); +const { defineFeature, loadFeature } = require("jest-cucumber"); +const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; +const { expect } = require("expect-puppeteer"); +const feature = loadFeature("./features/register-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: 100 }); + page = await browser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }); + + await page + .goto("http://localhost:3000", { + waitUntil: "networkidle0", + }) + .catch(() => {}); + }); + + let username; + let password; + + test("The user can logout", ({ given, when, then }) => { + given("A logged-in user", async () => { + username = "testuser"; + password = "Testpassword1"; + await page.waitForSelector("#login-username"); + await page.type("#login-username", username); + await page.waitForSelector("#register-password"); + await page.type("#register-password", password); + await page.click("button", { text: "Login" }); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + when("I click on the Logout link", async () => { + await page.waitForSelector('[data-testid="profile-menu"]'); + await page.click('[data-testid="profile-menu"]'); + await page.waitForSelector('[data-testid="logout-link"]'); + await page.click('[data-testid="logout-link"]'); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + then("The user should be logged out", async () => { + const url = page.url(); + expect(url).toContain("/login"); + }); + }); + + afterAll(async () => { + browser.close(); + }); +}); From 7949ab4f1df4877ab776703d22e6d1798ec67fbf Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 23:42:44 +0200 Subject: [PATCH 06/47] =?UTF-8?q?A=C3=B1adido=20test=20e2e=20para=20Config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/features/aboutus.feature | 2 +- webapp/e2e/features/config.feature | 6 +++ webapp/e2e/steps/aboutus.steps.js | 2 +- webapp/e2e/steps/config.steps.js | 58 +++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 webapp/e2e/features/config.feature create mode 100644 webapp/e2e/steps/config.steps.js diff --git a/webapp/e2e/features/aboutus.feature b/webapp/e2e/features/aboutus.feature index 090d0a01..a5feb075 100644 --- a/webapp/e2e/features/aboutus.feature +++ b/webapp/e2e/features/aboutus.feature @@ -1,6 +1,6 @@ Feature: Seeing logged user's profile -Scenario: The user can view the about us page +Scenario: The user can view the About Us page Given A logged-in user When I click on the About Us link Then The About Us page should be shown on screen \ No newline at end of file diff --git a/webapp/e2e/features/config.feature b/webapp/e2e/features/config.feature new file mode 100644 index 00000000..cabd0110 --- /dev/null +++ b/webapp/e2e/features/config.feature @@ -0,0 +1,6 @@ +Feature: Seeing logged user's profile + +Scenario: The user can view the Configuration page + Given A logged-in user + When I click on the Configuration link + Then The Configuration page should be shown on screen \ No newline at end of file diff --git a/webapp/e2e/steps/aboutus.steps.js b/webapp/e2e/steps/aboutus.steps.js index 3d4939f2..ef4ef571 100644 --- a/webapp/e2e/steps/aboutus.steps.js +++ b/webapp/e2e/steps/aboutus.steps.js @@ -23,7 +23,7 @@ defineFeature(feature, (test) => { .catch(() => {}); }); - test("User can view the about us page", ({ given, when, then }) => { + test("The user can view the About Us page", ({ given, when, then }) => { let username; let password; diff --git a/webapp/e2e/steps/config.steps.js b/webapp/e2e/steps/config.steps.js new file mode 100644 index 00000000..cfa2f335 --- /dev/null +++ b/webapp/e2e/steps/config.steps.js @@ -0,0 +1,58 @@ +const puppeteer = require("puppeteer"); +const { defineFeature, loadFeature } = require("jest-cucumber"); +const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; +const { expect } = require("expect-puppeteer"); +const feature = loadFeature("./features/register-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: 100 }); + page = await browser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }); + + await page + .goto("http://localhost:3000", { + waitUntil: "networkidle0", + }) + .catch(() => {}); + }); + + test("The user can view the Configuration page", ({ given, when, then }) => { + let username; + let password; + + given("A logged-in user", async () => { + username = "testuser"; + password = "Testpassword1"; + await page.waitForSelector("#login-username"); + await page.type("#login-username", username); + await page.waitForSelector("#login-password"); + await page.type("#login-password", password); + await page.click("button", { text: "Login" }); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + when("I click on the Configuration link", async () => { + await page.waitForSelector('[data-testid="profile-menu"]'); + await page.click('[data-testid="profile-menu"]'); + await page.waitForSelector('[data-testid="config-link"]'); + await page.click('[data-testid="config-link"]'); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + then("The Configuration page should be shown on screen", async () => { + const url = page.url(); + expect(url).toContain("/config"); + }); + }); + + afterAll(async () => { + browser.close(); + }); +}); \ No newline at end of file From 7d1d5d6c02b9bb573c0c06e298b5c4dbe8289bf7 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Mon, 22 Apr 2024 23:44:20 +0200 Subject: [PATCH 07/47] =?UTF-8?q?A=C3=B1adido=20test=20e2e=20para=20Histor?= =?UTF-8?q?y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/features/history.feature | 6 +++ webapp/e2e/steps/history.steps.js | 58 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 webapp/e2e/features/history.feature create mode 100644 webapp/e2e/steps/history.steps.js diff --git a/webapp/e2e/features/history.feature b/webapp/e2e/features/history.feature new file mode 100644 index 00000000..0438ec4b --- /dev/null +++ b/webapp/e2e/features/history.feature @@ -0,0 +1,6 @@ +Feature: Seeing logged user's profile + +Scenario: The user can view the History page + Given A logged-in user + When I click on the History link + Then The History page should be shown on screen \ No newline at end of file diff --git a/webapp/e2e/steps/history.steps.js b/webapp/e2e/steps/history.steps.js new file mode 100644 index 00000000..907a2cdb --- /dev/null +++ b/webapp/e2e/steps/history.steps.js @@ -0,0 +1,58 @@ +const puppeteer = require("puppeteer"); +const { defineFeature, loadFeature } = require("jest-cucumber"); +const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; +const { expect } = require("expect-puppeteer"); +const feature = loadFeature("./features/register-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: 100 }); + page = await browser.newPage(); + //Way of setting up the timeout + setDefaultOptions({ timeout: 10000 }); + + await page + .goto("http://localhost:3000", { + waitUntil: "networkidle0", + }) + .catch(() => {}); + }); + + test("The user can view the History page", ({ given, when, then }) => { + let username; + let password; + + given("A logged-in user", async () => { + username = "testuser"; + password = "Testpassword1"; + await page.waitForSelector("#login-username"); + await page.type("#login-username", username); + await page.waitForSelector("#login-password"); + await page.type("#login-password", password); + await page.click("button", { text: "Login" }); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + when("I click on the History link", async () => { + await page.waitForSelector('[data-testid="profile-menu"]'); + await page.click('[data-testid="profile-menu"]'); + await page.waitForSelector('[data-testid="history-link"]'); + await page.click('[data-testid="history-link"]'); + await page.waitForNavigation({ waitUntil: "networkidle0" }); + }); + + then("The History page should be shown on screen", async () => { + const url = page.url(); + expect(url).toContain("/history"); + }); + }); + + afterAll(async () => { + browser.close(); + }); +}); \ No newline at end of file From b2edb03c8493790f23184c13ddf73d4a9f13d3f2 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Tue, 23 Apr 2024 10:02:25 +0200 Subject: [PATCH 08/47] =?UTF-8?q?A=C3=B1adido=20nuevo=20icono=20de=20la=20?= =?UTF-8?q?aplicaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/public/favicon.ico | Bin 3870 -> 980 bytes webapp/src/index.js | 7 +++++++ 2 files changed, 7 insertions(+) diff --git a/webapp/public/favicon.ico b/webapp/public/favicon.ico index a11777cc471a4344702741ab1c8a588998b1311a..b04df033ee1268052bb7d83c113901d5b3e34e24 100644 GIT binary patch literal 980 zcmV;_11tQAP)Px&j!8s8R9HvtS4%8hQ5gPaJTiz#HT70)1REqxyeb~8)`ZezFy61kqE_r|Y$TSJ ztlC5(Boy^5Q<6$csSFZ9+YpZ^l@?7U9-}kNOmptI*PXd9iv|n->fCd_^Plhh&vRv< zq~isEmzMFRNjZ@7N(OY~0(gCC$66nhM+lg&=y2-T8v@tc0tpFsFgCU;86s(E-WVMG zDTq_4e9_yx#kBE4iHehu%JX}sGB6t&Q6BYQ?($DL!hT87Q|$<2;EGr_CsgqLk5?gKF;fg;^F`_ zH%C#plM@ph9lNY7#UT(8aSPMaPZ^M{$>@c;x^Prgg)lf`R)V#a#l;kagt$`Et*sj< zEYyk{T$P$(>MaC~fpv$MEj zF?X>E@VS$>4z#vLBR~JHU>wB6+{WZ&66dzI2V`XUqPshm!tL(r;o;HG-NV-l!o%G# zH>YI4#I(f3vrbD4PUJ@zGHxoSp3`Wm8js5FI_jD5m|ozJ7$| z(!_Uu&ny1amzNwejTWoLtg;x6n zQBm#`E-h^w8V!H15bcI+#c^>TFfsAlsz%TR*fCL4^A)wV-@xt_VtqoCfWe@KgM%f& zNVg-Ayt?{~`d(Q%L{QK>YCJ!$L|B-mFYN5-;py4W5H*_txm>tWi4qtceFV~yi5Ltf z^z>{YH`kx~E-9HpOUrj^Tv~b$O-+%Ey9m+x`UjH!7mWdn@4PWE5XUGcx1n1w+pMmx z4%pvUF*uXS%%rJG^%;GA{BHqC0tCR019lkO`t_nX+f7Y zrEbt7<^Ky=U~B6+e0&rj%E$|8b5n=v>MxwM(rDt5nrbP}2M4DhMQU_(7Znw=wwJd0 zmb8HA?*FiOL*QCi;41!%>F6mxd)Z&fA95a$)BX<*t$V#;Qr@-z0000;%nil|2-o+rCuEF-(I%-F}ijC~o(k~HKAkr0)!F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SJTAGW(SRGwJwb=@pY7r$uQRK3Zd~XbxU)ts!4XsJrCycrWSI?e!IqwqIR8+Jh zlRjZ`UO1I!BtJR_2~7AbkbSm%XQqxEPkz6BTGWx8e}nQ=w7bZ|eVP4?*Tb!$(R)iC z9)&%bS*u(lXqzitAN)Oo=&Ytn>%Hzjc<5liuPi>zC_nw;Z0AE3Y$Jao_Q90R-gl~5 z_xAb2J%eArrC1CN4G$}-zVvCqF1;H;abAu6G*+PDHSYFx@Tdbfox*uEd3}BUyYY-l zTfEsOqsi#f9^FoLO;ChK<554qkri&Av~SIM*{fEYRE?vH7pTAOmu2pz3X?Wn*!ROX ztd54huAk&mFBemMooL33RV-*1f0Q3_(7hl$<#*|WF9P!;r;4_+X~k~uKEqdzZ$5Al zV63XN@)j$FN#cCD;ek1R#l zv%pGrhB~KWgoCj%GT?%{@@o(AJGt*PG#l3i>lhmb_twKH^EYvacVY-6bsCl5*^~L0 zonm@lk2UvvTKr2RS%}T>^~EYqdL1q4nD%0n&Xqr^cK^`J5W;lRRB^R-O8b&HENO||mo0xaD+S=I8RTlIfVgqN@SXDr2&-)we--K7w= zJVU8?Z+7k9dy;s;^gDkQa`0nz6N{T?(A&Iz)2!DEecLyRa&FI!id#5Z7B*O2=PsR0 zEvc|8{NS^)!d)MDX(97Xw}m&kEO@5jqRaDZ!+%`wYOI<23q|&js`&o4xvjP7D_xv@ z5hEwpsp{HezI9!~6O{~)lLR@oF7?J7i>1|5a~UuoN=q&6N}EJPV_GD`&M*v8Y`^2j zKII*d_@Fi$+i*YEW+Hbzn{iQk~yP z>7N{S4)r*!NwQ`(qcN#8SRQsNK6>{)X12nbF`*7#ecO7I)Q$uZsV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ diff --git a/webapp/src/index.js b/webapp/src/index.js index 9e56989d..a9d85cd2 100644 --- a/webapp/src/index.js +++ b/webapp/src/index.js @@ -7,10 +7,17 @@ import './themes.js'; import './index.css'; // eslint-disable-next-line no-unused-vars import i18n from './i18n.js'; +import favicon from '../public/favicon.png'; var r = document.getElementById("root"); const root = ReactDOM.createRoot(r); +var link = document.createElement('link'); +link.type = 'image/png'; +link.rel = 'icon'; +link.href = favicon; +document.head.appendChild(link); + localStorage.setItem( "selectedThemes", JSON.stringify(["paises", "literatura", "cine", "arte", "programacion"]) From 7415b42c7aca835db728baf7fcb8d8ed7c4b7f43 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Tue, 23 Apr 2024 10:05:47 +0200 Subject: [PATCH 09/47] Fix --- webapp/src/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/webapp/src/index.js b/webapp/src/index.js index a9d85cd2..9e56989d 100644 --- a/webapp/src/index.js +++ b/webapp/src/index.js @@ -7,17 +7,10 @@ import './themes.js'; import './index.css'; // eslint-disable-next-line no-unused-vars import i18n from './i18n.js'; -import favicon from '../public/favicon.png'; var r = document.getElementById("root"); const root = ReactDOM.createRoot(r); -var link = document.createElement('link'); -link.type = 'image/png'; -link.rel = 'icon'; -link.href = favicon; -document.head.appendChild(link); - localStorage.setItem( "selectedThemes", JSON.stringify(["paises", "literatura", "cine", "arte", "programacion"]) From 9dd13ce66044d811f75ce5f1adeee92b43de6461 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Tue, 23 Apr 2024 10:07:56 +0200 Subject: [PATCH 10/47] Cambio de color en el logo --- webapp/public/favicon.ico | Bin 980 -> 369 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/webapp/public/favicon.ico b/webapp/public/favicon.ico index b04df033ee1268052bb7d83c113901d5b3e34e24..0b1706006a6cdb51f7c99d344b87c141122b137b 100644 GIT binary patch literal 369 zcmV-%0gnEOP)Px$D@jB_R5(v#G@3qj$$tihXa+I>BLl-yM#Je-|C6B?u7!FAgz4xoRM^-t7|oal zH{DxJouSFmiNSd0bhwzlgakvglM932vL#?KxC_o@WPt^c4ZtRLA~l_XjhPv)4sO7f z=vW3RUS5I*pc{%31|Z4OT{{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fA95a$)BX<*t$V#;Qr@-z0000 Date: Tue, 23 Apr 2024 10:11:11 +0200 Subject: [PATCH 11/47] Arreglando UI de error de Ranking --- webapp/src/pages/Ranking/Ranking.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webapp/src/pages/Ranking/Ranking.js b/webapp/src/pages/Ranking/Ranking.js index 750fde6f..15b95348 100644 --- a/webapp/src/pages/Ranking/Ranking.js +++ b/webapp/src/pages/Ranking/Ranking.js @@ -96,19 +96,27 @@ const Ranking = () => { if (isLoading) { return ( + <> +