generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #46 from Arquisoft/yago
Añadido test e2e history y login
- Loading branch information
Showing
5 changed files
with
152 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Feature: Seeing the loged user history | ||
|
||
Scenario: The user is not loged in the site | ||
Given A not loged user | ||
When Press history | ||
Then Redirected to login | ||
|
||
Scenario: The user is loged in the site so he can see history | ||
Given A registered user, i fill the login | ||
When I press history | ||
Then I see my history |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Login a existing user | ||
|
||
Scenario: The user is registered in the site | ||
Given A registered user, fill the data | ||
When Presses submit | ||
Then The user is redirected |
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature }=require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('./features/register-form.feature'); | ||
|
||
let page; | ||
let browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
let username = "usuario" | ||
let password = "contraseña" | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 100 }); | ||
page = await browser.newPage(); | ||
setDefaultOptions({ timeout: 10000 }); | ||
|
||
await page.goto("http://localhost:3000/register", { | ||
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', { text: 'Registrarse' }); | ||
|
||
await page.goto("http://localhost:3000/", { | ||
waitUntil: "networkidle0", | ||
}).catch(() => {}); | ||
|
||
}, 60000); | ||
|
||
test('The user is not loged in the site', ({given,when,then}) => { | ||
|
||
given('A not loged user', async () => { | ||
|
||
}); | ||
|
||
when('Press history', async () => { | ||
await expect(page).toClick('button', { text: 'Historial' }); | ||
}); | ||
|
||
then('Redirected to login', async () => { | ||
await expect(page).toMatchElement('div', { text: 'Entrar' }); | ||
}); | ||
}) | ||
|
||
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 page.goto("http://localhost:3000/login", { | ||
waitUntil: "networkidle0", | ||
}).catch(() => {}); | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Entrar' }); | ||
}); | ||
|
||
when('I press history', async () => { | ||
await expect(page).toClick('button', { text: 'Historial' }); | ||
}); | ||
|
||
then('I see my history', async () => { | ||
await expect(page).toMatchElement('h1', { text: 'HISTORIAL' }); | ||
await expect(page).toMatch('Número de Partidas:'); | ||
await expect(page).toMatch('Número de Preguntas Jugadas:'); | ||
await expect(page).toMatch('Número de acertadas:'); | ||
await expect(page).toMatch('Número de falladas:'); | ||
}); | ||
}) | ||
|
||
afterAll(async ()=>{ | ||
browser.close() | ||
}) | ||
|
||
}); |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature }=require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('./features/register-form.feature'); | ||
|
||
let page; | ||
let browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
let username = "usuario" | ||
let password = "contraseña" | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 100 }); | ||
page = await browser.newPage(); | ||
setDefaultOptions({ timeout: 10000 }); | ||
|
||
await page.goto("http://localhost:3000/register", { | ||
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', { text: 'Registrarse' }) | ||
|
||
}, 60000); | ||
|
||
test('The user is registered in the site', ({given,when,then}) => { | ||
|
||
given('A registered user, fill the data', async () => { | ||
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', { text: 'Entrar' }); | ||
}); | ||
|
||
|
||
then('The user is redirected', async () => { | ||
await expect(page).toMatchElement("div", { text: "Inicio de sesión exitoso" }); | ||
}); | ||
}) | ||
|
||
afterAll(async ()=>{ | ||
browser.close() | ||
}) | ||
|
||
}); |
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