From 477d6be4e63a1751bec6eb7b51fa59760817387b Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Fri, 26 Apr 2024 17:06:28 +0200 Subject: [PATCH 1/2] Fix --- webapp/e2e/steps/play-battery.steps.js | 9 ++++----- webapp/e2e/steps/play-calculator.steps.js | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/webapp/e2e/steps/play-battery.steps.js b/webapp/e2e/steps/play-battery.steps.js index 40cbb338..6fcce1c1 100644 --- a/webapp/e2e/steps/play-battery.steps.js +++ b/webapp/e2e/steps/play-battery.steps.js @@ -15,8 +15,9 @@ defineFeature(feature, (test) => { : await puppeteer.launch({ headless: 'new', slowMo: 100 }); page = await browser.newPage(); setDefaultOptions({ timeout: 10000 }); - - await page.goto("http://localhost:3000", { + localStorage.setItem("username","testuser"); + localStorage.setItem("token","abcdefg"); + await page.goto("http://localhost:3000/home/bateria", { waitUntil: "networkidle0", }); await page.setRequestInterception(true); @@ -59,9 +60,7 @@ defineFeature(feature, (test) => { let firstquestion; test("The user can answer a question on Battery mode", ({ given, when, then }) => { given("A logged-in user", 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")]'); diff --git a/webapp/e2e/steps/play-calculator.steps.js b/webapp/e2e/steps/play-calculator.steps.js index 9d0637e5..a7322d9a 100644 --- a/webapp/e2e/steps/play-calculator.steps.js +++ b/webapp/e2e/steps/play-calculator.steps.js @@ -15,7 +15,8 @@ defineFeature(feature, (test) => { : await puppeteer.launch({ headless: "new", slowMo: 100 }); page = await browser.newPage(); setDefaultOptions({ timeout: 10000 }); - + localStorage.setItem("username","testuser"); + localStorage.setItem("token","abcdefg"); await page.goto("http://localhost:3000/home/calculadora", { waitUntil: "networkidle0", }); @@ -72,8 +73,6 @@ defineFeature(feature, (test) => { then, }) => { given("A logged-in user", async () => { - localStorage.setItem("username","testuser"); - localStorage.setItem("token","abcdefg"); await page.waitForTimeout(1000); await page.waitForXPath( From b1bc9c7dd8332153774451c21c90687938c616df Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Fri, 26 Apr 2024 17:14:01 +0200 Subject: [PATCH 2/2] A ver si asi colega --- webapp/e2e/steps/play-battery.steps.js | 6 ++++-- webapp/e2e/steps/play-calculator.steps.js | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/webapp/e2e/steps/play-battery.steps.js b/webapp/e2e/steps/play-battery.steps.js index 6fcce1c1..25d8412e 100644 --- a/webapp/e2e/steps/play-battery.steps.js +++ b/webapp/e2e/steps/play-battery.steps.js @@ -15,8 +15,10 @@ defineFeature(feature, (test) => { : await puppeteer.launch({ headless: 'new', slowMo: 100 }); page = await browser.newPage(); setDefaultOptions({ timeout: 10000 }); - localStorage.setItem("username","testuser"); - localStorage.setItem("token","abcdefg"); + await page.evaluate(() => { + localStorage.setItem("username","testuser"); + localStorage.setItem("token","abcdefg"); + }); await page.goto("http://localhost:3000/home/bateria", { waitUntil: "networkidle0", }); diff --git a/webapp/e2e/steps/play-calculator.steps.js b/webapp/e2e/steps/play-calculator.steps.js index a7322d9a..d5a59141 100644 --- a/webapp/e2e/steps/play-calculator.steps.js +++ b/webapp/e2e/steps/play-calculator.steps.js @@ -15,8 +15,11 @@ defineFeature(feature, (test) => { : await puppeteer.launch({ headless: "new", slowMo: 100 }); page = await browser.newPage(); setDefaultOptions({ timeout: 10000 }); - localStorage.setItem("username","testuser"); - localStorage.setItem("token","abcdefg"); + await page.evaluate(() => { + localStorage.setItem("username","testuser"); + localStorage.setItem("token","abcdefg"); + }); + await page.goto("http://localhost:3000/home/calculadora", { waitUntil: "networkidle0", });