diff --git a/webapp/e2e/features/historial-form.feature b/webapp/e2e/features/historial-form.feature deleted file mode 100644 index d890daff..00000000 --- a/webapp/e2e/features/historial-form.feature +++ /dev/null @@ -1,11 +0,0 @@ -Feature: Visible user logged history - -Scenario: The user is not logged in the site - Given A not logged user - When Press history - Then Redirected to login - -Scenario: The user register in the site so he can see history - Given A unregistered user, fill the register - When I press history - Then I see my history \ No newline at end of file diff --git a/webapp/e2e/steps/historial-form.steps.js b/webapp/e2e/steps/historial-form.steps.js deleted file mode 100644 index 0240a271..00000000 --- a/webapp/e2e/steps/historial-form.steps.js +++ /dev/null @@ -1,85 +0,0 @@ -const puppeteer = require('puppeteer'); -const { defineFeature, loadFeature }=require('jest-cucumber'); -const setDefaultOptions = require('expect-puppeteer').setDefaultOptions -const feature = loadFeature('./features/historial-form.feature'); - -let page; -let browser; - -defineFeature(feature, test => { - - let username = ""; - let password = ""; - - beforeAll(async () => { - browser = process.env.GITHUB_ACTIONS - ? await puppeteer.launch() - : await puppeteer.launch({ headless: false, slowMo: 100 }); - page = await browser.newPage(); - //Way of setting up the timeout - setDefaultOptions({ timeout: 10000 }) - - await page - .goto("http://localhost:3000/", { - waitUntil: "networkidle0", - }) - .catch(() => {}); - }); - - test('The user is not logged in the site', ({given,when,then}) => { - - given('A not logged user', async () => { - username = "pablo"; - password = "12345"; - }); - - when('Press history', async () => { - await page.goto("http://localhost:3000/getgamehistory", { - waitUntil: "networkidle0", - }).catch(() => {}); - }); - - then('Redirected to login', async () => { - await expect(page).toMatchElement('button[title="entrar"]'); - }); - },300000); - - - test('The user register in the site so he can see history', ({given,when,then}) => { - - - given('A unregistered user, fill the register', async () => { - await page.goto("http://localhost:3000/sign-up", { - waitUntil: "networkidle0", - }).catch(() => {}); - //Registrar al user - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - await expect(page).toClick('button[name="registrarsePage"]'); - await page.waitForNavigation({ - waitUntil: 'networkidle0' - }); - }); - - when('I press history', async () => { - await page.waitForSelector('[data-testid="historial-user"]', { - visible: true, - }); - await page.click('[data-testid="historial-user"]'); - }); - - then('I see my history', async () => { - await expect(page).toMatchElement('th', { text: 'Fecha'}); - await expect(page).toMatchElement('th', { text: 'Tiempo de partida'}); - await expect(page).toMatchElement('th', { text: 'Porcentaje de aciertos'}); - await expect(page).toMatchElement('th', { text: 'Número de preguntas'}); - await expect(page).toMatchElement('th', { text: 'Número de aciertos'}); - await expect(page).toMatchElement('th', { text: 'Número de fallos'}); - }); - },300000); - - afterAll(async ()=>{ - browser.close() - }) - -}); \ No newline at end of file diff --git a/webapp/e2e/test-environment-setup.js b/webapp/e2e/test-environment-setup.js index 35a53b11..7b7ed511 100644 --- a/webapp/e2e/test-environment-setup.js +++ b/webapp/e2e/test-environment-setup.js @@ -5,21 +5,15 @@ let mongoserver; let userservice; let authservice; let gatewayservice; -let questionservice; -let questionhistoryservice; async function startServer() { console.log('Starting MongoDB memory server...'); mongoserver = await MongoMemoryServer.create(); const mongoUri = mongoserver.getUri(); process.env.MONGODB_URI = mongoUri; - process.env.SECRET_KEY = '123456789'; - console.log(process.env.MONGODB_URI) userservice = await require("../../users/userservice/user-service"); authservice = await require("../../users/authservice/auth-service"); gatewayservice = await require("../../gatewayservice/gateway-service"); - questionservice = await require("../../questions/creationservice/creation-service"); - questionhistoryservice = await require("../../questions/retrieveservice/retrieve-service"); } startServer();