Skip to content

Commit

Permalink
Merge pull request #203 from Arquisoft/Adrian-Develop
Browse files Browse the repository at this point in the history
Test End2End (Registro, Login y Perfil de usuario) y Hotfixes añadidos
  • Loading branch information
Tora-U00F1-o authored May 1, 2022
2 parents f871313 + 8790dea commit e5dcbbe
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 5 deletions.
10 changes: 9 additions & 1 deletion webapp/e2e/features/login-form.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ Feature: Login a user on the web page
Scenario: The user log in
Given Email and password of a user
When I click in Iniciar Sesión
Then I should be redirected to the catalog
Then I should be redirected to the catalog
Scenario: User log in blank email
Given Blank Email and password of a user
When I click in Iniciar Sesión
Then Warning message below Email
Scenario: User log in blank password
Given Email and blank password of a user
When I click in Iniciar Sesión
Then Warning message below Password
6 changes: 6 additions & 0 deletions webapp/e2e/features/orders-form.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Seeing orders history of a user

Scenario: Orders of user "admin"
Given Registered user admin
When Log In and click on my profile
Then I should see my orders
26 changes: 25 additions & 1 deletion webapp/e2e/features/register-form.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,28 @@ Feature: Registering a new user
Scenario: The user is not registered in the site
Given An unregistered user
When I fill the data in the form and press Regístrate
Then I should be redirected to Login Page
Then I should be redirected to Login Page
Scenario: User Register blank email
Given Name, Dni, Password and confirmPassword of a user
When I fill the data in the form and press Regístrate
Then Warning below email
Scenario: User Register blank name
Given Email, Dni, Password and confirmPassword of a user
When I fill the data in the form and press Regístrate
Then Warning below name
Scenario: User Register blank dni
Given Name, Email, Password and confirmPassword of a user
When I fill the data in the form and press Regístrate
Then Warning below dni
Scenario: User Register blank password
Given Name, Dni, Email and confirmPassword of a user
When I fill the data in the form and press Regístrate
Then Warning below Password
Scenario: User Register blank confirmPassword
Given Name, Dni, Password and Email of a user
When I fill the data in the form and press Regístrate
Then Warning below confirmPassword
Scenario: Password and Confirm Password don't match
Given Email, Name, Dni, Password and confirmPassword of a user
When I fill the data in the form and press Regístrate
Then Warning below confirmPassword (Las contraseñas no coinciden)
45 changes: 45 additions & 0 deletions webapp/e2e/steps/login-form.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,49 @@ defineFeature(feature, test => {
});
});

test("User Login", ({given,when,then}) => {
let email:string
let password:string

given("Blank Email and password of a user", () => {
email = " "
password = "admin"
});

when("I click in Iniciar Sesion", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/login']");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='password']", password);
await expect(page).toClick('button', { text: 'Iniciar Sesión' });
});

then("Warning below email", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});
test("User Login", ({given,when,then}) => {
let email:string
let password:string

given("Email and blank password of a user", () => {
email = "[email protected]"
password = " "
});

when("I click in Iniciar Sesion", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/login']");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='password']", password);
await expect(page).toClick('button', { text: 'Iniciar Sesión' });
});

then("Warning below password", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});

});
56 changes: 56 additions & 0 deletions webapp/e2e/steps/orders-form.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { defineFeature, loadFeature } from 'jest-cucumber';
import puppeteer from "puppeteer";

const feature = loadFeature('./features/login.feature');

let page: puppeteer.Page;
let browser: puppeteer.Browser;

defineFeature(feature, test => {

jest.setTimeout(100000)
beforeAll(async () => {

browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: true, slowMo:100}); //false to run tests locally
page = await browser.newPage();

await page
.goto("http://localhost:3000", {
waitUntil: "networkidle0",
})
.catch(() => {});
});

test("Orders in profile", ({given,when,then}) => {
let email:string
let password:string

given("Admin session", () => {
email = "[email protected]"
password = "admin"
});

when("I click in Iniciar Sesion", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/login']");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='password']", password);
await expect(page).toClick('button', { text: 'Iniciar Sesión' });
await page.waitForNavigation()
await page.waitForTimeout(2000);
await expect(page).toMatch("Yeso");
await expect(page).toClick("a[href='/orders']");


});

then("I should see admin order's history", async () => {
await page.waitForNavigation()
await page.waitForTimeout(2000);
await expect(page).toMatch("Cuarcita");
});
});
});
194 changes: 193 additions & 1 deletion webapp/e2e/steps/register-form.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,199 @@ defineFeature(feature, test => {
then("I should be redirected to the login page", async () => {
await page.waitForNavigation()
await page.waitForTimeout(2000);
await expect(page).toMatch("Entrar en Sesión");
await expect(page).toMatch("Iniciar Sesión");
});
});
test("User Register blank email", ({given,when,then}) => {
let email:string
let name:string
let dni:string
let password:string
let confirmPassword:string

given("Name, Dni, Password and confirmPassword of a user", () => {
email = ""
name = "Adri"
dni = "12345678"
password = "adri"
confirmPassword = "adri"
});

when("I click in Regístrate", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/register']");
await expect(page).toMatch("Crear cuenta");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='name']", name);
await expect(page).toFill("input[name='dni']", dni);
await expect(page).toFill("input[name='password']", password);
await expect(page).toFill("input[name='confirmPassword']", confirmPassword);
await expect(page).toClick('button', { text: 'Regístrate' });
});

