From c9d49f245fcc0130fe1633e8198f7693ae0d39bc Mon Sep 17 00:00:00 2001 From: Lara Date: Tue, 30 Apr 2024 12:44:26 +0200 Subject: [PATCH] Prueba --- .github/workflows/build.yml | 2 ++ .github/workflows/release.yml | 40 ++++++++++----------- webapp/e2e/features/home.feature | 6 ---- webapp/e2e/steps/02-login.steps.js | 6 ++++ webapp/e2e/steps/03-home.steps.js | 57 ------------------------------ 5 files changed, 28 insertions(+), 83 deletions(-) delete mode 100644 webapp/e2e/features/home.feature delete mode 100644 webapp/e2e/steps/03-home.steps.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a15c313..3acc227 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,7 @@ on: - LaraFMz - Pablo-Arreglos - jota + - Larafm5 pull_request: types: [opened, synchronize, reopened] jobs: @@ -27,6 +28,7 @@ jobs: - run: npm --prefix gatewayservice test -- --coverage - run: npm --prefix questionservice test -- --coverage - run: npm --prefix webapp test -- --coverage + - run: npm --prefix webapp run test:e2e - name: Analyze with SonarCloud uses: sonarsource/sonarcloud-github-action@master env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 628c986..08718b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,28 +27,28 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -# e2e-tests: -# needs: [unit-tests] -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: actions/setup-node@v4 -# with: -# node-version: 20 -# - run: npm --prefix userservice/authservice install -# - run: npm --prefix userservice/userservice install -# - run: npm --prefix gatewayservice install -# - run: npm --prefix questionservice install -# - run: npm --prefix webapp install -# - run: npm --prefix webapp run build -# - run: npm --prefix webapp run test:e2e + e2e-tests: + needs: [unit-tests] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm --prefix userservice/authservice install + - run: npm --prefix userservice/userservice install + - run: npm --prefix gatewayservice install + - run: npm --prefix questionservice install + - run: npm --prefix webapp install + - run: npm --prefix webapp run build + - run: npm --prefix webapp run test:e2e docker-push-webapp: name: Push webapp Docker Image to GitHub Packages runs-on: ubuntu-latest permissions: contents: read packages: write -# needs: [e2e-tests] + needs: [e2e-tests] steps: - uses: actions/checkout@v4 - name: Publish to Registry @@ -68,7 +68,7 @@ jobs: permissions: contents: read packages: write -# needs: [e2e-tests] + needs: [e2e-tests] steps: - uses: actions/checkout@v4 - name: Publish to Registry @@ -85,7 +85,7 @@ jobs: permissions: contents: read packages: write -# needs: [e2e-tests] + needs: [e2e-tests] steps: - uses: actions/checkout@v4 - name: Publish to Registry @@ -102,7 +102,7 @@ jobs: permissions: contents: read packages: write -# needs: [e2e-tests] + needs: [e2e-tests] steps: - uses: actions/checkout@v4 - name: Update OpenAPI configuration @@ -123,7 +123,7 @@ jobs: permissions: contents: read packages: write -# needs: [e2e-tests] + needs: [e2e-tests] steps: - uses: actions/checkout@v4 - name: Publish to Registry diff --git a/webapp/e2e/features/home.feature b/webapp/e2e/features/home.feature deleted file mode 100644 index 8757b4a..0000000 --- a/webapp/e2e/features/home.feature +++ /dev/null @@ -1,6 +0,0 @@ -Feature: Access the app - -Scenario: A registered user enters the app - Given A user that is logged in the application - When I navigate to the Home page - Then I should be able to interact with the app \ No newline at end of file diff --git a/webapp/e2e/steps/02-login.steps.js b/webapp/e2e/steps/02-login.steps.js index 258aa60..94d4bbf 100644 --- a/webapp/e2e/steps/02-login.steps.js +++ b/webapp/e2e/steps/02-login.steps.js @@ -31,6 +31,12 @@ defineFeature(feature, test => { given('A user that is logged in the application', async () => { username = "pablo@gmail.com" password = "pabloasw1" + await expect(page).toClick("button", { text: "REGÍSTRATE" }); + await expect(page).toFill('input[name="username"]', username); + await expect(page).toFill('input[name="password"]', password); + await expect(page).toClick('button', { text: 'Crear' }) + await expect(page).toClick('a[href="/"]', { text: 'WIQ 5A' }); + await page.waitForNavigation(); await expect(page).toClick("button", { text: "INICIA SESIÓN" }); }); diff --git a/webapp/e2e/steps/03-home.steps.js b/webapp/e2e/steps/03-home.steps.js deleted file mode 100644 index 35cd730..0000000 --- a/webapp/e2e/steps/03-home.steps.js +++ /dev/null @@ -1,57 +0,0 @@ -const puppeteer = require('puppeteer'); -const { defineFeature, loadFeature }=require('jest-cucumber'); -const setDefaultOptions = require('expect-puppeteer').setDefaultOptions -const feature = loadFeature('./features/home.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(); - //Way of setting up the timeout - setDefaultOptions({ timeout: 10000 }) - - await page - .goto("http://localhost:3000", { - waitUntil: "networkidle0", - }) - .catch(() => {}); - }); - - test('A registered user enters the app', ({given,when,then}) => { - - let username; - let password; - - given('A user that is logged in the application', async () => { - username = "pablo@gmail.com" - password = "pabloasw1" - await expect(page).toClick("button", { text: "INICIA SESIÓN" }); - }); - - when('I navigate to the Home page', async () => { - await expect(page).toFill('input[name="username"]', username); - await expect(page).toFill('input[name="password"]', password); - await expect(page).toClick('button', { text: 'Iniciar Sesión' }) - - await expect(page).toClick('a[href="/"]', { text: 'WIQ 5A' }); - await page.waitForNavigation(); - - }); - - then('I should be able to interact with the app', async () => { - await expect(page).toMatchElement("button", { text: "JUGAR" }); - await expect(page).toMatchElement("button", { text: "ESTADÍSTICAS" }); - }); - }) - - afterAll(async ()=>{ - browser.close() - }) - -}); \ No newline at end of file