Skip to content

Commit

Permalink
A ver si ye de esta
Browse files Browse the repository at this point in the history
  • Loading branch information
iyanfdezz committed Apr 26, 2024
1 parent 3d67a8e commit 383141a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 26 deletions.
20 changes: 9 additions & 11 deletions webapp/e2e/steps/play-battery.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,9 @@ defineFeature(feature, (test) => {
let firstquestion;
test("The user can answer a question on Battery mode", ({ given, when, then }) => {
given("A logged-in user", async () => {
username = "testuser";
password = "Testpassword1";
await page.waitForSelector("#login-username");
await page.type("#login-username", username);
await page.waitForSelector("#login-password");
await page.type("#login-password", password);
await page.click("button", { text: "Login" });
//await page.waitForNavigation({ waitUntil: "networkidle0" });
});

when("I play on Battery mode and click on an answer", async () => {
localStorage.setItem("username","testuser");
localStorage.setItem("token","abcdefg");

await page.waitForTimeout(1000);
await page.waitForXPath('//button[contains(text(), "Batería de sabios")]');
const button = await page.$x('//button[contains(text(), "Batería de sabios")]');
Expand All @@ -80,6 +72,12 @@ defineFeature(feature, (test) => {
const jugarButton = await page.$x('//section[contains(@class, "chakra-modal__content")]//button[contains(text(), "Jugar")]');
await jugarButton[0].click();

//await page.waitForNavigation({ waitUntil: "networkidle0" });
});

when("I play on Battery mode and click on an answer", async () => {


await page.waitForSelector('[data-testid="question"]');

firstquestion = await page.evaluate(element =>
Expand Down
56 changes: 41 additions & 15 deletions webapp/e2e/steps/play-calculator.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defineFeature(feature, (test) => {
page = await browser.newPage();
setDefaultOptions({ timeout: 10000 });

await page.goto("http://localhost:3000", {
await page.goto("http://localhost:3000/home/calculadora", {
waitUntil: "networkidle0",
});

Expand All @@ -31,31 +31,50 @@ defineFeature(feature, (test) => {
"Access-Control-Allow-Headers": "*",
},
});
} else if (req.url().includes("/questions")) {
req.respond({
status: 200,
headers: {
"Access-Control-Allow-Origin": "*",
},
contentType: "application/json",
body: JSON.stringify([
{
pregunta: "Test question",
respuestas: [
"Test answer 1",
"Test answer 2",
"Test answer 3",
"Test correct answer",
],
correcta: "Test correct answer",
},
{
pregunta: "Test question 2",
respuestas: [
"Test answer 1",
"Test answer 2",
"Test answer 3",
"Test correct answer",
],
correcta: "Test correct answer",
},
]),
});
} else {
req.continue();
}
});
});
let username;
let password;
test("The user can answer a question on Human Calculator mode", ({
given,
when,
then,
}) => {
given("A logged-in user", async () => {
username = "testuser";
password = "Testpassword1";
await page.waitForSelector("#login-username");
await page.type("#login-username", username);
await page.waitForSelector("#login-password");
await page.type("#login-password", password);
await page.click("button", { text: "Login" });

//await page.waitForNavigation({ waitUntil: "networkidle0" });
});
localStorage.setItem("username","testuser");
localStorage.setItem("token","abcdefg");

when("I play on Human Calculator mode and answer incorrectly", async () => {
await page.waitForTimeout(1000);
await page.waitForXPath(
'//button[contains(text(), "Calculadora humana")]'
Expand All @@ -64,7 +83,6 @@ defineFeature(feature, (test) => {
'//button[contains(text(), "Calculadora humana")]'
);
await button[0].click();
//await page.waitForNavigation({ waitUntil: "networkidle0" });

await page.waitForXPath(
'//section[contains(@class, "chakra-modal__content")]//button[contains(text(), "Jugar")]'
Expand All @@ -73,6 +91,14 @@ defineFeature(feature, (test) => {
'//section[contains(@class, "chakra-modal__content")]//button[contains(text(), "Jugar")]'
);
await jugarButton[0].click();
//await page.waitForNavigation({ waitUntil: "networkidle0" });
});

when("I play on Human Calculator mode and answer incorrectly", async () => {

//await page.waitForNavigation({ waitUntil: "networkidle0" });


await page.waitForSelector('[data-testid="operation"]');

const answer = -999;
Expand Down

0 comments on commit 383141a

Please sign in to comment.