Skip to content

Commit

Permalink
Merge branch 'develop' into Valentin_Interfaz2
Browse files Browse the repository at this point in the history
  • Loading branch information
valydumitru01 committed May 1, 2022
2 parents eee22d3 + e5dcbbe commit 6e7d60d
Show file tree
Hide file tree
Showing 26 changed files with 970 additions and 185 deletions.
14 changes: 14 additions & 0 deletions webapp/e2e/features/login-form.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
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
28 changes: 26 additions & 2 deletions webapp/e2e/features/register-form.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,29 @@ 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 submit
Then A confirmation message should be shown in the screen
When I fill the data in the form and press Regístrate
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)
96 changes: 96 additions & 0 deletions webapp/e2e/steps/login-form.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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("User Login", ({given,when,then}) => {
let email:string
let password:string

given("Email and password of a user", () => {
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' });
});

then("I should be redirected to the catalog", async () => {
await page.waitForNavigation()
await page.waitForTimeout(2000);
await expect(page).toMatch("Yeso");
});
});

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");
});
});
});
Loading

0 comments on commit 6e7d60d

Please sign in to comment.