diff --git a/webapp/e2e/jest.config.js b/webapp/e2e/jest.config.js index 0586f4a8..9efab019 100644 --- a/webapp/e2e/jest.config.js +++ b/webapp/e2e/jest.config.js @@ -1,6 +1,6 @@ module.exports = { testMatch: ["**/playing_full_game_pos*.steps.js","**/login_register_negative_bad_email_format.steps.js","**/login_register_negative_blank_email_credentials.steps.js", "**/login_positive.steps.js","**/about_positive_logged_user_seeing_about_screen.steps.js" - ,"**/about_positive_non_logged_user_seeing_about_screen.steps.js"], + ,"**/about_positive_non_logged_user_seeing_about_screen.steps.js","**/login_register_negative_blank_password_credentials.steps.js","**/register*.steps.js"], moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], testTimeout: 30000 } \ No newline at end of file diff --git a/webapp/e2e/steps/register_negative_blank_username.steps.js b/webapp/e2e/steps/register_negative_blank_username.steps.js index fc50429d..cbd744ef 100644 --- a/webapp/e2e/steps/register_negative_blank_username.steps.js +++ b/webapp/e2e/steps/register_negative_blank_username.steps.js @@ -36,7 +36,7 @@ defineFeature(feature, test => { when("The user fills its data in the form leaving the username field in blank", async () => { await expect(page).toClick("span[class='chakra-link css-1bicqx'"); await expect(page).toFill("input[id='user'", user); - await expect(page).toFill("input[id='username'", username); + await expect(page).toFill("input[id='username'", ""); await expect(page).toFill("#password", password); await expect(page).toFill("input[id='field-:r5:']", password); @@ -68,101 +68,3 @@ defineFeature(feature, test => { }); - -/** - * Note: e2e Testing purposes only! - * Auxiliar function for logging out an user from any directory of the user. - * Beware if the user is playing a game when logging out - * It also ensures the task has been performed successfully. - * - * @param {*} page The website - */ -async function logOutUser(page) { - // Logging out - await expect(page).toClick("#lateralMenuButton"); - await expect(page).toClick("button[data-testid='LogOut']"); - - // Checking for the log out to be sucessful - await new Promise(resolve => setTimeout(resolve, 6000)); - - - let header = await page.$eval("button[data-testid='Login']", (element) => { - return element.innerHTML - }) - let value = header === "Login" || "Iniciar sesión"; - - expect(value).toBeTruthy(); -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function for login an user using its credentials from the root directory of the website. -* It also ensures the task has been performed successfully. -* -* @param username The username for the user. Currently we are using codes for each test case. -* @param email The email for the user. If none is defined, the username (a code) + '@gmail.com' is used -* @param password The password for the user. If none is defined, the username (a code) + '.ps' is used -* Beware of constraits for the user password. -* @param page The website -*/ -async function loginUserFromRootDirectory(username, email = username + "@gmail.com", password = username + ".ps", page) { - - // login process - await expect(page).toClick("button[data-testid='Login'"); - await expect(page).toFill("#user", email); - await expect(page).toFill("#password", password); - await expect(page).toClick("button[data-testid='Login'"); - - // Checking for the process to be correct - await new Promise(resolve => setTimeout(resolve, 6000)); // 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(); - -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function for registering a new user from the root directory of the website. -* It also ensures the task has been performed successfully. -* -* @param {*} username The username for the new user. Currently we are using codes for each test case. -* @param {*} page The website -* @returns An array with the credentials of the user created [email, username] -*/ -async function registerUserFromRootDirectory(username, page) { - // Credentials for the new user - let email = username + "@email.com" - let password = username + "ps" - - // Registeing 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, 6000)); // 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]; -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function that times out the tests for some time, so the page can be fully loaded. -* @param {*} timeout_ms Amount of ms to wait. -*/ -async function waitForPageToLoad(timeout_ms = 6000) { - await new Promise(resolve => setTimeout(resolve, timeout_ms)); - -} - diff --git a/webapp/e2e/steps/register_negative_email_already_in_use_form.steps.js b/webapp/e2e/steps/register_negative_email_already_in_use_form.steps.js index f1044748..c3049b88 100644 --- a/webapp/e2e/steps/register_negative_email_already_in_use_form.steps.js +++ b/webapp/e2e/steps/register_negative_email_already_in_use_form.steps.js @@ -73,100 +73,42 @@ defineFeature(feature, test => { }); - - -/** - * Note: e2e Testing purposes only! - * Auxiliar function for logging out an user from any directory of the user. - * Beware if the user is playing a game when logging out - * It also ensures the task has been performed successfully. - * - * @param {*} page The website - */ -async function logOutUser(page) { - // Logging out - await expect(page).toClick("#lateralMenuButton"); - await expect(page).toClick("button[data-testid='LogOut']"); - - // Checking for the log out to be sucessful - waitForPageToLoad(); - let header = await page.$eval("button[data-testid='Login']", (element) => { - return element.innerHTML - }) - let value = header === "Login" || "Iniciar sesión"; - - expect(value).toBeTruthy(); -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function for login an user using its credentials from the root directory of the website. -* It also ensures the task has been performed successfully. -* -* @param username The username for the user. Currently we are using codes for each test case. -* @param email The email for the user. If none is defined, the username (a code) + '@gmail.com' is used -* @param password The password for the user. If none is defined, the username (a code) + '.ps' is used -* Beware of constraits for the user password. -* @param page The website -*/ -async function loginUserFromRootDirectory(username, email = username + "@gmail.com", password = username + ".ps", page) { - - // login process - await expect(page).toClick("button[data-testid='Login'"); - await expect(page).toFill("#user", email); - await expect(page).toFill("#password", password); - await expect(page).toClick("button[data-testid='Login'"); - - // Checking for the process to be correct - await new Promise(resolve => setTimeout(resolve, 6000)); // 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(); - -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function for registering a new user from the root directory of the website. -* It also ensures the task has been performed successfully. -* -* @param {*} username The username for the new user. Currently we are using codes for each test case. -* @param {*} page The website -* @returns An array with the credentials of the user created [email, username] -*/ async function registerUserFromRootDirectory(username, page) { - // Credentials for the new user - let email = username + "@email.com" - let password = username + "ps" - - // Registeing 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, 6000)); // 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]; + // 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]; } -/** -* Note: e2e Testing purposes only! -* Auxiliar function that times out the tests for some time, so the page can be fully loaded. -* @param {*} timeout_ms Amount of ms to wait. -*/ -async function waitForPageToLoad(timeout_ms = 6000) { - await new Promise(resolve => setTimeout(resolve, timeout_ms)); - +async function logOutUser(page) { + // Logging out + await expect(page).toClick("#lateralMenuButton"); + await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load + await expect(page).toClick("button[data-testid='LogOut']"); + + // Checking for the log out to be sucessful + await new Promise(resolve => setTimeout(resolve, 5000)); + let header = await page.$eval("button[data-testid='Login']", (element) => { + return element.innerHTML + }) + let value = header === "Login" || "Iniciar sesión"; + + expect(value).toBeTruthy(); } - diff --git a/webapp/e2e/steps/register_negative_username_already_in_use_form.steps.js b/webapp/e2e/steps/register_negative_username_already_in_use_form.steps.js index 11b0cd3a..83027a94 100644 --- a/webapp/e2e/steps/register_negative_username_already_in_use_form.steps.js +++ b/webapp/e2e/steps/register_negative_username_already_in_use_form.steps.js @@ -10,7 +10,7 @@ let browser; defineFeature(feature, test => { let username = "t.reg.neg.un_aiu" let user = username + "@gmail.com"; - let password = username + ".psw"; + let password = username + "psw"; beforeAll(async () => { @@ -26,6 +26,11 @@ defineFeature(feature, test => { waitUntil: "networkidle0", }) .catch(() => {}); + + await registerUserFromRootDirectory(username,page); + + await logOutUser(page); + }, 120000); test("The user is not registered in the root directory of the website and tries to create an account", ({given,when,and,then}) => { @@ -67,102 +72,43 @@ defineFeature(feature, test => { }); }); - - -/** - * Note: e2e Testing purposes only! - * Auxiliar function for logging out an user from any directory of the user. - * Beware if the user is playing a game when logging out - * It also ensures the task has been performed successfully. - * - * @param {*} page The website - */ -async function logOutUser(page) { - // Logging out - await expect(page).toClick("#lateralMenuButton"); - await expect(page).toClick("button[data-testid='LogOut']"); - - // Checking for the log out to be sucessful - await new Promise(resolve => setTimeout(resolve, 6000)); - - - let header = await page.$eval("button[data-testid='Login']", (element) => { - return element.innerHTML - }) - let value = header === "Login" || "Iniciar sesión"; - - expect(value).toBeTruthy(); -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function for login an user using its credentials from the root directory of the website. -* It also ensures the task has been performed successfully. -* -* @param username The username for the user. Currently we are using codes for each test case. -* @param email The email for the user. If none is defined, the username (a code) + '@gmail.com' is used -* @param password The password for the user. If none is defined, the username (a code) + '.ps' is used -* Beware of constraits for the user password. -* @param page The website -*/ -async function loginUserFromRootDirectory(username, email = username + "@gmail.com", password = username + ".ps", page) { - - // login process - await expect(page).toClick("button[data-testid='Login'"); - await expect(page).toFill("#user", email); - await expect(page).toFill("#password", password); - await expect(page).toClick("button[data-testid='Login'"); - - // Checking for the process to be correct - await new Promise(resolve => setTimeout(resolve, 6000)); // 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(); - -} - -/** -* Note: e2e Testing purposes only! -* Auxiliar function for registering a new user from the root directory of the website. -* It also ensures the task has been performed successfully. -* -* @param {*} username The username for the new user. Currently we are using codes for each test case. -* @param {*} page The website -* @returns An array with the credentials of the user created [email, username] -*/ async function registerUserFromRootDirectory(username, page) { - // Credentials for the new user - let email = username + "@email.com" - let password = username + "ps" - - // Registeing 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, 6000)); // 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]; + // 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]; } -/** -* Note: e2e Testing purposes only! -* Auxiliar function that times out the tests for some time, so the page can be fully loaded. -* @param {*} timeout_ms Amount of ms to wait. -*/ -async function waitForPageToLoad(timeout_ms = 6000) { - await new Promise(resolve => setTimeout(resolve, timeout_ms)); - +async function logOutUser(page) { + // Logging out + await expect(page).toClick("#lateralMenuButton"); + await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load + await expect(page).toClick("button[data-testid='LogOut']"); + + // Checking for the log out to be sucessful + await new Promise(resolve => setTimeout(resolve, 5000)); + let header = await page.$eval("button[data-testid='Login']", (element) => { + return element.innerHTML + }) + let value = header === "Login" || "Iniciar sesión"; + + expect(value).toBeTruthy(); } diff --git a/webapp/e2e/steps/register_negative_wrong_email_format.steps.js b/webapp/e2e/steps/register_negative_wrong_email_format.steps.js index 7413296e..664b17fe 100644 --- a/webapp/e2e/steps/register_negative_wrong_email_format.steps.js +++ b/webapp/e2e/steps/register_negative_wrong_email_format.steps.js @@ -8,7 +8,7 @@ let browser; defineFeature(feature, test => { let username = "t.reg.neg.wr_em"; - let user = username + "@gmail.com"; + let user = username ; let password = username + ".psw"; beforeAll(async () => {