Skip to content

Commit

Permalink
test: modified e2e test
Browse files Browse the repository at this point in the history
Co-authored-by: Dario G.Mori <[email protected]>
  • Loading branch information
GOLASOOO committed May 1, 2024
1 parent ac2747e commit 4824f0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 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: ["**/steps/register_positive_form.steps.js"],
testMatch: ["**/steps/register_positive*.steps.js"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testTimeout: 30000
}
24 changes: 7 additions & 17 deletions webapp/e2e/steps/register_positive_form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ let browser;


defineFeature(feature, test => {
let userName = "t.reg.pos"
let userEmail = userName + "@gmail.com";
let password = userName + ".psw";

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
Expand All @@ -25,27 +28,14 @@ defineFeature(feature, test => {
});

test("The user is not registered in the root directory of the website", ({given,when,and,then}) => {
// Trying to avoid repeated users:
// Generate random bytes
let randomBytes = crypto.randomBytes(8); // 8 bytes = 64 bits
// Convert bytes to hex
let hexString = randomBytes.toString('hex');
// Take the first 16 characters
let randomHash = hexString.substring(0, 4);

let username = "test" + randomHash
let user = username + "@email.com"
let password = "password"


given("An unregistered user", async () => {

});

when("I fill the data in the form", 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='user'", userEmail);
await expect(page).toFill("input[id='username'", userName);
await expect(page).toFill("#password", password);
await expect(page).toFill("input[id='field-:r5:']", password);

Expand All @@ -57,11 +47,11 @@ defineFeature(feature, test => {
});

then("The main menu screen is shown", async () => {
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load
await new Promise(resolve => setTimeout(resolve, 6000));
let header = await page.$eval("h2", (element) => {
return element.innerHTML
})
let value = header === "Bienvenid@ " + username || header === "Welcome " + username;
let value = header === "Bienvenid@ " + userName || header === "Welcome " + userName;

expect(value).toBeTruthy();
});
Expand Down

0 comments on commit 4824f0a

Please sign in to comment.