From 2bd1018aafa732b1fc3cf06124acb649ea9e08ca Mon Sep 17 00:00:00 2001 From: iyanfdezz Date: Thu, 25 Apr 2024 20:19:50 +0200 Subject: [PATCH] Fixes --- webapp/e2e/test-environment-setup.js | 4 +- webapp/e2e/user-model.js | 63 ++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 webapp/e2e/user-model.js diff --git a/webapp/e2e/test-environment-setup.js b/webapp/e2e/test-environment-setup.js index ce3be1a8..a2da3207 100644 --- a/webapp/e2e/test-environment-setup.js +++ b/webapp/e2e/test-environment-setup.js @@ -1,5 +1,7 @@ const { MongoMemoryServer } = require('mongodb-memory-server'); - +const mongoose = require('mongoose'); +const User = require('./user-model'); +const bcrypt = require('bcrypt'); let mongoserver; let userservice; diff --git a/webapp/e2e/user-model.js b/webapp/e2e/user-model.js new file mode 100644 index 00000000..ae347c9a --- /dev/null +++ b/webapp/e2e/user-model.js @@ -0,0 +1,63 @@ +const mongoose = require('mongoose'); + +const userSchema = new mongoose.Schema({ + username: { + type: String, + required: true, + }, + password: { + type: String, + required: true, + }, + createdAt: { + type: Date, + default: Date.now, + }, + games: [{ + gamemode: String, + correctAnswers: Number, + incorrectAnswers: Number, + points: Number, + avgTime: Number, + questions: [{ + pregunta: String, + respuestas: [ + String, + String, + String, + String + ], + correcta: String, + respuesta: String + }] + }], + friends: [{ + type: String, + ref: 'User' + }] +}); + +const User = mongoose.model('User', userSchema); + +// Modelo para el grupo +const groupSchema = new mongoose.Schema({ + name: { + type: String, + required: true, + unique: true // Asegura que no haya grupos con el mismo nombre + }, + createdAt: { + type: Date, + default: Date.now + }, + members: [{ + type: String, + required: true + }] +}); + +const Group = mongoose.model('Group', groupSchema); + + + +module.exports = { User, Group }; \ No newline at end of file