From 4bb482bea58fac853f9aae1b35d1ced660a523bb Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Wed, 24 Apr 2024 23:23:01 +0200 Subject: [PATCH 1/3] Little fix --- webapp/e2e/steps/add-friend.steps.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/webapp/e2e/steps/add-friend.steps.js b/webapp/e2e/steps/add-friend.steps.js index 1d8418bf..5d5a5509 100644 --- a/webapp/e2e/steps/add-friend.steps.js +++ b/webapp/e2e/steps/add-friend.steps.js @@ -22,10 +22,11 @@ defineFeature(feature, (test) => { }); let username; let password; + let userCountBefore; test("The user can add a friend", ({ given, when, then }) => { given("A logged-in user and another user", async () => { await expect(page).toClick("a", { text: "Regístrate" }); - username="friend"; + username="Friend"; password="Friend123"; await page.waitForSelector('#register-username'); await page.type('#register-username', username); @@ -59,23 +60,19 @@ defineFeature(feature, (test) => { //await page.waitForNavigation({ waitUntil: "networkidle0" }); await page.waitForTimeout(1000); + const userRowsBefore = await page.$$('[data-testid^="user-row-"]'); + userCountBefore = userRowsBefore.length; + await page.waitForSelector('[data-testid^="add-friend-button-"]'); await page.click('[data-testid^="add-friend-button-"]'); }); then("The user should disappear from the Users page", async () => { - await page.waitForTimeout(1000); - - const userRowsBefore = await page.$$('[data-testid^="user-row-"]'); - const userCountBefore = userRowsBefore.length; - - await page.waitForSelector('[data-testid^="add-friend-button-"]'); - const addFriendButtons = await page.$$('[data-testid^="add-friend-button-"]'); - await addFriendButtons[0].click(); await page.waitForTimeout(1000); - + await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] }); + const userRowsAfter = await page.$$('[data-testid^="user-row-"]'); const userCountAfter = userRowsAfter.length; From 18c929f3246c9db6c34689bbe96aa6ab63be259d Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Thu, 25 Apr 2024 00:01:37 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Arreglado=20el=20error=20de=20duplicaci?= =?UTF-8?q?=C3=B3n=20al=20agregar=20amigo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/userservice/user-service.js | 2 ++ webapp/src/locales/en.json | 2 +- webapp/src/locales/es.json | 2 +- webapp/src/pages/Social/UsersPage.js | 3 --- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 6823d844..fe96feca 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -101,6 +101,7 @@ app.post("/adduser", async (req, res) => { app.get("/users", async (req, res) => { try { const users = await User.find(); + console.log(users); res.status(200).json(users); } catch (error) { res.status(500).json({ error: "Internal Server Error" }); @@ -219,6 +220,7 @@ app.get("/friends", async (req, res) => { } // Devuelve la lista de amigos res.status(200).json({ friends: user.friends }); + } catch (error) { res.status(500).json({ error: "Internal Server Error" }); } diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 0cf88c18..8fd8d5ae 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -194,7 +194,7 @@ "list": "User List", "user": "User", "actions": "Actions", - "friend": "Friend", + "friend": "Already friends", "addFriend": "Add Friend", "loading": "Loading users...", "error": "Error loading users: " diff --git a/webapp/src/locales/es.json b/webapp/src/locales/es.json index df2ec035..3e239b02 100644 --- a/webapp/src/locales/es.json +++ b/webapp/src/locales/es.json @@ -194,7 +194,7 @@ "list": "Lista de usuarios", "user": "Usuario", "actions": "Acciones", - "friend": "Amigo", + "friend": "Ya sois amigos", "addFriend": "Añadir amigo", "loading": "Cargando usuarios ...", "error": "Error al cargar los usuarios: " diff --git a/webapp/src/pages/Social/UsersPage.js b/webapp/src/pages/Social/UsersPage.js index bde2d5c1..ebed5838 100644 --- a/webapp/src/pages/Social/UsersPage.js +++ b/webapp/src/pages/Social/UsersPage.js @@ -103,9 +103,6 @@ const UsersPage = () => { throw new Error("Error al agregar amigo"); } - // Agregar el usuario a la lista de amigos localmente - setUsers((prevFriends) => [...prevFriends, user]); - // Actualizar el estado de isFriend del usuario setUsers((prevUsers) => { return prevUsers.map((u) => { if (u._id === user._id) { From f4377d115050f34821cb17d48799e5c6b2b1255f Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Thu, 25 Apr 2024 00:04:35 +0200 Subject: [PATCH 3/3] Formato --- webapp/src/locales/en.json | 2 +- webapp/src/locales/es.json | 2 +- webapp/src/pages/Social/UsersPage.js | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/webapp/src/locales/en.json b/webapp/src/locales/en.json index 8fd8d5ae..11b00d8c 100644 --- a/webapp/src/locales/en.json +++ b/webapp/src/locales/en.json @@ -191,7 +191,7 @@ "home": "Back to Home" }, "userspage": { - "list": "User List", + "list": "Application users", "user": "User", "actions": "Actions", "friend": "Already friends", diff --git a/webapp/src/locales/es.json b/webapp/src/locales/es.json index 3e239b02..33e57b6b 100644 --- a/webapp/src/locales/es.json +++ b/webapp/src/locales/es.json @@ -191,7 +191,7 @@ "home": "Volver al inicio" }, "userspage": { - "list": "Lista de usuarios", + "list": "Usuarios de la aplicación", "user": "Usuario", "actions": "Acciones", "friend": "Ya sois amigos", diff --git a/webapp/src/pages/Social/UsersPage.js b/webapp/src/pages/Social/UsersPage.js index ebed5838..c8b9a2ef 100644 --- a/webapp/src/pages/Social/UsersPage.js +++ b/webapp/src/pages/Social/UsersPage.js @@ -113,7 +113,6 @@ const UsersPage = () => { }); } catch (error) { console.error("Error al agregar amigo:", error); - // Manejar el error según sea necesario } };