diff --git a/webapp/e2e/features/buyProduct.feature b/webapp/e2e/features/buyProduct.feature index 6600c0f..2978fda 100644 --- a/webapp/e2e/features/buyProduct.feature +++ b/webapp/e2e/features/buyProduct.feature @@ -1,6 +1,6 @@ Feature: Buy a product Scenario: The user is registered in the site - Given An registered user + Given A registered user When I select a certain product and add it to the shopping cart and click in the buy product button and fill the payment form Then The product should be add to the my shipments menu \ No newline at end of file diff --git a/webapp/e2e/steps/buyProduct.steps.ts b/webapp/e2e/steps/buyProduct.steps.ts index 9e714c3..f835306 100644 --- a/webapp/e2e/steps/buyProduct.steps.ts +++ b/webapp/e2e/steps/buyProduct.steps.ts @@ -1,7 +1,7 @@ import { defineFeature, loadFeature } from 'jest-cucumber'; import puppeteer from "puppeteer"; -const feature = loadFeature('./features/login.feature'); +const feature = loadFeature('./features/buyProduct.feature'); let page: puppeteer.Page; let browser: puppeteer.Browser; @@ -26,19 +26,23 @@ defineFeature(feature, test => { let user:string; let password:string; - + let card:string; + let expDate:string; + let cvc:string; given('A registered user', () => { user = "UO263611"; password = "EnolDede5c"; - + card = "12340"; + expDate = "02/24"; + cvc = "123"; }); - when('I log in to my pod', async () => { + when('I select a certain product and add it to the shopping cart and click in the buy product button and fill the payment form', async () => { await page.setViewport({width: 1200, height: 1300}); await page .goto("http://localhost:3000/login", { waitUntil: "networkidle0", - }); + }) await page.waitForTimeout(2000); await expect(page).toMatch("Login"); await expect(page).toClick('button', {text: 'Login'}); @@ -46,16 +50,35 @@ defineFeature(feature, test => { await expect(page).toFill("input[name='username']", user); await expect(page).toFill("input[name='password']", password); await expect(page).toClick('button', {text: 'Log In'}); - }); - - then('I am redirected to home and then i can see the logout button', async () => { await page.waitForTimeout(2000); - await expect(page).toMatch('Nike Blazer'); - await page.goto("http://localhost:3000/perfil", {waitUntil: "networkidle0"}).catch(() => {}); - await expect(page).toMatch("Logout"); + await page + .goto("http://localhost:3000/product/Nike%20Blazer%20blancas", { + waitUntil: "networkidle0", + }).catch(() => {}); + await page.waitForTimeout(2000); + await expect(page).toClick('button', {text: '34'}); + await expect(page).toClick('button', {text: 'Añadir al carrito'}); + await page + .goto("http://localhost:3000/carrito", { + waitUntil: "networkidle0", + }).catch(() => {}); await page.waitForTimeout(2000); - //await expect(page).toMatch('Enol'); - //await expect(page).toMatch('España Asturias Localidad 1234 Calle'); + await expect(page).toClick('button', {text: 'Comprar'}); + await page.waitForTimeout(5000); + await expect(page).toFill("input[name='cardNumber']", card); + await expect(page).toFill("input[name='expDate']", expDate); + await expect(page).toFill("input[name='cvc']", cvc); + await page.waitForTimeout(10000); + await expect(page).toClick('button', {text: 'Pagar'}); + await page.waitForTimeout(10000); + }); + + then('The product should be add to the my shipments menu', async () => { + await page.goto("http://localhost:3000/pedidos", {waitUntil: "networkidle0"}).catch(() => {}); + await page.waitForTimeout(5000); + await expect(page).toClick('button', {text: 'Actualizar'}); + await page.waitForTimeout(5000); + await expect(page).toMatch('enol1999@email.com'); }); }) diff --git a/webapp/e2e/steps/loginsteps.ts b/webapp/e2e/steps/loginsteps.ts index 87d8eb9..4a4de46 100644 --- a/webapp/e2e/steps/loginsteps.ts +++ b/webapp/e2e/steps/loginsteps.ts @@ -50,7 +50,7 @@ defineFeature(feature, test => { then('I am redirected to home and then i can see the logout button', async () => { await page.waitForTimeout(2000); - await expect(page).toMatch('Nike Blazer'); + await expect(page).toMatch('Nike Blazer blancas'); await page.goto("http://localhost:3000/perfil", {waitUntil: "networkidle0"}).catch(() => {}); await expect(page).toMatch("Logout"); await page.waitForTimeout(2000); diff --git a/webapp/src/components/PaymentForm.tsx b/webapp/src/components/PaymentForm.tsx index 93219f4..a7f9413 100644 --- a/webapp/src/components/PaymentForm.tsx +++ b/webapp/src/components/PaymentForm.tsx @@ -183,25 +183,28 @@ function PaymentForm() {