diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0dd803c..152cd2b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,6 +43,13 @@ jobs: - run: npm --prefix questionservice install - run: npm --prefix gatewayservice install - run: npm --prefix webapp install + + - run: npm --prefix gatewayservice start + - run: npm --prefix questionservice start + - run: npm --prefix users/authservice start + - run: npm --prefix users/historyservice start + - run: npm --prefix users/userservice start + - run: npm --prefix webapp run build - run: npm --prefix webapp run test:e2e docker-push-webapp: diff --git a/users/historyservice/history-service.js b/users/historyservice/history-service.js index edd3360..74528f3 100644 --- a/users/historyservice/history-service.js +++ b/users/historyservice/history-service.js @@ -11,7 +11,7 @@ const port = 8004; app.use(bodyParser.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/historydb'; mongoose.connect(mongoUri); diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index 1b83340..ad0a6ca 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -12,7 +12,7 @@ const port = 8001; app.use(bodyParser.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/historydb'; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; mongoose.connect(mongoUri); diff --git a/webapp/e2e/steps/history.steps.js b/webapp/e2e/steps/history.steps.js index 35f43d8..b9eeb01 100644 --- a/webapp/e2e/steps/history.steps.js +++ b/webapp/e2e/steps/history.steps.js @@ -13,8 +13,8 @@ defineFeature(feature, test => { beforeAll(async () => { - browser = await puppeteer.launch({ headless: "new", slowMo: 50,defaultViewport: { - width: 1024, height: 768,}, }); + browser = await puppeteer.launch({ headless: "new", slowMo: 40,defaultViewport: { + width: 1024, height: 768,},}); page = await browser.newPage(); setDefaultOptions({ timeout: 200000 }); @@ -23,49 +23,49 @@ defineFeature(feature, test => { test('The user is not loged in the site', ({given,when,then}) => { given('A not loged user', async () => { - // username = "yago"; - // password = "Yagooooo1"; + username = "Avestrus1"; + password = "Avestrus1"; }); when('Press history', async () => { - // await page.goto("http://localhost:3000/historial", { - // waitUntil: "networkidle0", - // }).catch(() => {}); + await page.goto("http://localhost:3000/historial", { + waitUntil: "networkidle0", + }).catch(() => {}); }); then('Redirected to login', async () => { - // await expect(page).toMatchElement('button[name="entrarPage"]'); + await expect(page).toMatchElement('button[name="entrarPage"]'); }); },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' - // }); + 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-button-navbar"]', { - // visible: true, - // }); - // await page.click('[data-testid="historial-button-navbar"]'); + await page.waitForSelector('[data-testid="historial-button-navbar"]', { + visible: true, + }); + await page.click('[data-testid="historial-button-navbar"]'); }); then('I see my history', async () => { - // await expect(page).toMatchElement('h1', { text: 'HISTORIAL' }); - // await expect(page).toMatchElement('p', { text: 'Número de Partidas: 0' }); - // await expect(page).toMatchElement('p', { text: 'Número de Preguntas Jugadas: 0' }); - // await expect(page).toMatchElement('p', { text: 'Número de acertadas: 0' }); - // await expect(page).toMatchElement('p', { text: 'Número de falladas: 0' }); + await expect(page).toMatchElement('h1', { text: 'HISTORIAL' }); + await expect(page).toMatchElement('p', { text: 'Número de Partidas: 0' }); + await expect(page).toMatchElement('p', { text: 'Número de Preguntas Jugadas: 0' }); + await expect(page).toMatchElement('p', { text: 'Número de acertadas: 0' }); + await expect(page).toMatchElement('p', { text: 'Número de falladas: 0' }); }); },300000); diff --git a/webapp/e2e/steps/jugar-form.steps.js b/webapp/e2e/steps/jugar-form.steps.js index ad9bcc5..31110e4 100644 --- a/webapp/e2e/steps/jugar-form.steps.js +++ b/webapp/e2e/steps/jugar-form.steps.js @@ -11,64 +11,54 @@ defineFeature(feature, (test) => { let password = ""; beforeAll(async () => { - browser = await puppeteer.launch({ - headless: "new", - slowMo: 50, - defaultViewport: { - width: 1024, - height: 768, - }, - }); + browser = await puppeteer.launch({ headless: "new", slowMo: 40,defaultViewport: { + width: 1024, height: 768,},}); page = await browser.newPage(); setDefaultOptions({ timeout: 200000 }); }, 300000); test('User Initiates a Game', ({ given, when,and, then }) => { given('An unregistered user exists', async () => { - // username = "Zohaib"; - // password = "Zohaib11"; + username = "Nasheeee1"; + password = "Nasheeee1"; }); when('the user enters their details on the register form and submits', async () => { - // await page.goto("http://localhost:3000/sign-up", { - // waitUntil: "networkidle0", - // }); - // 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' - // }); + await page.goto("http://localhost:3000/sign-up", { + waitUntil: "networkidle0", + }); + 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' + }); }); and('the user is redirected to the homepage and logged in automatically', async () => { - // // Utiliza data-testid para verificar la presencia de botones o enlaces - // const isLogoutLinkVisibleMobile = await page.$eval('[data-testid="Salir-button-navbar"]', el => el.textContent.includes('Salir')); - // const isLogoutButtonVisibleDesktop = await page.$('[data-testid="Salir-button-navbar-large"]') !== null; + // Utiliza data-testid para verificar la presencia de botones o enlaces + const isLogoutButtonVisibleDesktop = await page.$('[data-testid="Salir-button-navbar-large"]') !== null; - // // Afirmar que el enlace o botón "Salir" debe ser visible en al menos una de las versiones - // expect(isLogoutLinkVisibleMobile || isLogoutButtonVisibleDesktop).toBeTruthy(); + // Afirmar que el enlace o botón "Salir" debe ser visible en al menos una de las versiones + expect(isLogoutButtonVisibleDesktop).toBeTruthy(); }); and('the user clicks the "Play" button on the homepage', async () => { - // await expect(page).toClick('[data-testid="jugar-button-home"]'); - // await page.waitForNavigation({ - // waitUntil: 'networkidle0' - // }); + await expect(page).toClick('[data-testid="jugar-button-home"]'); }); then('the questions should be displayed', async () => { - // const questionText = await page.$eval('.quiz-header h2', el => el.textContent); - // expect(questionText).toBeTruthy(); + const questionText = await page.$eval('.quiz-header h2', el => el.textContent); + expect(questionText).toBeTruthy(); - // // // Opcionalmente, puedes verificar el número de la pregunta actual vs. el total - // const questionIndicatorText = await page.$eval('.quiz-header div', el => el.textContent); - // expect(questionIndicatorText).toMatch(/Pregunta \d+ de \d+/); + // // Opcionalmente, puedes verificar el número de la pregunta actual vs. el total + const questionIndicatorText = await page.$eval('.quiz-header div', el => el.textContent); + expect(questionIndicatorText).toMatch(/Pregunta \d+ de \d+/); - // // // Verificar que las opciones de respuesta se muestran - // const answersCount = await page.$$eval('.answers-list li', answers => answers.length); - // expect(answersCount).toBe(4); + // // Verificar que las opciones de respuesta se muestran + const answersCount = await page.$$eval('.answers-list li', answers => answers.length); + expect(answersCount).toBe(4); }); diff --git a/webapp/e2e/steps/register-form.steps.js b/webapp/e2e/steps/register-form.steps.js index 453f0fe..9b6636a 100644 --- a/webapp/e2e/steps/register-form.steps.js +++ b/webapp/e2e/steps/register-form.steps.js @@ -9,8 +9,8 @@ let browser; defineFeature(feature, test => { beforeAll(async () => { - browser = await puppeteer.launch({ headless: "new", slowMo: 50,defaultViewport: { - width: 1024, height: 768,}, }); + browser = await puppeteer.launch({ headless: "new", slowMo: 40,defaultViewport: { + width: 1024, height: 768,},}); page = await browser.newPage(); setDefaultOptions({ timeout: 200000 }); @@ -25,27 +25,26 @@ defineFeature(feature, test => { let password; given('An unregistered user', async () => { - // username = "santiago" - // password = "Santiago1" - // await expect(page).toClick("a", { text: "¿No tienes una cuenta? Registrate aquí." }); + username = "Vuamosss1" + password = "Vuamosss1" + await expect(page).toClick("a", { text: "¿No tienes una cuenta? Registrate aquí." }); }); when('I fill the data in the form and press submit', async () => { - // 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' - // }); + 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' + }); }); then('The user is registered and logged', async () => { // Utiliza data-testid para verificar la presencia de botones o enlaces - // const isLogoutLinkVisibleMobile = await page.$eval('[data-testid="Salir-button-navbar"]', el => el.textContent.includes('Salir')); - // const isLogoutButtonVisibleDesktop = await page.$('[data-testid="Salir-button-navbar-large"]') !== null; + const isLogoutButtonVisibleDesktop = await page.$('[data-testid="Salir-button-navbar-large"]') !== null; - // // Afirmar que el enlace o botón "Salir" debe ser visible en al menos una de las versiones - // expect(isLogoutLinkVisibleMobile || isLogoutButtonVisibleDesktop).toBeTruthy(); + // Afirmar que el enlace o botón "Salir" debe ser visible en al menos una de las versiones + expect(isLogoutButtonVisibleDesktop).toBeTruthy(); }); },300000);