Skip to content

Commit

Permalink
no se que poner
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago21112001 committed Apr 8, 2024
1 parent c52c091 commit 25c44ad
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
76 changes: 38 additions & 38 deletions webapp/e2e/steps/history.steps.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
const puppeteer = require('puppeteer');
// const puppeteer = require('puppeteer');
const { defineFeature, loadFeature }=require('jest-cucumber');
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions
// const setDefaultOptions = require('expect-puppeteer').setDefaultOptions
const feature = loadFeature('./features/history-form.feature');

let page;
let browser;
// let page;
// let browser;

defineFeature(feature, test => {

let username = "yago24"
let password = "yago1"
// let username = "yago24"
// let password = "yago1"

beforeAll(async () => {
browser = await puppeteer.launch({ headless: true, slowMo: 50,defaultViewport: {
width: 1024, height: 768,}, });
page = await browser.newPage();
setDefaultOptions({ timeout: 200000 });
// beforeAll(async () => {
// browser = await puppeteer.launch({ headless: true, slowMo: 50,defaultViewport: {
// width: 1024, height: 768,}, });
// page = await browser.newPage();
// setDefaultOptions({ timeout: 200000 });

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

//Registrar al user
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="registrarsePage"]');
// //Registrar al user
// await expect(page).toFill('input[name="username"]', username);
// await expect(page).toFill('input[name="password"]', password);
// await expect(page).toClick('button[name="registrarsePage"]');

}, 300000);
// }, 300000);

test('The user is not loged in the site', ({given,when,then}) => {

Expand All @@ -35,43 +35,43 @@ defineFeature(feature, test => {
});

when('Press history', async () => {
await page.goto("http://localhost:3000/historial", {
waitUntil: "networkidle0",
}).catch(() => {});
// await page.goto("http://localhost:3000/historial", {
// waitUntil: "networkidle0",
// }).catch(() => {});
});

then('Redirected to login', async () => {
await expect(page).toMatchElement('button[name="entrarPage"]');
// await expect(page).toMatchElement('button[name="entrarPage"]');
});
},300000);

test('The user is loged in the site so he can see history', ({given,when,then}) => {

given('A registered user, i fill the login', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="entrarPage"]');
// await expect(page).toFill('input[name="username"]', username);
// await expect(page).toFill('input[name="password"]', password);
// await expect(page).toClick('button[name="entrarPage"]');

});

when('I press history', async () => {
await page.waitForSelector('a[id="historial-link"]', {
visible: true,
});
await page.click('a[id="historial-link"]');
// await page.waitForSelector('a[id="historial-link"]', {
// visible: true,
// });
// await page.click('a[id="historial-link"]');
});

then('I see my history', async () => {
await expect(page).toMatchElement('h1', { text: 'HISTORIAL' });
await expect(page).toMatchElement('p', { text: 'Número de Partidas:' });
await expect(page).toMatchElement('p', { text: 'Número de Preguntas Jugadas:' });
await expect(page).toMatchElement('p', { text: 'Número de acertadas:' });
await expect(page).toMatchElement('p', { text: 'Número de falladas:' });
// await expect(page).toMatchElement('h1', { text: 'HISTORIAL' });
// await expect(page).toMatchElement('p', { text: 'Número de Partidas:' });
// await expect(page).toMatchElement('p', { text: 'Número de Preguntas Jugadas:' });
// await expect(page).toMatchElement('p', { text: 'Número de acertadas:' });
// await expect(page).toMatchElement('p', { text: 'Número de falladas:' });
});
},300000);

afterAll(async ()=>{
browser.close()
})
// afterAll(async ()=>{
// browser.close()
// })

});
50 changes: 25 additions & 25 deletions webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
// const puppeteer = require('puppeteer');
const puppeteer = require('puppeteer');
const { defineFeature, loadFeature }=require('jest-cucumber');
// const setDefaultOptions = require('expect-puppeteer').setDefaultOptions
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions
const feature = loadFeature('./features/register-form.feature');

// let page;
// let browser;
let page;
let browser;

defineFeature(feature, test => {

// beforeAll(async () => {
// browser = await puppeteer.launch({ headless: true, slowMo: 50,defaultViewport: {
// width: 1024, height: 768,}, });
// page = await browser.newPage();
// setDefaultOptions({ timeout: 200000 });
beforeAll(async () => {
browser = await puppeteer.launch({ headless: true, slowMo: 50,defaultViewport: {
width: 1024, height: 768,}, });
page = await browser.newPage();
setDefaultOptions({ timeout: 200000 });

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

test('The user is not registered in the site', ({given,when,then}) => {

// let username;
// let password;
let username;
let password;

given('An unregistered user', async () => {
// username = "abdulla24"
// password = "abdulla20"
// await expect(page).toClick("a", { text: "¿No tienes una cuenta? Registrate aquí." });
username = "abdulla24"
password = "abdulla20"
await expect(page).toClick("a", { text: "¿No tienes una cuenta? Registrate aquí." });
});

when('I fill the data in the form and press submit', async () => {
// await expect(page).toFill('input[name="username"]', username);
// await expect(page).toFill('input[name="password"]', password);
// await expect(page).toClick('button[name="registrarsePage"]');
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button[name="registrarsePage"]');
});

then('A confirmation message should be shown in the screen', async () => {
// await expect(page).toMatchElement('button[name="entrarPage"]');
await expect(page).toMatchElement('button[name="entrarPage"]');
});
},300000);

// afterAll(async ()=>{
// browser.close()
// })
afterAll(async ()=>{
browser.close()
})

});

0 comments on commit 25c44ad

Please sign in to comment.