Skip to content

Commit

Permalink
Merge pull request #315 from Arquisoft/test
Browse files Browse the repository at this point in the history
Problema e2e
  • Loading branch information
bidof committed Apr 30, 2024
2 parents a163506 + 97188eb commit e9ac670
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
28 changes: 13 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
release:
types: [published]


jobs:
unit-tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -54,24 +55,21 @@ jobs:
REACT_APP_API_URI: http://${{ secrets.DEPLOY_HOST }}:3000

e2e-tests:
runs-on: ubuntu-latest
needs: [unit-tests]
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 21
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix historyservice install
- run: npm --prefix questionservice install
- run: npm --prefix roomservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: xvfb-run --auto-servernum npm --prefix webapp run test:e2e
env :
CI : ""
- name: Copy e2eTest.sh to remote server
run: |
echo "${{ secrets.DEPLOY_KEY }}" > deploy_key
chmod 600 deploy_key
scp -o StrictHostKeyChecking=no -i deploy_key ./e2eTest.sh azureuser@${{ secrets.DEPLOY_HOST }}:~
- name: Run e2e tests
run: |
ssh -o StrictHostKeyChecking=no -i deploy_key azureuser@${{ secrets.DEPLOY_HOST }} <<'ENDSSH'
chmod +x ~/e2eTest.sh
~/e2eTest.sh
ENDSSH
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
Expand Down
42 changes: 42 additions & 0 deletions e2eTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Detener todos los contenedores Docker
docker stop $(docker ps -aq)
# Navegar a la carpeta e2e en tu directorio home
cd ~/e2e

# Vaciar la carpeta e2e
rm -rf *

# Clonar el repositorio
git clone https://github.com/Arquisoft/wiq_es05c.git
cd wiq_es05c

# Configurar Node.js
nvm install 21
nvm use 21

# Instalar dependencias y construir la aplicación web
npm --prefix users/authservice install
npm --prefix users/userservice install
npm --prefix gatewayservice install
npm --prefix historyservice install
npm --prefix questionservice install
npm --prefix roomservice install
npm --prefix webapp install
npm --prefix webapp run build

# Ejecutar pruebas e2e
xvfb-run --auto-servernum npm --prefix webapp run test:e2e

# Capturar el estado de salida de las pruebas
TEST_STATUS=$?

# Si las pruebas fallaron, reiniciar todos los contenedores Docker y imprimir un mensaje
if [ $TEST_STATUS -ne 0 ]; then
echo "Fallaron los tests"
docker start $(docker ps -aq)
fi

# Salir con el estado de salida de las pruebas
exit $TEST_STATUS
2 changes: 1 addition & 1 deletion questionservice/scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Scheduler {


start() {
this.job1 = cron.schedule('0 * * * *', async () => {
this.job1 = cron.schedule('*/10 * * * *', async () => {
try {
await this.generarPregunta();
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/steps/dailyQuestionMode-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1920, height: 1080 }});
: await puppeteer.launch({ headless: false, slowMo: 0, defaultViewport: { width: 1200, height: 800 }});
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 30000 })
Expand Down

0 comments on commit e9ac670

Please sign in to comment.