diff --git a/webapp/e2e/jest.config.js b/webapp/e2e/jest.config.js index e4673362..b15fd886 100644 --- a/webapp/e2e/jest.config.js +++ b/webapp/e2e/jest.config.js @@ -1,5 +1,5 @@ module.exports = { - testMatch: ["**/playing*.steps.js","**/login*.steps.js","**/about*.steps.js","**/register*.steps.js","**/seeing*.steps.js"], + testMatch: ["**/about*.steps.js","**/logout*.steps.js"], moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], testTimeout: 30000 } \ No newline at end of file diff --git a/webapp/e2e/steps/about_positive_logged_user_seeing_about_screen.steps.js b/webapp/e2e/steps/about_positive_logged_user_seeing_about_screen.steps.js index 520869ed..f2629561 100644 --- a/webapp/e2e/steps/about_positive_logged_user_seeing_about_screen.steps.js +++ b/webapp/e2e/steps/about_positive_logged_user_seeing_about_screen.steps.js @@ -7,7 +7,7 @@ let browser; defineFeature(feature, test => { - let username = "t.about.pos"; + let username = "about_pos"; beforeAll(async () => { browser = process.env.GITHUB_ACTIONS diff --git a/webapp/e2e/steps/logout_positive_logged_user.steps.js b/webapp/e2e/steps/logout_positive_logged_user.steps.js index fd6cc9db..d06f8633 100644 --- a/webapp/e2e/steps/logout_positive_logged_user.steps.js +++ b/webapp/e2e/steps/logout_positive_logged_user.steps.js @@ -7,9 +7,7 @@ let browser; defineFeature(feature, test => { - let username = "t.logOu.pos.logged" - let userEmail; - let password; + let username = "logout_p_logged" beforeAll(async () => { browser = process.env.GITHUB_ACTIONS @@ -25,25 +23,16 @@ defineFeature(feature, test => { }) .catch(() => {}); - // Registering the user before the tests - let credentials = registerUserFromRootDirectory(username, page); - userEmail = credentials[0]; - username = credentials[1]; + // Registering the user before the tests + await registerUserFromRootDirectory(username, page); + }, 120000); test("A logged user wants to log out the webpage", ({given,when,and,then}) => { let gameURL = "http://localhost:3000/dashboard/game"; given('A logged user in main menu', async () => { - let header = await page.$eval("button[data-testid='Login']", (element) => { - return element.innerHTML - }) - let value = header === "Login" || "Iniciar sesiĆ³n"; - - expect(value).toBeTruthy(); - - - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 5000)); let newHeader = await page.$eval("h2", (element) => { return element.innerHTML }) @@ -52,7 +41,7 @@ defineFeature(feature, test => { }); when('User presses the button for deploying the lateral menu', async() => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 5000)); await expect(page).toClick("#lateralMenuButton"); }); @@ -63,7 +52,7 @@ defineFeature(feature, test => { }); then('The login screen shows on the user device and the user is no longer logged in', async() => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 5000)); let header = await page.$eval("button[data-testid='Login']", (element) => { return element.innerHTML }) @@ -79,6 +68,26 @@ defineFeature(feature, test => { }); }); -async function waitForPageToLoad (timeout_ms = 6000) { - await new Promise(resolve => setTimeout(resolve, timeout_ms)); -} \ No newline at end of file +async function registerUserFromRootDirectory(username, page) { + // Credentials for the new user + let email = username + "@email.com" + let password = username + "psw" + + // Registering process + await expect(page).toClick("span[class='chakra-link css-1bicqx'"); + await expect(page).toFill("input[id='user'", email); + await expect(page).toFill("input[id='username'", username); + await expect(page).toFill("#password", password); + await expect(page).toFill("input[id='field-:r5:']", password); + await expect(page).toClick("button[data-testid='Sign up'"); + + // Checking for the process to be correct + await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load + let header = await page.$eval("h2", (element) => { + return element.innerHTML + }) + let value = header === "Bienvenid@ " + username || header === "Welcome " + username; + expect(value).toBeTruthy(); + + return [email, password]; +} diff --git a/webapp/e2e/steps/logout_positive_non_logged_user.steps.js b/webapp/e2e/steps/logout_positive_non_logged_user.steps.js index 7b0d29f6..344964ec 100644 --- a/webapp/e2e/steps/logout_positive_non_logged_user.steps.js +++ b/webapp/e2e/steps/logout_positive_non_logged_user.steps.js @@ -1,8 +1,3 @@ -import { registerUserFromRootDirectory}from '../e2e_utils/e2e_utils_register.js'; -import { waitForPageToLoad } from '../e2e_utils/e2e_utils_timeout.js'; -import { logOutUser } from '../e2e_utils/e2e_utils_logout.js'; -import { loginUserFromRootDirectory } from '../e2e_utils/e2e_utils_login.js' - const { defineFeature, loadFeature }=require('jest-cucumber'); const puppeteer = require('puppeteer'); const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; @@ -12,10 +7,6 @@ let browser; defineFeature(feature, test => { - let username = "t.logoU.neg.n_log" - let user; - let password; - beforeAll(async () => { browser = process.env.GITHUB_ACTIONS ? await puppeteer.launch({ ignoreHTTPSErrors: true }) @@ -32,14 +23,9 @@ defineFeature(feature, test => { }, 120000); test("A non-logged user wants to log out the webpage", ({given,when,then}) => { - let username = "pepe" - let user = username + "@pepe.com" - let password = "pepe" - - let gameURL = "http://localhost:3000/dashboard/game"; given('A non-logged user in main menu', async () => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 5000)); let header = await page.$eval("button[data-testid='Login']", (element) => { return element.innerHTML }) @@ -57,7 +43,7 @@ defineFeature(feature, test => { }); then('The login screen shows on the user device', async() => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 5000)); let header = await page.$eval("button[data-testid='Login']", (element) => { return element.innerHTML })