diff --git a/gatewayservice/Dockerfile b/gatewayservice/Dockerfile
index d789b3cd..ecc8d18a 100644
--- a/gatewayservice/Dockerfile
+++ b/gatewayservice/Dockerfile
@@ -2,9 +2,9 @@
FROM node:20
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
-RUN apt-get install apt-transport-https
+RUN apt install apt-transport-https -y --no-install-recommends && apt clean
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
-RUN apt-get update && apt-get install filebeat
+RUN apt update && apt install filebeat -y --no-install-recommends && apt clean
COPY filebeat.yml /etc/filebeat/filebeat.yml
diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js
index 6f859df6..1328fa39 100644
--- a/gatewayservice/gateway-service.js
+++ b/gatewayservice/gateway-service.js
@@ -1,5 +1,4 @@
const express = require('express');
-const cors = require('cors');
const promBundle = require('express-prom-bundle');
const axios = require('axios');
const { loggerFactory, requestLoggerMiddleware, responseLoggerMiddleware, errorHandlerMiddleware } = require("cyt-utils")
@@ -42,7 +41,7 @@ require("./routes/authRoutes")(app, axios)
require("./routes/historyRoutes")(app, axios, authTokenMiddleware)
// Open API
-openapiPath='./GatewayAPI.yaml'
+const openapiPath='./GatewayAPI.yaml'
if (fs.existsSync(openapiPath)) {
const file = fs.readFileSync(openapiPath, 'utf8');
diff --git a/gatewayservice/package-lock.json b/gatewayservice/package-lock.json
index 7182d60d..3778ca2c 100644
--- a/gatewayservice/package-lock.json
+++ b/gatewayservice/package-lock.json
@@ -9,7 +9,6 @@
"version": "1.0.0",
"dependencies": {
"axios": "^1.6.5",
- "cors": "^2.8.5",
"cyt-utils": "*2.0.9",
"express": "^4.18.2",
"express-openapi": "^12.1.3",
@@ -1851,18 +1850,6 @@
"integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==",
"dev": true
},
- "node_modules/cors": {
- "version": "2.8.5",
- "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
- "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
- "dependencies": {
- "object-assign": "^4",
- "vary": "^1"
- },
- "engines": {
- "node": ">= 0.10"
- }
- },
"node_modules/create-jest": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz",
@@ -3785,14 +3772,6 @@
"node": ">=8"
}
},
- "node_modules/object-assign": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
- "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/object-inspect": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
diff --git a/gatewayservice/package.json b/gatewayservice/package.json
index 213256a2..749b70f8 100644
--- a/gatewayservice/package.json
+++ b/gatewayservice/package.json
@@ -20,7 +20,6 @@
"homepage": "https://github.com/arquisoft/wiq_es05b#readme",
"dependencies": {
"axios": "^1.6.5",
- "cors": "^2.8.5",
"cyt-utils": "*2.0.9",
"express": "^4.18.2",
"express-openapi": "^12.1.3",
diff --git a/jordi/Dockerfile b/jordi/Dockerfile
index ccbc539e..4a8d9641 100644
--- a/jordi/Dockerfile
+++ b/jordi/Dockerfile
@@ -2,9 +2,9 @@
FROM node:20
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
-RUN apt-get install apt-transport-https
+RUN apt install apt-transport-https -y --no-install-recommends && apt clean
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
-RUN apt-get update && apt-get install filebeat
+RUN apt update && apt install filebeat -y --no-install-recommends && apt clean
COPY filebeat.yml /etc/filebeat/filebeat.yml
diff --git a/sonar-project.properties b/sonar-project.properties
index b491886f..05da4bd9 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -10,7 +10,8 @@ sonar.host.url=https://sonarcloud.io
sonar.language=js
sonar.projectName=wiq_es05b
-sonar.coverage.exclusions=**/*.test.js
+sonar.coverage.exclusions=**/*.test.js,**/*.draft.js
+sonar.cpd.exclusions=**/*.test.js,**/*.draft.js
sonar.sources=users/authservice,users/userservice,gatewayservice,webapp/src,userhistory,jordi
sonar.sourceEncoding=UTF-8
sonar.exclusions=node_modules/**
diff --git a/userhistory/Dockerfile b/userhistory/Dockerfile
index b4549407..cf2f03f7 100644
--- a/userhistory/Dockerfile
+++ b/userhistory/Dockerfile
@@ -2,9 +2,9 @@
FROM node:20
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
-RUN apt-get install apt-transport-https
+RUN apt install apt-transport-https -y --no-install-recommends && apt clean
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
-RUN apt-get update && apt-get install filebeat
+RUN apt update && apt install filebeat -y --no-install-recommends && apt clean
COPY filebeat.yml /etc/filebeat/filebeat.yml
diff --git a/users/authservice/Dockerfile b/users/authservice/Dockerfile
index 8f50e162..8e9d9091 100644
--- a/users/authservice/Dockerfile
+++ b/users/authservice/Dockerfile
@@ -2,9 +2,9 @@
FROM node:20
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
-RUN apt-get install apt-transport-https
+RUN apt install apt-transport-https -y --no-install-recommends && apt clean
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
-RUN apt-get update && apt-get install filebeat
+RUN apt update && apt install filebeat -y --no-install-recommends && apt clean
COPY filebeat.yml /etc/filebeat/filebeat.yml
diff --git a/users/userservice/Dockerfile b/users/userservice/Dockerfile
index c56b97f6..9f4072d6 100644
--- a/users/userservice/Dockerfile
+++ b/users/userservice/Dockerfile
@@ -2,9 +2,9 @@
FROM node:20
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
-RUN apt-get install apt-transport-https
+RUN apt install apt-transport-https -y --no-install-recommends && apt clean
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
-RUN apt-get update && apt-get install filebeat
+RUN apt update && apt install filebeat -y --no-install-recommends && apt clean
COPY filebeat.yml /etc/filebeat/filebeat.yml
diff --git a/webapp/src/__test__/Account.test.js b/webapp/src/__test__/Account.test.js
index 6e5ca174..10fb3d8b 100644
--- a/webapp/src/__test__/Account.test.js
+++ b/webapp/src/__test__/Account.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
+import { render, screen, waitFor, act } from '@testing-library/react';
import axios from 'axios';
import Account from '../views/Account.jsx';
import { AuthContext } from "../views/context/AuthContext.jsx";
@@ -9,18 +9,7 @@ import '@testing-library/jest-dom';
jest.mock('axios');
jest.mock('../views/context/AuthContext');
-
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
-
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+require("./utils/localStorageMock")()
// Configura una implementación simulada de axios
jest.mock('../App.jsx', () => ({
diff --git a/webapp/src/__test__/Error.test.js b/webapp/src/__test__/Error.test.js
index fb82d701..173b321c 100644
--- a/webapp/src/__test__/Error.test.js
+++ b/webapp/src/__test__/Error.test.js
@@ -1,27 +1,14 @@
import React from 'react';
-import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
+import { render, screen, act } from '@testing-library/react';
import '@testing-library/jest-dom';
-import axios from 'axios';
import Error from '../views/Error.jsx';
import { useAuth } from "../App.jsx";
import { AuthContext } from "../views/context/AuthContext.jsx";
import {MemoryRouter} from "react-router";
-import Menu from "../views/Menu";
jest.mock('axios');
jest.mock('../views/context/AuthContext');
-
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
-
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+require("./utils/localStorageMock")()
jest.mock('../App.jsx', () => ({
useAuth: jest.fn().mockReturnValue({
diff --git a/webapp/src/__test__/Login.test.js b/webapp/src/__test__/Login.test.js
index eee29171..bd4cba49 100644
--- a/webapp/src/__test__/Login.test.js
+++ b/webapp/src/__test__/Login.test.js
@@ -9,18 +9,7 @@ import '@testing-library/jest-dom';
jest.mock('axios');
jest.mock('../views/context/AuthContext');
-
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
-
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+require("./utils/localStorageMock")()
// Configura una implementación simulada de axios
jest.mock('../App.jsx', () => ({
diff --git a/webapp/src/__test__/Menu.test.js b/webapp/src/__test__/Menu.test.js
index 2e96b348..dae2e762 100644
--- a/webapp/src/__test__/Menu.test.js
+++ b/webapp/src/__test__/Menu.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
+import { render, screen, waitFor, act } from '@testing-library/react';
import axios from 'axios';
import Menu from '../views/Menu.jsx';
import { AuthContext } from "../views/context/AuthContext";
@@ -9,18 +9,7 @@ import '@testing-library/jest-dom';
jest.mock('axios');
jest.mock('../views/context/AuthContext');
-
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
-
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+require("./utils/localStorageMock")()
// Configura una implementación simulada de axios
jest.mock('../App.jsx', () => ({
diff --git a/webapp/src/__test__/Signup.test.js b/webapp/src/__test__/Signup.test.js
index f8c01e30..337e59b9 100644
--- a/webapp/src/__test__/Signup.test.js
+++ b/webapp/src/__test__/Signup.test.js
@@ -9,18 +9,7 @@ import '@testing-library/jest-dom';
jest.mock('axios');
jest.mock('../views/context/AuthContext');
-
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
-
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+require("./utils/localStorageMock")()
// Configura una implementación simulada de axios
jest.mock('../App.jsx', () => ({
diff --git a/webapp/src/__test__/components/CustomForm.test.js b/webapp/src/__test__/components/CustomForm.test.js
index 648d8894..2e46b153 100644
--- a/webapp/src/__test__/components/CustomForm.test.js
+++ b/webapp/src/__test__/components/CustomForm.test.js
@@ -1,5 +1,5 @@
import React from "react";
-import { render, fireEvent, screen } from "@testing-library/react";
+import { render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import CustomForm from "../../views/components/CustomForm";
import '@testing-library/jest-dom';
diff --git a/webapp/src/__test__/components/ErrorSnackBar.test.js b/webapp/src/__test__/components/ErrorSnackBar.test.js
index 597746ac..e7764f82 100644
--- a/webapp/src/__test__/components/ErrorSnackBar.test.js
+++ b/webapp/src/__test__/components/ErrorSnackBar.test.js
@@ -1,7 +1,6 @@
import React from "react";
import { render, fireEvent, screen } from "@testing-library/react";
import ErrorSnackBar from "../../views/components/ErrorSnackBar";
-import { Snackbar } from "@mui/material";
import '@testing-library/jest-dom';
describe("ErrorSnackBar component", () => {
diff --git a/webapp/src/__test__/components/Footer.test.js b/webapp/src/__test__/components/Footer.test.js
index 95da4cc4..4d0e3861 100644
--- a/webapp/src/__test__/components/Footer.test.js
+++ b/webapp/src/__test__/components/Footer.test.js
@@ -9,14 +9,14 @@ describe("Footer component", () => {
const currentYear = new Date().getFullYear();
expect(screen.getByText(`© ${currentYear} ASW - WIQ05b`)).toBeInTheDocument();
- expect(screen.getByRole("navigation")).toBeInTheDocument();
- const appBar = screen.getByRole("navigation");
+ expect(screen.getByTestId("footer")).toBeInTheDocument();
+ const appBar = screen.getByTestId("footer");
expect(appBar).toHaveStyle({ backgroundColor: "primary" });
});
test("has fixed position at the bottom of the page", () => {
render();
- const appBar = screen.getByRole("navigation");
+ const appBar = screen.getByTestId("footer");
expect(appBar).toHaveStyle({ top: "auto", bottom: 0, position: "fixed" });
});
diff --git a/webapp/src/__test__/components/Nav.draft.js b/webapp/src/__test__/components/Nav.draft.js
index 8c524ccc..014375f1 100644
--- a/webapp/src/__test__/components/Nav.draft.js
+++ b/webapp/src/__test__/components/Nav.draft.js
@@ -1,28 +1,15 @@
-/*
import React from "react";
import {render, screen, fireEvent, act} from "@testing-library/react";
import Nav from "../../views/components/Nav";
import {AuthContext} from "../../views/context/AuthContext";
import {MemoryRouter} from "react-router";
-import Menu from "../../views/Menu";
import { useAuth } from "../../App.jsx";
-import axios from "axios";
-import { ConfigContext } from '../../views/context/ConfigContext';
jest.mock('axios');
jest.mock('../../views/context/AuthContext');
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
+require("../utils/localStorageMock");
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
jest.mock('../../App.jsx', () => ({
useAuth: jest.fn().mockReturnValue({
getUser: jest.fn().mockReturnValue({
@@ -70,4 +57,3 @@ describe("Nav component", () => {
expect(logoutMenuItem).toBeInTheDocument();
});
});
-*/
diff --git a/webapp/src/__test__/components/SaveList.test.js b/webapp/src/__test__/components/SaveList.test.js
index a1bbdc34..62206cc7 100644
--- a/webapp/src/__test__/components/SaveList.test.js
+++ b/webapp/src/__test__/components/SaveList.test.js
@@ -8,18 +8,7 @@ import { MemoryRouter } from "react-router";
jest.mock('axios');
jest.mock('../../views/context/AuthContext');
-
-const localStorageMock = (() => {
- let store = {};
- return {
- getItem: key => store[key],
- setItem: (key, value) => { store[key] = value },
- removeItem: key => { delete store[key] },
- clear: () => { store = {} }
- };
-})();
-
-Object.defineProperty(window, 'localStorage', { value: localStorageMock });
+require("../utils/localStorageMock")()
describe('SaveList component', () => {
const mockSaves = [
diff --git a/webapp/src/__test__/utils/localStorageMock.js b/webapp/src/__test__/utils/localStorageMock.js
new file mode 100644
index 00000000..e71403d1
--- /dev/null
+++ b/webapp/src/__test__/utils/localStorageMock.js
@@ -0,0 +1,18 @@
+const localStorageMock = (() => {
+ let store = {};
+ Object.defineProperty(window, 'localStorage', {value: localStorageMock});
+ return {
+ getItem: key => store[key],
+ setItem: (key, value) => {
+ store[key] = value
+ },
+ removeItem: key => {
+ delete store[key]
+ },
+ clear: () => {
+ store = {}
+ }
+ };
+});
+
+module.exports = localStorageMock;
\ No newline at end of file
diff --git a/webapp/src/views/Game.jsx b/webapp/src/views/Game.jsx
index b97423cc..fe9b3e39 100644
--- a/webapp/src/views/Game.jsx
+++ b/webapp/src/views/Game.jsx
@@ -208,15 +208,18 @@ const Game = () => {
.catch(e => setHistorialError(e.response.data.error))
}
- const createSave = () => {
- axios
- .post("/history/create", {
- token: getUser().token,
- category: category,
- userId: getUser().userId
- })
- .then(response => saveId.current = response.data.id)
- .catch(err => setHistorialError(err.response.data.error))
+ const createSave = async () => {
+ try {
+ const response = await axios
+ .post("/history/create", {
+ token: getUser().token,
+ category: category,
+ userId: getUser().userId
+ })
+ saveId.current = response.data.id
+ } catch (err) {
+ setHistorialError(err.response.data.error)
+ }
}
useEffect( () => {
diff --git a/webapp/src/views/components/Footer.jsx b/webapp/src/views/components/Footer.jsx
index d663bb64..3faac1a8 100644
--- a/webapp/src/views/components/Footer.jsx
+++ b/webapp/src/views/components/Footer.jsx
@@ -7,7 +7,7 @@ import { Container } from "@mui/material";
export default function Footer() {
return (
-
+
© {new Date().getFullYear()} ASW - WIQ05b