generated from Arquisoft/dede_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from Arquisoft/enol_tests
Merge con cambios en los test y nuevo test e2e de comprar además de eliminar boton de logout
- Loading branch information
Showing
5 changed files
with
54 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,36 +26,59 @@ 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'}); | ||
await page.waitForNavigation(); | ||
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('[email protected]'); | ||
}); | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters