Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori committed May 5, 2024
2 parents b0baaeb + 09e9b14 commit 8181872
Show file tree
Hide file tree
Showing 24 changed files with 855 additions and 342 deletions.
2 changes: 1 addition & 1 deletion webapp/e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
testMatch: ["**/playing_full_game_pos*.steps.js","**/about.steps.js", "**/login_positive.steps.js"],
testMatch: ["**/*.steps.js"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testTimeout: 30000
}
77 changes: 0 additions & 77 deletions webapp/e2e/steps/about.steps.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ let browser;


defineFeature(feature, test => {
let username = "about_pos";

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 100 });
? await puppeteer.launch({ ignoreHTTPSErrors: true})
: await puppeteer.launch({ headless: false, slowMo: 100, ignoreHTTPSErrors: true });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand All @@ -21,33 +22,32 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
})
.catch(() => {});
});

test("A logged user wants to see the about screen of the webpage", ({given,when,and,then}) => {
// Registering the user before the tests
await registerUserFromRootDirectory(username, page);

let username;
let password;

given("A logged user in the main menu", async () => {
username = "test@email.com"
password = "password"

await expect(page).toClick("button[data-testid='Login'");
await expect(page).toFill("#user", username);
await expect(page).toFill("#password", password);
await expect(page).toClick("button[data-testid='Login'");
// Logging it out
await logOutUser(page);

}, 120000);

test("A logged user wants to see the about screen of the webpage", ({given,when,and,then}) => {

given("A logged user in the main menu", async () => {
await loginUserFromRootDirectory(username, page);
});

when("The user presses the button for deploying the lateral menu", async () => {
await expect(page).toClick("#lateralMenuButton");
});

and("the user presses the button for seeing the about section (i)", async () => {
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
await expect(page).toClick("#aboutButton");
});

then("The user is presented to the about screen", async () => {
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
let header = await page.$eval("h2", (element) => {
return element.innerHTML
})
Expand All @@ -60,4 +60,63 @@ defineFeature(feature, test => {
done();
browser.close();
});
});
});
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];
}

async function logOutUser(page) {
// Logging out
await expect(page).toClick("#lateralMenuButton");
await new Promise(resolve => setTimeout(resolve, 5000));
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();
}
async function loginUserFromRootDirectory(username, page) {
// Credentials for the new user
let email = username + "@email.com"
let password = username + "psw"

// 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, 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();

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ let browser;


defineFeature(feature, test => {

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 100 });
? await puppeteer.launch({ ignoreHTTPSErrors: true})
: await puppeteer.launch({ headless: false, slowMo: 100, ignoreHTTPSErrors: true });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand All @@ -21,7 +20,7 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
})
.catch(() => {});
});
}, 120000);

test("A non-logged user wants to see the about screen of the webpage", ({given,when,and,then}) => {

Expand All @@ -34,11 +33,12 @@ defineFeature(feature, test => {
});

and("the user presses the button for seeing the about section (i)", async () => {
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
await expect(page).toClick("#aboutButton");
});

then("The user is presented to the about screen", async () => {
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
let header = await page.$eval("h2", (element) => {
return element.innerHTML
})
Expand Down
62 changes: 51 additions & 11 deletions webapp/e2e/steps/login_register_negative_bad_email_format.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ let browser;


defineFeature(feature, test => {
let username = "t.login.neg.bad.em"
let password = username + "psw" ;


beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 100 });
? await puppeteer.launch({ ignoreHTTPSErrors: true})
: await puppeteer.launch({ headless: false, slowMo: 100, ignoreHTTPSErrors: true});
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand All @@ -21,15 +24,13 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
})
.catch(() => {});
});

}, 120000);

test("A registered user wants to log in using his credentials but with an invalid email", ({given,when,and,then}) => {
let username = "pepe"
let user = username + "email.com" // Bad formatted email
let password = "Password"

given('A registered user in the root screen', async () => {
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
let header = await page.$eval("button[data-testid='Login']", (element) => {
return element.innerHTML
})
Expand All @@ -43,7 +44,7 @@ defineFeature(feature, test => {
});

and('User enters in the log in screen', async() => {
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
let header = await page.$eval("h2", (element) => {
return element.innerHTML
})
Expand All @@ -53,7 +54,7 @@ defineFeature(feature, test => {
});

and('User fills the form with his proper password but writes a wrong formatted email', async() => {
await expect(page).toFill("#user", user);
await expect(page).toFill("#user", username );
await expect(page).toFill("#password", password);
});

Expand All @@ -62,7 +63,7 @@ defineFeature(feature, test => {
});

then('Log in screen shows an informative error message and does not allow the user to log in', async() => {
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load
await new Promise(resolve => setTimeout(resolve, 5000)); // Waiting for page to fully load
let header = await page.$eval("div[class='chakra-alert__desc css-zzks76'", (element) => {
return element.innerHTML
})
Expand All @@ -77,4 +78,43 @@ defineFeature(feature, test => {
done();
browser.close();
});
});
});
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];
}

async function logOutUser(page) {
// Logging out
await expect(page).toClick("#lateralMenuButton");
await new Promise(resolve => setTimeout(resolve, 5000));
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();
}
Loading

0 comments on commit 8181872

Please sign in to comment.