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.
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
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: Entering the leaderboard page | ||
|
||
Scenario: Entering the leaderboard page | ||
Given A registered user | ||
When I click the link to the leaderboard page | ||
Then The app shows the leaderboard page | ||
|
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/leaderboard.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('test5', 'test5@gmail.com', 'test5', page); | ||
}); | ||
|
||
test('Entering the leaderboard page', ({given,when,then}) => { | ||
|
||
let username; | ||
let password; | ||
let id; | ||
|
||
given('A registered user', async () => { | ||
username = "test5" | ||
password = "test5" | ||
id = "normalGame" | ||
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 leaderboard page', async () => { | ||
await expect(page).toMatchElement("#normalGame", { text: "Normal Game" }); | ||
await expect(page).toMatchElement("#triviaGame", { text: "Trivia Game" }); | ||
await expect(page).toMatchElement("#leaderboard", { text: "Leaderboard" }); | ||
await expect(page).toClick('#leaderboard'); | ||
}); | ||
|
||
then('The app shows the leaderboard page', async () => { | ||
await expect(page).toMatchElement("#leaderboardHeader", { text: "LEADERBOARD" }); | ||
}); | ||
}) | ||
|
||
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