Skip to content

Commit

Permalink
Merge pull request #122 from Arquisoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
pelazas authored Apr 28, 2024
2 parents e5db97a + 898a6a8 commit 60fbe36
Show file tree
Hide file tree
Showing 14 changed files with 917 additions and 212 deletions.
84 changes: 42 additions & 42 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,47 @@ on:
types: [published]

jobs:
# unit-tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 20
# - run: npm --prefix users/authservice ci
# - run: npm --prefix users/userservice ci
# - run: npm --prefix gatewayservice ci
# - run: npm --prefix webapp ci
# - run: npm --prefix users/authservice test -- --coverage
# - run: npm --prefix users/userservice test -- --coverage
# - run: npm --prefix gatewayservice test -- --coverage
# - run: npm --prefix webapp test -- --coverage
# - name: Analyze with SonarCloud
# uses: sonarsource/sonarcloud-github-action@master
# 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 users/authservice install
# - run: npm --prefix users/userservice install
# - run: npm --prefix gatewayservice install
# - run: npm --prefix webapp install
# - run: npm --prefix webapp run build
#- run: npm --prefix webapp run test:e2e
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
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 users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice 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
Expand All @@ -69,7 +69,7 @@ jobs:
permissions:
contents: read
packages: write
#needs: [e2e-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -87,7 +87,7 @@ jobs:
permissions:
contents: read
packages: write
#needs: [e2e-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -105,7 +105,7 @@ jobs:
permissions:
contents: read
packages: write
#needs: [e2e-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -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
Expand All @@ -141,7 +141,7 @@ jobs:
permissions:
contents: read
packages: write
#needs: [e2e-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -162,7 +162,7 @@ jobs:
permissions:
contents: read
packages: write
#needs: [e2e-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -180,7 +180,7 @@ jobs:
permissions:
contents: read
packages: write
#needs: [e2e-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand Down
10 changes: 10 additions & 0 deletions gatewayservice/monitoring/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM grafana/grafana

# Copying the provisioning files
COPY ./provisioning /etc/grafana/provisioning

# Exposing Grafana server port
EXPOSE 9091

# Running Grafana server
CMD [ "grafana-server" ]
10 changes: 10 additions & 0 deletions gatewayservice/monitoring/prometheus/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM prom/prometheus

# Copying the configuration file
COPY prometheus.yml /etc/prometheus/prometheus.yml

# Exposing Prometheus server port
EXPOSE 9090

# Running Prometheus
ENTRYPOINT [ "prometheus", "--config.file=/etc/prometheus/prometheus.yml" ]
2 changes: 1 addition & 1 deletion webapp/e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
testMatch: ["**/steps/*.js"],
testTimeout: 30000,
setupFilesAfterEnv: ["expect-puppeteer"]
setupFilesAfterEnv: ["expect-puppeteer"],
}
71 changes: 71 additions & 0 deletions webapp/e2e/singlePlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

const puppeteer = require('puppeteer');

function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}

(async () => {
// Abrir un navegador Puppeteer
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
const timeout = 5000;

// Configurar un tiempo de espera predeterminado para las acciones de la página
page.setDefaultTimeout(timeout);

// Ir a la página de inicio de sesión
await page.goto('http://localhost:3000/');

// Esperar a que aparezca el botón de inicio de sesión y hacer clic en él
await page.waitForSelector('button.MuiButtonBase-root:nth-child(2)');
await page.click('button.MuiButtonBase-root:nth-child(2)');

// Esperar a que aparezca el campo de nombre de usuario, escribir el nombre de usuario y esperar
await page.waitForSelector('div.MuiFormControl-root:nth-child(2) > div:nth-child(2)');
await page.click('div.MuiFormControl-root:nth-child(2) > div:nth-child(2)'); // Hacer clic en el campo de usuario
await page.type('div.MuiFormControl-root:nth-child(2) > div:nth-child(2)', 'PabloS',{ delay: 100 });

// Esperar a que aparezca el campo de contraseña, escribir la contraseña y esperar
await page.waitForSelector('div.MuiFormControl-root:nth-child(3) > div:nth-child(2)');
await page.click('div.MuiFormControl-root:nth-child(3) > div:nth-child(2)'); // Hacer clic en el campo de contraseña
await page.type('div.MuiFormControl-root:nth-child(3) > div:nth-child(2)', 'PabloPassword',{ delay: 100 });

// Esperar a que aparezca el botón de inicio de sesión y hacer clic en él
await page.waitForSelector('button.MuiButtonBase-root:nth-child(1)');
await page.click('button.MuiButtonBase-root:nth-child(1)');

// Esperar a que aparezca el botón de juego individual y hacer clic en él
await page.waitForSelector('button.game-page-button:nth-child(1)');
await page.click('button.game-page-button:nth-child(1)');

// Esperar a que aparezca el botón "add bot" y hacer clic en él
await page.waitForSelector('.add-bot-button');
await page.click('.add-bot-button');
await delay(6000);
// Esperar a que aparezca el botón "start game" y hacer clic en él
await page.waitForSelector('.start-game-button');
await page.click('.start-game-button');
await delay(1500);
// Selector base para el botón de respuesta
const answerSelector = '.answer-grid > button:nth-child';

// Hacer clic en el botón de respuesta 13 veces utilizando un bucle for
for (let i = 1; i <= 13; i++) {
const fullSelector = `${answerSelector}(${1})`; // Selector completo para cada botón de respuesta
await page.waitForSelector(fullSelector); // Esperar a que aparezca el botón de respuesta actual
await page.click(fullSelector); // Hacer clic en el botón de respuesta actual
console.log('Clicked answer', i); // Imprimir un mensaje en la consola
await delay(5000);

}

// Cerrar el navegador
await browser.close();

})().catch(err => {
console.error(err);
process.exit(1);
});
Loading

0 comments on commit 60fbe36

Please sign in to comment.