Skip to content

Commit

Permalink
Merge pull request #153 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
paulasuarezp authored Apr 29, 2023
2 parents c359eaf + d0e1a88 commit 2c82517
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 47 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,5 @@ After the actions process is finished, we can access the application using the I
## Miembros del equipo
- Abel Busto Dopazo, UO284262
- Adrián Fernández Álvarez, UO282154
- Juan Hermosa Casaprima, UO276839
- Guillermo Pulido Fernández, UO282716
- Paula Suárez Prieto, UO269745
2 changes: 1 addition & 1 deletion docker-compose-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ services:
webapp:
image: ghcr.io/arquisoft/lomap_es2c/webapp:latest
ports:
- "3000:3000"
- "443:443"
depends_on:
- restapi
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
webapp:
build: ./webapp
ports:
- "3000:3000"
- "443:443"
depends_on:
- restapi
prometheus:
Expand Down
4 changes: 2 additions & 2 deletions restapi/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import express, { Request, Response, Router } from 'express';
import * as fac from './src/facade';

const api: Router = express.Router()

/*
api.get(
"/usermanager/find/username",
async (req: Request, res: Response): Promise<Response> => {
Expand All @@ -14,7 +14,7 @@ api.get(
return res.status(404).send({ "error": err.message })
}
}
);
);*/

