Skip to content

Commit

Permalink
Merge pull request #142 from Arquisoft/enol_tests
Browse files Browse the repository at this point in the history
Merge con cambios en los test y nuevo test e2e de comprar además de eliminar boton de logout
  • Loading branch information
nataliariego authored May 4, 2022
2 parents 921c757 + 672c8bd commit 1ef285a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 28 deletions.
2 changes: 1 addition & 1 deletion webapp/e2e/features/buyProduct.feature
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
49 changes: 36 additions & 13 deletions webapp/e2e/steps/buyProduct.steps.ts
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;
Expand All @@ -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]');
});
})

Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/steps/loginsteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 14 additions & 11 deletions webapp/src/components/PaymentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,28 @@ function PaymentForm() {
<div>
<h6>Número de tarjeta</h6>
<div>
<div> <label ><input type="text" className="form-control" placeholder=" " /></label> </div>
<h6>Número de tarjeta</h6>
<div>
<div> <label ><input type="text" name="cardNumber" className="form-control" placeholder=" " /></label> </div>
</div>
</div>
</div>

<hr />
<hr />

<div>
<h6>Fecha en formato MM/YY</h6>
<div>
<div> <label ><input type="text" className="form-control" placeholder=" " /></label> </div>
<h6>Fecha en formato MM/YY</h6>
<div>
<div> <label ><input type="text" name="expDate" className="form-control" placeholder=" " /></label> </div>
</div>
</div>
</div>

<hr />
<hr />

<div>
<h6>Código de seguridad</h6>
<div>
<div> <label ><input type="text" className="form-control" placeholder=" " /></label> </div>
<h6>Código de seguridad</h6>
<div>
<div> <label ><input type="text" name="cvc" className="form-control" placeholder=" " /></label> </div>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/UserDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ async function retrievePODAddress(webID: string): Promise<string> {
</CardActionArea>
</Card>
</CombinedDataProvider>
<LogoutButton >
{/*}<LogoutButton >
<Button style={{ marginTop: 20 }} variant="contained" color="primary">
Logout
</Button>
</LogoutButton>
</LogoutButton> {*/}
</Container>


Expand Down

0 comments on commit 1ef285a

Please sign in to comment.