Skip to content

Commit

Permalink
fix: removed about and changed stuff in login register negative
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori committed May 5, 2024
1 parent efaaaef commit 6e29997
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 91 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","**/about_positive_logged_user_seeing_about_screen.steps.js"
testMatch: ["**/playing_full_game_pos*.steps.js","**/login_register_negative_bad_email_format.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"],
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
testTimeout: 30000
Expand Down
77 changes: 0 additions & 77 deletions webapp/e2e/steps/about.steps.js

This file was deleted.

68 changes: 55 additions & 13 deletions webapp/e2e/steps/login_register_negative_bad_email_format.steps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { waitForPageToLoad } from '../e2e_utils/e2e_utils_timeout.js';

const { defineFeature, loadFeature }=require('jest-cucumber');
const puppeteer = require('puppeteer');
const setDefaultOptions = require("expect-puppeteer").setDefaultOptions;
Expand All @@ -9,15 +7,14 @@ let browser;


defineFeature(feature, test => {
let username = "t.login.neg.bad_em"
let user;
let password;
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, ignoreHTTPSErrors: true });
? 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 @@ -27,13 +24,19 @@ defineFeature(feature, test => {
waitUntil: "networkidle0",
})
.catch(() => {});


// Registering the user before the tests
await registerUserFromRootDirectory(username, page);

// Logging it out
await logOutUser(page);

}, 120000);

test("A registered user wants to log in using his credentials but with an invalid email", ({given,when,and,then}) => {

given('A registered user in the root screen', async () => {
waitForPageToLoad();
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 @@ -47,7 +50,7 @@ defineFeature(feature, test => {
});

and('User enters in the log in screen', async() => {
waitForPageToLoad();
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 @@ -57,7 +60,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 + "a");
await expect(page).toFill("#password", password);
});

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

then('Log in screen shows an informative error message and does not allow the user to log in', async() => {
waitForPageToLoad();
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 @@ -81,4 +84,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();
}

0 comments on commit 6e29997

Please sign in to comment.