From 6195ee8b4ac6fdc81c3244decd70986f91912351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Su=C3=A1rez=20Losada?= Date: Sun, 5 May 2024 15:14:00 +0200 Subject: [PATCH] test: removing exporting functions as test case crashed thanks to it. Also added timeout to before all Now testing if it works (it should). If it does, i'll make all the test to pass and then refactor will be done if there's time for it before the final delivery --- webapp/e2e/steps/login_positive.steps.js | 37 ++++++++++++++++-------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/webapp/e2e/steps/login_positive.steps.js b/webapp/e2e/steps/login_positive.steps.js index 9002aae6..a1973ae2 100644 --- a/webapp/e2e/steps/login_positive.steps.js +++ b/webapp/e2e/steps/login_positive.steps.js @@ -1,6 +1,3 @@ -const { logOutUser } = require('../e2e_utils/e2e_utils_logout.js'); -const { waitForPageToLoad } = require('../e2e_utils/e2e_utils_timeout.js') -const { registerUserFromRootDirectory } = require('../e2e_utils/e2e_utils_register.js') const { defineFeature, loadFeature }=require('jest-cucumber'); const puppeteer = require('puppeteer'); const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; @@ -11,8 +8,8 @@ let browser; defineFeature(feature, test => { let username = "t.regis.pos"; - let email; - let password; + let email = username + "@gmail.com"; + let password = username + ".psw"; beforeAll(async () => { browser = process.env.GITHUB_ACTIONS @@ -28,15 +25,31 @@ defineFeature(feature, test => { }) .catch(() => {}); + // 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'"); - // Registering the user before the tests - let credentials = registerUserFromRootDirectory(username, page); - email = credentials[0]; - username = credentials[1]; + // Checking for the process to be correct + await new Promise(resolve => setTimeout(resolve, 6000)); + + // Checking user is in main screen + let header = await page.$eval("h2", (element) => { + return element.innerHTML + }) + let value = header === "Bienvenid@ " + username || header === "Welcome " + username; + expect(value).toBeTruthy(); + + - // Logging it out - logOutUser(page); - }); + // Logging it out + await expect(page).toClick("#lateralMenuButton"); + await expect(page).toClick("button[data-testid='LogOut']"); + + }, 120000); test("A registered user wants to log in using his correct credentials", ({given,when,and,then}) => {