api.post(
"/usermanager/edit",
Expand Down
15 changes: 14 additions & 1 deletion restapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,21 @@
"version": "1.0.0",
"scripts": {
"start": "ts-node-dev ./server.ts",
"test": "cd tests && jest --runInBand"
"test": "cd tests && jest --coverage"
},

"jest": {
"collectCoverage": true,
"coverageReporters": [
"json",
"lcov",
"text",
"clover"
],
"coverageDirectory": "coverage"
}

,
"keywords": [],
"author": "",
"license": "ISC",
Expand Down
7 changes: 3 additions & 4 deletions restapi/tests/UserManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ describe('UserManager', () => {
});
describe('modificarContrasena', () => {
it('debería lanzar un error si el usuario no existe', async () => {
let error = new Error("Error por defecto")
let error1 = new Error("Error por defecto")
try {
await userManager.modificarContrasena(new UserImpl("usertestnotexists", "", "", ""), "", "")
} catch (err) {
error = err;
error1 = err;
}
expect(error.message).toBe("El usuario no existe.");
expect(error1.message).toBe("El usuario no existe.");

});
it('debería lanzar un error si la contraseña antigua no coincide', async () => {
Expand All @@ -121,7 +121,6 @@ describe('UserManager', () => {
});

it('no deberia lanzar ningun error si cambia la contraseña satisfactoriamente (se cambia por la misma por ser un test)', async () => {
let error = new Error("Error por defecto")
try {
await userManager.modificarContrasena(new UserImpl("usertestn4", "", "", ""), "usertestN4.", "usertestN4.")
} catch (err) {
Expand Down
29 changes: 15 additions & 14 deletions restapi/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import express, { Application, RequestHandler } from "express";
import bp from "body-parser";
import promBundle from "express-prom-bundle";
import { Server } from "http";
import request, { Response } from "supertest";
import request from "supertest";
import apiUser from "../api";
import { UserImpl } from "../src/entities/User";
import { FriendRequest } from "../src/entities/FriendRequest";
import { FriendManagerImpl } from "../src/controllers/FriendManager";
import FriendshipSchema from "../src/entities/FriendshipSchema";
import UserSchema from "../src/entities/UserSchema";
var mongoose = require('mongoose');

var server: Server;
const mongoose = require('mongoose');

let server: Server;

const app: Application = express();

Expand Down Expand Up @@ -46,7 +47,7 @@ describe('test conexión con api ', () => {
expect(response.status).toBe(200);
});
});

/*
describe('/usermanager/find/username ', () => {
test('usuario que existe', async () => {
const response = await request(app).get('/usermanager/find/username?username=usertestn1');
Expand All @@ -59,7 +60,7 @@ describe('/usermanager/find/username ', () => {
const response = await request(app).get('/usermanager/find/username?username=usernotexists');
expect(response.status).toBe(404);
});
});
});*/

describe('/usermanager/edit ', () => {
test('usuario que existe', async () => {
Expand Down Expand Up @@ -88,7 +89,7 @@ describe('/sesionmanager/signup ', () => {
let user = new UserImpl("usertestsignup", "1234", "webIdPrueba", "descripcionprueba", "img")
const response = await request(app).post('/sesionmanager/signup').send({ user: user });
expect(response.status).toBe(200);
let r = await UserSchema.deleteOne({ username: "usertestsignup" })
await UserSchema.deleteOne({ username: "usertestsignup" })
});
});

Expand All @@ -112,8 +113,8 @@ describe('/sesionmanager/login ', () => {

test('usuario que no existe', async () => {

let user = new UserImpl("usernotexists", "wrongpassword", "webIdPrueba1", "descripcionprueba1")
const response = await request(app).post('/sesionmanager/login').send({ user: user });
let userNotExist = new UserImpl("usernotexists", "wrongpassword", "webIdPrueba1", "descripcionprueba1")
const response = await request(app).post('/sesionmanager/login').send({ user: userNotExist });
expect(response.status).toBe(404);

});
Expand Down Expand Up @@ -235,14 +236,14 @@ describe('/usermanager/editpsw', () => {

describe('/friendmanager/friendrequests', () => {
test('user que existe', async () => {
let user = new UserImpl("usertestn1", "", "webIdPrueba1", "descripcionprueba1")
const response = await request(app).post('/friendmanager/friendrequests').send({ user: user });
expect(response.status).toBe(200);
let user2 = new UserImpl("usertestn1", "", "webIdPrueba1", "descripcionprueba1")
const response2 = await request(app).post('/friendmanager/friendrequests').send({ user: user2 });
expect(response2.status.toString()).toBe("200");
});
test('user que no existe', async () => {
let user = new UserImpl("usernotexists", "", "webIdPrueba1", "descripcionprueba1")
const response = await request(app).post('/friendmanager/friendrequests').send({ user: user });
expect(response.status).toBe(404);
let user3 = new UserImpl("usernotexists", "", "webIdPrueba1", "descripcionprueba1")
const response2 = await request(app).post('/friendmanager/friendrequests').send({ user: user3 });
expect(response2.status.toString()).toBe("404");
});
});

9 changes: 8 additions & 1 deletion restapi/tests/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ export default {
"**/src/persistence/*.{ts,tsx}",
"!**/src/persistence/DefaultMongo.ts",
"**/src/entities/*.{ts,tsx}",
]
],
coverageReporters: [
"json",
"lcov",
"text",
"clover"
],
coverageDirectory: "coverage"
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
4 changes: 1 addition & 3 deletions webapp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import express, { Application } from 'express';
//setting the option module to commonjs

var app: Application = express();
const port: number = 3000;
const port: number = 3000;

app.use(express.static("build"));
app.use(express.static('public'));
app.use(express.static(__dirname + '/public'));

app
.listen(port, (): void => {
Expand Down
1 change: 0 additions & 1 deletion webapp/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export async function editUserDetails(user: User): Promise<User> {
}

export async function getMyFriends(user: User): Promise<User[]> {
console.log("empieza")
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api'
let response = await fetch(apiEndPoint + '/friendmanager/friends', {
method: 'POST',
Expand Down
1 change: 0 additions & 1 deletion webapp/src/auth/AuthPodChecker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Navigate } from 'react-router-dom';
import { readCookie } from 'utils/CookieReader';

export const AuthPodChecker = (props: { children: any }) => {
console.log(readCookie("isPodLogged"))
if (readCookie("isPodLogged") === "true") {
return props.children;
} else {
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/mainComponents/ImgCarrusel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export default function StandardImageList() {

const itemData = [
{
img: '/fotosCarrusel/1.png',
img: '1.png',
title: 'Crea tus propios mapas',
},
{
img: '/fotosCarrusel/2.png',
img: '2.png',
title: 'Guarda tus lugares favoritos',
},
{
img: '/fotosCarrusel/4.png',
img: '4.png',
title: 'Ve los mapas de tus amigos',
}
];
11 changes: 5 additions & 6 deletions webapp/src/components/userIdentification/podLogin/Pod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export default function PodLogin() {
const [provider, setProvider] = useState('');
const [idp, setIdp] = useState("https://inrupt.net");

let redirectUrl = window.location.origin.concat("/home/welcome");
console.log(redirectUrl)
let redirectToUrl = window.location.origin.concat("/home/welcome");


const providers = GetProviders();
Expand Down Expand Up @@ -89,8 +88,8 @@ export default function PodLogin() {
<img style={{ width: "50px", height: "auto" }}
loading="lazy"
width="60"
src={"../" + option.name + ".png"}
srcSet={"../" + option.name + ".png"}
src={option.name + ".png"}
srcSet={option.name + ".png"}
alt={"Logo de " + option.name}
/>
{option.name}
Expand All @@ -109,7 +108,7 @@ export default function PodLogin() {
<InputAdornment position="start">
<img
style={{ width: "50px", height: "auto" }}
src={"../" + params.inputProps.value + ".png"}
src={ params.inputProps.value + ".png"}
alt={"Logo de " + params.inputProps.value}
/>
</InputAdornment>
Expand All @@ -123,7 +122,7 @@ export default function PodLogin() {
<LoginButton
oidcIssuer={idp}
redirectUrl={
redirectUrl
redirectToUrl
}
onError={handleError}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const FriendsComponent = (props: { friends: Promise<Friend[]>, daddy: any
position: [parseFloat(place.latitude), parseFloat(place.longitude)],
name: place.nombre,
type: "friend",
iconUrl: "../markers/friendsMarker.png",
iconUrl: "friendsMarker.png",
category: place.category,
imageUrl: place.images[0]?.url
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const Groups = (props: { groups: Promise<Group[]>, daddy: any, refresh: a
position: [parseFloat(place.latitude), parseFloat(place.longitude)],
name: place.nombre,
type: "mine",
iconUrl: "../markers/myMarker.png",
iconUrl: "myMarker.png",
category: place.category,
imageUrl: place.images[0]?.url
})
Expand Down
10 changes: 5 additions & 5 deletions webapp/src/components/windowComponents/map/MapComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function markerIcon(url: string): L.Icon {
};

const addMarkerIcon = new L.Icon({
iconUrl: '../markers/add-location.png',
iconUrl: 'add-location.png',
iconSize: [47, 47]
});

Expand Down Expand Up @@ -128,7 +128,7 @@ function CleanMap(props: { myGroup: string, friendGroup: string }): any {

legend.onAdd = function () {
let div = L.DomUtil.create('div', 'cleanMap');
div.innerHTML += '<button id="cleanMapButton"><img width="20px" src="../cleanMap.png" alt="Descripción de la imagen">Limpiar mapa</button>';
div.innerHTML += '<button id="cleanMapButton"><img width="20px" src="cleanMap.png" alt="Descripción de la imagen">Limpiar mapa</button>';
return div;
};

Expand Down Expand Up @@ -158,9 +158,9 @@ function Legend(): any {
legend.onAdd = function () {
let div = L.DomUtil.create('div', 'Leyenda');
div.innerHTML += '<h3 id="titutloleyenda" style="color: #81c784">Leyenda</h4>';
div.innerHTML += '<img src="../markers/myMarker.png" width="20px">Tus lugares<br>';
div.innerHTML += '<img src="../markers/friendsMarker.png" width="20px">Lugares de tus amigos<br>';
div.innerHTML += '<img src="../markers/add-location.png" width="20px">Lugar que estás añadiendo<br>';
div.innerHTML += '<img src="myMarker.png" width="20px">Tus lugares<br>';
div.innerHTML += '<img src="friendsMarker.png" width="20px">Lugares de tus amigos<br>';
div.innerHTML += '<img src="add-location.png" width="20px">Lugar que estás añadiendo<br>';
return div;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default function AddPlaceForm(props: { refresh: any }) {
position: [parseFloat(place.latitude), parseFloat(place.longitude)],
name: place.nombre,
type: "mine",
iconUrl: "../markers/myMarker.png",
iconUrl: "myMarker.png",
category: place.category,
imageUrl: place.images[0]?.url
})
Expand Down

0 comments on commit 2c82517

Please sign in to comment.