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 1/3] 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}) => { From be0f6367337d5cbf04796aaff068716bd76bd62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Su=C3=A1rez=20Losada?= Date: Sun, 5 May 2024 15:29:02 +0200 Subject: [PATCH 2/3] test: removing unexported functions --- webapp/e2e/steps/login_positive.steps.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/e2e/steps/login_positive.steps.js b/webapp/e2e/steps/login_positive.steps.js index a1973ae2..4c8c0f44 100644 --- a/webapp/e2e/steps/login_positive.steps.js +++ b/webapp/e2e/steps/login_positive.steps.js @@ -54,7 +54,7 @@ defineFeature(feature, test => { test("A registered user wants to log in using his correct credentials", ({given,when,and,then}) => { given('A registered user in the root screen', async () => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 6000)); let header = await page.$eval("button[data-testid='Login']", (element) => { return element.innerHTML }) @@ -68,7 +68,7 @@ defineFeature(feature, test => { }); and('User enters in the log in screen', async() => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 6000)); let header = await page.$eval("h2", (element) => { return element.innerHTML }) @@ -87,7 +87,7 @@ defineFeature(feature, test => { }); then('The main menu screen shows on the user device', async() => { - waitForPageToLoad(); + await new Promise(resolve => setTimeout(resolve, 6000)); let header = await page.$eval("h2", (element) => { return element.innerHTML }) From 0477e46c28cb41434c4ba95d10823aad3711c2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Su=C3=A1rez=20Losada?= Date: Sun, 5 May 2024 15:45:20 +0200 Subject: [PATCH 3/3] test: added timeout --- webapp/e2e/steps/login_positive.steps.js | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/e2e/steps/login_positive.steps.js b/webapp/e2e/steps/login_positive.steps.js index 4c8c0f44..66b42120 100644 --- a/webapp/e2e/steps/login_positive.steps.js +++ b/webapp/e2e/steps/login_positive.steps.js @@ -47,6 +47,7 @@ defineFeature(feature, test => { // Logging it out await expect(page).toClick("#lateralMenuButton"); + await new Promise(resolve => setTimeout(resolve, 6000)); await expect(page).toClick("button[data-testid='LogOut']"); }, 120000);