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.
- Loading branch information
Showing
2 changed files
with
63 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,6 @@ | ||
Feature: Access the app | ||
|
||
Scenario: A registered user enters the app | ||
Given An existing user | ||
When I navigate to the Home page | ||
Then I should be able to interact with the app |
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,57 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature }=require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('../features/home.feature'); | ||
|
||
let page; | ||
let browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 100 }); | ||
page = await browser.newPage(); | ||
//Way of setting up the timeout | ||
setDefaultOptions({ timeout: 10000 }) | ||
|
||
await page | ||
.goto("http://localhost:3000", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => {}); | ||
}); | ||
|
||
test('A registered user enters the app', ({given,when,then}) => { | ||
|
||
let username; | ||
let password; | ||
|
||
given('An existing user', async () => { | ||
username = "pablo" | ||
password = "pabloasw" | ||
await expect(page).toClick("button", { text: "INICIA SESIÓN" }); | ||
}); | ||
|
||
when('I navigate to the Home page', async () => { | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Login' }) | ||
|
||
await expect(page).toClick('a[href="/"]', { text: 'WIQ 5A' }); | ||
await page.waitForNavigation(); | ||
|
||
}); | ||
|
||
then('I should be able to interact with the app', async () => { | ||
await expect(page).toMatchElement("button", { text: "JUGAR" }); | ||
await expect(page).toMatchElement("button", { text: "ESTADÍSTICAS" }); | ||
}); | ||
}) | ||
|
||
afterAll(async ()=>{ | ||
browser.close() | ||
}) | ||
|
||
}); |