generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Dario G.Mori <[email protected]>
- Loading branch information
Showing
5 changed files
with
120 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* 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(); | ||
|
||
} | ||
modules.export ={loginUserFromRootDirectory}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const {waitForPageToLoad} = require('../e2e_utils/e2e_utils_timeout.js'); | ||
|
||
/** | ||
* 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(); | ||
} | ||
modules.export = {logOutUser} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* 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]; | ||
} | ||
|
||
modules.export ={registerUserFromRootDirectory}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* 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)); | ||
|
||
} | ||
|
||
modules.export = {waitForPageToLoad} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters