Skip to content

Commit

Permalink
✨ Arreglados problemas de e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
coral2742 committed May 8, 2024
1 parent 13b6cf6 commit 3fbdeb0
Show file tree
Hide file tree
Showing 9 changed files with 32,181 additions and 21,199 deletions.
7 changes: 6 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ app.get('/createquestion', async (req, res) => {
// Return a json response with what we obtained on the petition
res.json(questionResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
if (error.response) {
res.status(error.response.status).json({ error: error.response.data.error });
} else {
res.status(500).json({ error: 'Internal Server Error' });
}

}
});

Expand Down
1,589 changes: 1,545 additions & 44 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
"@mui/icons-material": "^5.15.12",
"@mui/material": "^5.15.12",
"axios": "^1.6.8",
"bcrypt": "^5.1.1",
"cors": "^2.8.5",
"express": "^4.19.2",
"express-prom-bundle": "^7.0.0",
"history": "^5.3.0",
"jest": "^29.7.0",
"supertest": "^6.3.4"
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.3.4",
"supertest": "^6.3.4",
"swagger-ui-express": "^5.0.0"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
Expand Down
9 changes: 7 additions & 2 deletions users/authservice/auth-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const userSchema = new mongoose.Schema({
createdAt: Date,
});

const User = mongoose.model('User', userSchema);
let model;

module.exports = User
if (mongoose.models.User) {
model = mongoose.model('User');
} else {
model = mongoose.model('User', userSchema);
}
module.exports = model;
2 changes: 1 addition & 1 deletion webapp/e2e/features/register-form.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Feature: Registering a new user
Scenario: The user is not registered in the site
Given An unregistered user
When I fill the data in the form and press submit
Then A confirmation message should be shown in the screen
Then I should be redirected to the main game page
12 changes: 8 additions & 4 deletions webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ defineFeature(feature, test => {
when('I fill the data in the form and press submit', async () => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick('button', { text: 'Crear usuario' })
await expect(page).toClick('button', { text: 'Crear usuario' });


});

then('A confirmation message should be shown in the screen', async () => {
await expect(page).toMatchElement("div", { text: "Usuario añadido correctamente" });

then('I should be redirected to the main game page', async () => {
// Esperar a que la confirmación aparezca en la pantalla
await page.waitForSelector("h2", { text: "¡Bienvenido a" });
});

})

afterAll(async () => {
Expand Down
51,750 changes: 30,606 additions & 21,144 deletions webapp/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.1",
"react-scripts": "5.0.1",
"react-scripts": "^3.0.1",
"web-vitals": "^3.5.1"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const AddUser = ({ onCloseSnackbar }) => {
setOpenSnackbar(true);

// Redirige a la página de juego después de 3 segundos
navigate("/Game");
navigate("/mainPage");
} catch (error) {
setError("Error al crear usuario");
setOpenSnackbar(true); // Abre el Snackbar en caso de error
Expand Down

0 comments on commit 3fbdeb0

Please sign in to comment.