From 3a28848874ba007429d52269a386d9ce065b7e87 Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Wed, 24 Apr 2024 19:08:26 +0200 Subject: [PATCH] =?UTF-8?q?Eliminando=20m=C3=A1s=20test=20innecesarios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/e2e/steps/ranking-sorting.steps.js | 64 ---------------------- webapp/e2e/steps/ranking.steps.js | 63 ---------------------- webapp/e2e/steps/stats.steps.js | 62 --------------------- webapp/e2e/steps/users-addfriend.steps.js | 65 ----------------------- 4 files changed, 254 deletions(-) delete mode 100644 webapp/e2e/steps/ranking-sorting.steps.js delete mode 100644 webapp/e2e/steps/ranking.steps.js delete mode 100644 webapp/e2e/steps/stats.steps.js delete mode 100644 webapp/e2e/steps/users-addfriend.steps.js diff --git a/webapp/e2e/steps/ranking-sorting.steps.js b/webapp/e2e/steps/ranking-sorting.steps.js deleted file mode 100644 index 64a6228f..00000000 --- a/webapp/e2e/steps/ranking-sorting.steps.js +++ /dev/null @@ -1,64 +0,0 @@ -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/ranking-sorting.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 see the Ranking page and change sorting filter", ({ 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 Ranking link and in Sort by Total Points", async () => { - await page.click('button[aria-label="Abrir menú"]'); - await page.click('[data-testid="home-ranking-link"]'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); - await page.select('[data-testid="combobox"]', "totalPoints"); - await page.waitForSelector('th', { text: "Puntos totales" }); - await page.waitForSelector('td'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); - }); - - then("The ranking (sorted by Total Points) should be shown on screen", async () => { - const url = page.url(); - expect(url).toContain("/ranking"); - const displayedField = await page.evaluate(() => { - return document.querySelector('th').textContent; - }); - expect(displayedField).toContain("Puntos totales"); - }); - }); - - afterAll(async () => { - browser.close(); - }); -}); diff --git a/webapp/e2e/steps/ranking.steps.js b/webapp/e2e/steps/ranking.steps.js deleted file mode 100644 index d607fcaa..00000000 --- a/webapp/e2e/steps/ranking.steps.js +++ /dev/null @@ -1,63 +0,0 @@ -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/ranking.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 see the Ranking page and change gamemode", ({ 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 Ranking link and in Battery gamemode", async () => { - await page.click('button[aria-label="Abrir menú"]'); - await page.click('[data-testid="home-ranking-link"]'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); - await page.click('[data-testid="battery-button"]'); - await page.waitForSelector('button.active'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); - }); - - then("The ranking of the Battery gamemode should be shown on screen", async () => { - const url = page.url(); - expect(url).toContain("/ranking"); - const statsText = await page.evaluate(() => { - return document.querySelector("h2").textContent; - }); - expect(statsText).toContain("Batería de sabios"); - }); - }); - - afterAll(async () => { - browser.close(); - }); -}); diff --git a/webapp/e2e/steps/stats.steps.js b/webapp/e2e/steps/stats.steps.js deleted file mode 100644 index 123bdb48..00000000 --- a/webapp/e2e/steps/stats.steps.js +++ /dev/null @@ -1,62 +0,0 @@ -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/stats.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 see his Stats page and change gamemode", ({ 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 Stats link and in Calculator gamemode", async () => { - await page.click('button[aria-label="Abrir menú"]'); - await page.click('[data-testid="home-stats-link"]'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); - await page.click('[data-testid="calculator-button"]'); - await page.waitForSelector('button.active'); - }); - - then("The user's stats in Calculator gamemode shoud be shown on screen", async () => { - const url = page.url(); - expect(url).toContain("/stats"); - const statsText = await page.evaluate(() => { - return document.querySelector("h2").textContent; - }); - expect(statsText).toContain("Calculadora humana"); - }); - }); - - afterAll(async () => { - browser.close(); - }); -}); diff --git a/webapp/e2e/steps/users-addfriend.steps.js b/webapp/e2e/steps/users-addfriend.steps.js deleted file mode 100644 index 30864473..00000000 --- a/webapp/e2e/steps/users-addfriend.steps.js +++ /dev/null @@ -1,65 +0,0 @@ -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/users-addfriend.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 add a friend", ({ 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 Users link and add a friend", async () => { - await page.click('button[aria-label="Abrir menú"]'); - await page.click('[data-testid="home-usuarios-link"]'); - await page.waitForNavigation({ waitUntil: "networkidle0" }); - }); - - then("The user should disappear from the Users page", async () => { - const url = page.url(); - expect(url).toContain("/social/"); - - const numUsersBefore = await page.$$eval('tr', (rows) => rows.length); - - await page.click('[data-testid="add-friend-button-0"]'); - await page.waitForTimeout(1000); - - const numUsersAfter = await page.$$eval('tr', (rows) => rows.length); - - expect(numUsersAfter).toBeLessThan(numUsersBefore); - }); - }); - - afterAll(async () => { - browser.close(); - }); -});