Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finished e2e integration #338

Merged
merged 26 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2473a7c
test: added timeout to before all
GOLASOOO May 5, 2024
7f4fa18
test: added ignore https errors
GOLASOOO May 5, 2024
25a84d5
Merge remote-tracking branch 'origin/test/e2e' into test/e2e
GOLASOOO May 5, 2024
7eabc4b
Merge remote-tracking branch 'origin/test/e2e' into test/e2e
GOLASOOO May 5, 2024
53c1ed3
test: added register test cases
GOLASOOO May 5, 2024
e445f41
fix: about_positive_logged_user_seeing_about_screen.steps.js
Toto-hitori May 5, 2024
9a3254c
fix: about_positive_non_logged_user_seeing_about_screen.steps.js
Toto-hitori May 5, 2024
efaaaef
fix: added timeout for pressing about button
Toto-hitori May 5, 2024
6e29997
fix: removed about and changed stuff in login register negative
Toto-hitori May 5, 2024
95346c2
fix: simplified test
Toto-hitori May 5, 2024
96aa9b5
fix: login_register_negative_blank_email_credentials.steps.js
Toto-hitori May 5, 2024
925c2d6
fix: ignoreHttpsErrors
Toto-hitori May 5, 2024
f820bc4
fix: fixed register
Toto-hitori May 5, 2024
0a656c4
fix: seeing tests
Toto-hitori May 5, 2024
4cc1089
fix: logout and about
Toto-hitori May 5, 2024
baabe89
fix: uncommented https lines
Toto-hitori May 5, 2024
13d23d4
fix: login register negative
Toto-hitori May 5, 2024
89f8204
fix: run all tests
Toto-hitori May 5, 2024
b1974fd
fix: some fixes tests
Toto-hitori May 5, 2024
f5e9321
fix:fixed login register negative
Toto-hitori May 5, 2024
5bfa032
fix:fixed logout positive logged user
Toto-hitori May 5, 2024
b4968c3
fix:fixed register
Toto-hitori May 5, 2024
322fca5
fix:fixed register negative wrong email
Toto-hitori May 5, 2024
5ae916e
fix:fixed register negative blank password
Toto-hitori May 5, 2024
0386a25
fix: added timeout
Toto-hitori May 5, 2024
6b424e3
fix: added timeout
Toto-hitori May 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "[email protected]"
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