generated 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.
Merge pull request #216 from Arquisoft/E2E-testing
Two new e2e tests working
- Loading branch information
Showing
7 changed files
with
141 additions
and
5 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,7 @@ | ||
Feature: Playing a normal game | ||
|
||
Scenario: Playing a normal game | ||
Given A registered user | ||
When I click the link to the normal game | ||
Then The app enters a normal game | ||
|
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,7 @@ | ||
Feature: Playing a trivia game | ||
|
||
Scenario: Playing a trivia game | ||
Given A registered user | ||
When I click the link to the trivia game | ||
Then The app enters a trivia game | ||
|
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,63 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature }=require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('./features/normal-game.feature'); | ||
const { registerUser } = require('../utils.js'); | ||
|
||
let page; | ||
let browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 40 }); | ||
page = await browser.newPage(); | ||
//Way of setting up the timeout | ||
setDefaultOptions({ timeout: 10000 }) | ||
|
||
await page | ||
.goto("http://localhost:3000", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => {}); | ||
|
||
await registerUser('test6', 'test6@gmail.com', 'test6', page); | ||
}); | ||
|
||
test('Playing a normal game', ({given,when,then}) => { | ||
|
||
let username; | ||
let password; | ||
|
||
given('A registered user', async () => { | ||
username = "test6" | ||
password = "test6" | ||
await expect(page).toFill('input[id="Username"]', username); | ||
await expect(page).toFill('input[id="password"]', password); | ||
await expect(page).toClick('button', { text: 'Log in' }); | ||
}); | ||
|
||
when('I click the link to the normal game', async () => { | ||
await expect(page).toMatchElement("#normalGame", { text: "Normal Game" }); | ||
await expect(page).toMatchElement("#triviaGame", { text: "Trivia Game" }); | ||
await expect(page).toClick('#normalGame'); | ||
}); | ||
|
||
then('The app enters a normal game', async () => { | ||
await expect(page).toMatchElement("text", { text: "1/10" }); | ||
}); | ||
}) | ||
|
||
afterEach(async () => { | ||
await page.evaluate(() => { | ||
localStorage.clear(); | ||
}); | ||
}); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const puppeteer = require('puppeteer'); | ||
const { defineFeature, loadFeature }=require('jest-cucumber'); | ||
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions | ||
const feature = loadFeature('./features/trivia-game.feature'); | ||
const { registerUser } = require('../utils.js'); | ||
|
||
let page; | ||
let browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
beforeAll(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: false, slowMo: 40 }); | ||
page = await browser.newPage(); | ||
//Way of setting up the timeout | ||
setDefaultOptions({ timeout: 10000 }) | ||
|
||
await page | ||
.goto("http://localhost:3000", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => {}); | ||
|
||
await registerUser('test7', 'test7@gmail.com', 'test7', page); | ||
}); | ||
|
||
test('Playing a trivia game', ({given,when,then}) => { | ||
|
||
let username; | ||
let password; | ||
|
||
given('A registered user', async () => { | ||
username = "test7" | ||
password = "test7" | ||
await expect(page).toFill('input[id="Username"]', username); | ||
await expect(page).toFill('input[id="password"]', password); | ||
await expect(page).toClick('button', { text: 'Log in' }); | ||
}); | ||
|
||
when('I click the link to the trivia game', async () => { | ||
await expect(page).toMatchElement("#normalGame", { text: "Normal Game" }); | ||
await expect(page).toMatchElement("#triviaGame", { text: "Trivia Game" }); | ||
await expect(page).toClick('#triviaGame'); | ||
}); | ||
|
||
then('The app enters a trivia game', async () => { | ||
await expect(page).toMatchElement("div", { id: "cajaQuesitos" }); | ||
}); | ||
}) | ||
|
||
afterEach(async () => { | ||
await page.evaluate(() => { | ||
localStorage.clear(); | ||
}); | ||
}); | ||
|
||
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