then("Warning below email", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});
test("User Register blank name", ({given,when,then}) => {
let email:string
let name:string
let dni:string
let password:string
let confirmPassword:string

given("Email, Dni, Password and confirmPassword of a user", () => {
email = "[email protected]"
name = ""
dni = "12345678"
password = "adri"
confirmPassword = "adri"
});

when("I click in Regístrate", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/register']");
await expect(page).toMatch("Crear cuenta");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='name']", name);
await expect(page).toFill("input[name='dni']", dni);
await expect(page).toFill("input[name='password']", password);
await expect(page).toFill("input[name='confirmPassword']", confirmPassword);
await expect(page).toClick('button', { text: 'Regístrate' });
});

then("Warning below name", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});
test("User Register blank dni", ({given,when,then}) => {
let email:string
let name:string
let dni:string
let password:string
let confirmPassword:string

given("Email, Name, Password and confirmPassword of a user", () => {
email = "[email protected]"
name = "Adri"
dni = ""
password = "adri"
confirmPassword = "adri"
});

when("I click in Regístrate", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/register']");
await expect(page).toMatch("Crear cuenta");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='name']", name);
await expect(page).toFill("input[name='dni']", dni);
await expect(page).toFill("input[name='password']", password);
await expect(page).toFill("input[name='confirmPassword']", confirmPassword);
await expect(page).toClick('button', { text: 'Regístrate' });
});

then("Warning below dni", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});
test("User Register blank password", ({given,when,then}) => {
let email:string
let name:string
let dni:string
let password:string
let confirmPassword:string

given("Email, Name, Dni and confirmPassword of a user", () => {
email = "[email protected]"
name = "Adri"
dni = "123456"
password = ""
confirmPassword = "adri"
});

when("I click in Regístrate", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/register']");
await expect(page).toMatch("Crear cuenta");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='name']", name);
await expect(page).toFill("input[name='dni']", dni);
await expect(page).toFill("input[name='password']", password);
await expect(page).toFill("input[name='confirmPassword']", confirmPassword);
await expect(page).toClick('button', { text: 'Regístrate' });
});

then("Warning below password", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});
test("User Register blank confirm password", ({given,when,then}) => {
let email:string
let name:string
let dni:string
let password:string
let confirmPassword:string

given("Email, Name, Dni Password of a user", () => {
email = "[email protected]"
name = "Adri"
dni = "123456"
password = "adri"
confirmPassword = ""
});

when("I click in Regístrate", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/register']");
await expect(page).toMatch("Crear cuenta");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='name']", name);
await expect(page).toFill("input[name='dni']", dni);
await expect(page).toFill("input[name='password']", password);
await expect(page).toFill("input[name='confirmPassword']", confirmPassword);
await expect(page).toClick('button', { text: 'Regístrate' });
});

then("Warning below confirmPassword", async () => {
await expect(page).toMatch("El campo no puede estar vacio");
});
});
test("Confirm Password and Password don't match", ({given,when,then}) => {
let email:string
let name:string
let dni:string
let password:string
let confirmPassword:string

given("Email, Name, Dni Password of a user", () => {
email = "[email protected]"
name = "Adri"
dni = "123456"
password = "adri"
confirmPassword = "manuel"
});

when("I click in Regístrate", async () => {
await page.setViewport({ width: 1200, height: 1300 });
await expect(page).toMatch("Sedimentarias");
await expect(page).toClick("a[href='/register']");
await expect(page).toMatch("Crear cuenta");
await expect(page).toFill("input[name='email']", email);
await expect(page).toFill("input[name='name']", name);
await expect(page).toFill("input[name='dni']", dni);
await expect(page).toFill("input[name='password']", password);
await expect(page).toFill("input[name='confirmPassword']", confirmPassword);
await expect(page).toClick('button', { text: 'Regístrate' });
});

then("Warning below confirmPassword", async () => {
await expect(page).toMatch("Las contraseñas no coinciden");
});
});
});
2 changes: 1 addition & 1 deletion webapp/src/components/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import axios from 'axios';
import { Grid, Link, Typography } from '@mui/material';

const checkParams = (text: String) => {
return text === "" || text == null;
return text.trim() === "" || text == null;
}

type EmailFormProps = {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type NotificationType = {
};

const checkParams = (text: String) => {
return text === "" || text == null;
return text.trim() === "" || text == null;
};

const checkPaswwords = (repPass: String, pass: String) => {
Expand Down

0 comments on commit e5dcbbe

Please sign in to comment.