forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and update UI components and new test e2e
- Loading branch information
Showing
9 changed files
with
133 additions
and
56 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
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 created user | ||
|
||
Scenario: The user is registered in the site | ||
Given An user | ||
When I fill the data in the form and press submit | ||
Then The home page will appear |
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,66 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature } = require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('./features/login-form.feature'); | ||
|
||
|
||
let page; | ||
let browser; | ||
|
||
|
||
defineFeature(feature, test => { | ||
let username; | ||
let password; | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 10 }); | ||
|
||
page = await browser.newPage(); | ||
//Way of setting up the timeout | ||
setDefaultOptions({ timeout: 50000 }) | ||
|
||
await page | ||
.goto("http://localhost:3000/login", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => { }); | ||
username = "Prueba" | ||
password = "PruebaPSW" | ||
await expect(page).toClick("button", { text: "Don't have an account? Register here." }); | ||
await expect(page).toFill('input[name="name"]', 'Prueba'); | ||
await expect(page).toFill('input[name="surname"]', 'Prueba'); | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toFill('input[name="passwordRepeat"]', password); | ||
await expect(page).toClick("button", { text: "Registrarse" }); | ||
}); | ||
|
||
test('The user is registered in the site', ({ given, when, then }) => { | ||
|
||
given('An user', async () => { | ||
username = "Prueba" | ||
password = "PruebaPSW" | ||
}); | ||
|
||
when('I fill the data in the form and press submit', async () => { | ||
await page.waitForSelector('input[name="username"]'); | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await Promise.all([ | ||
page.click('button', { text: 'Login' }), | ||
page.waitForNavigation({ waitUntil: 'networkidle0' }), | ||
]); | ||
}); | ||
|
||
then('The home page will appear', async () => { | ||
await expect(page).toMatchElement("button", { text: "JUGAR" }); | ||
}); | ||
}) | ||
|
||
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
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
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
Oops, something went wrong.