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.
Test e2e para responder una pregunta mal en calculadora
- Loading branch information
Showing
6 changed files
with
98 additions
and
16 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: Answering a question | ||
|
||
Scenario: The user can answer a question on Human Calculator mode | ||
Given A logged-in user | ||
When I play on Human Calculator mode and answer incorrectly | ||
Then The game ends |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Feature: Answering a question | ||
|
||
Scenario: The user can answer a question | ||
Scenario: The user can answer a question on Classic mode | ||
Given A logged-in user | ||
When I play on Classic mode and click on an answer | ||
Then The right answer should be colored green |
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,65 @@ | ||
const puppeteer = require("puppeteer"); | ||
const { defineFeature, loadFeature } = require("jest-cucumber"); | ||
const setDefaultOptions = require("expect-puppeteer").setDefaultOptions; | ||
const { expect } = require("expect-puppeteer"); | ||
|
||
const feature = loadFeature("./features/play-calculator.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(); | ||
setDefaultOptions({ timeout: 10000 }); | ||
|
||
await page.goto("http://localhost:3000", { | ||
waitUntil: "networkidle0", | ||
}); | ||
}); | ||
|
||
test("The user can answer a question on Human Calculator mode", ({ given, when, then }) => { | ||
given("A logged-in user", async () => { | ||
|
||
await page.type("#login-username", "testuser"); | ||
await page.type("#login-password", "Testpassword1"); | ||
await page.click("button", { text: "Login" }); | ||
await page.waitForNavigation(); | ||
}); | ||
|
||
when("I play on Human Calculator mode and answer incorrectly", async () => { | ||
|
||
await page.click('[data-testid="calculator"]'); | ||
await page.waitForNavigation(); | ||
|
||
await page.waitForSelector('[data-testid="operation"]'); | ||
|
||
const operation = await page.evaluate(() => { | ||
return document.querySelector('[data-testid="operation"]').textContent; | ||
}); | ||
|
||
const answer = -1; | ||
|
||
await page.type('[data-testid="answer-input"]', answer.toString()); | ||
|
||
await page.click('[data-testid="submit-button"]'); | ||
}); | ||
|
||
then("The game ends", async () => { | ||
await page.waitForSelector('[data-testid="game-over"]'); | ||
|
||
const gameOverMessage = await page.evaluate(() => { | ||
return document.querySelector('[data-testid="game-over"]').textContent; | ||
}); | ||
|
||
expect(gameOverMessage).toContain("¡Juego terminado!"); | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
await 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