Skip to content

Commit

Permalink
com login jugar reg
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago21112001 committed Apr 8, 2024
1 parent 8f25278 commit c52c091
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 89 deletions.
74 changes: 37 additions & 37 deletions webapp/e2e/steps/jugar-form.steps.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
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/jugar-form.feature');

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

defineFeature(feature, (test) => {
let username = "zohaib24";
let password = "zohaib1";
// let username = "zohaib24";
// let password = "zohaib1";

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
// //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"]');
// 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('User Initiates a Game', ({ given, when, then }) => {

given('a registered user exists', async () => {
await expect(page).toMatchElement('button[name="entrarPage"]');
// await expect(page).toMatchElement('button[name="entrarPage"]');
});

when('the user enters their details on the login form and submits', 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('the user clicks the "Play" button on the homepage', async () => {
await expect(page).toClick('button', { text: 'JUGAR' })
// await expect(page).toClick('button', { text: 'JUGAR' })
});

then('the questions should be displayed', async () => {
await expect(page).toMatchElement('.quiz-header');
// await expect(page).toMatchElement('.quiz-header');

// Recuperar y verificar el texto de la pregunta actual
const questionText = await page.$eval('.quiz-header h2', el => el.textContent);
expect(questionText).toBeTruthy();
// // Recuperar y verificar el texto de la pregunta actual
// const questionText = await page.$eval('.quiz-header h2', el => el.textContent);
// expect(questionText).toBeTruthy();

// Opcionalmente, puedes verificar el número de la pregunta actual vs. el total
const questionIndicatorText = await page.$eval('.quiz-header div', el => el.textContent);
expect(questionIndicatorText).toMatch(/Pregunta \d+ de \d+/);
// // Opcionalmente, puedes verificar el número de la pregunta actual vs. el total
// const questionIndicatorText = await page.$eval('.quiz-header div', el => el.textContent);
// expect(questionIndicatorText).toMatch(/Pregunta \d+ de \d+/);

// Verificar que las opciones de respuesta se muestran
const answersCount = await page.$$eval('.answers-list li', answers => answers.length);
expect(answersCount).toBe(4);
// // Verificar que las opciones de respuesta se muestran
// const answersCount = await page.$$eval('.answers-list li', answers => answers.length);
// expect(answersCount).toBe(4);

});

},300000);

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

});
54 changes: 27 additions & 27 deletions webapp/e2e/steps/login-form.steps.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
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/login-form.feature');

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

defineFeature(feature, test => {

let username = "santiago24"
let password = "santiago1"
// let username = "santiago24"
// let password = "santiago1"

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
// //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"]');
// 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 registered in the site', ({given,when,then}) => {

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

when('Presses submit', async () => {
await expect(page).toClick('button[name="entrarPage"]');
// await expect(page).toClick('button[name="entrarPage"]');
});


then('The user is redirected', async () => {
await expect(page).toMatchElement("p", { text: "¿A que estás esperando?" });
// await expect(page).toMatchElement("p", { text: "¿A que estás esperando?" });
});
},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 c52c091

Please sign in to comment.