forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
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
3 changed files
with
68 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: Seeing the records table of a user | ||
|
||
Scenario: The authenticated user can see their records | ||
Given An authenticated user | ||
When I navigate to the records page | ||
Then I can see my records |
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,60 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature }=require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('./features/record-button.feature'); | ||
|
||
let page; | ||
let browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 20 }); | ||
page = await browser.newPage(); | ||
//Way of setting up the timeout | ||
setDefaultOptions({ timeout: 10000 }) | ||
|
||
await page | ||
.goto("http://localhost:3000", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => {}); | ||
}); | ||
|
||
test('The authenticated user can see their records', ({given, when, then}) => { | ||
let username; | ||
let password; | ||
|
||
given('An authenticated user', async () => { | ||
username = "record1"; | ||
password = "record1"; | ||
await expect(page).toClick('button', { text: 'SignUp' }); | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Add User' }); | ||
await expect(page).toClick('a', { text: 'Already have an account? Login here.' }); | ||
await expect(page).toClick('button', { text: 'Login' }); | ||
await expect(page).toFill('input[name="username"]', username); | ||
await expect(page).toFill('input[name="password"]', password); | ||
await expect(page).toClick('button', { text: 'Login' }); | ||
}); | ||
|
||
when('I navigate to the records page', async () => { | ||
await expect(page).toClick('button', { text: 'Ver historial' }); | ||
}); | ||
|
||
then('I can see my records', async () => { | ||
await expect(page).toMatchElement("th", { text: "Preguntas acertadas" }); | ||
await expect(page).toMatchElement("th", { text: "Nº preguntas" }); | ||
await expect(page).toMatchElement("th", { text: "Tiempo total" }); | ||
await expect(page).toMatchElement("th", { text: "Fecha" }); | ||
}); | ||
}); | ||
|
||
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