Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Started to fix e2e #280

Merged
merged 8 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
coverage
testDB.sqlite
**/*.sqlite
docs/build
.idea
4 changes: 2 additions & 2 deletions auth_service/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
"development": {
"dialect": "sqlite",
"storage": "./testDB.sqlite",
"storage": "./testDBAuth.sqlite",
"logging": false
},
"test": {
"dialect": "sqlite",
"storage": "./testDB.sqlite",
"storage": "./testDBAuth.sqlite",
"logging": false
}
}
4 changes: 2 additions & 2 deletions game_service/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
"development": {
"dialect": "sqlite",
"storage": "./testDB.sqlite",
"storage": "./testDBGame.sqlite",
"logging": false
},
"test": {
"dialect": "sqlite",
"storage": "./testDB.sqlite",
"storage": "./testDBGame.sqlite",
"logging": false
}
}
8 changes: 7 additions & 1 deletion game_service/game/verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const getCurrentQuestion = async (userId) => {
}

const requestQuestion = async() => {
return res = (await axios.post("http://question:8002/api/questions/generate")).data;
let url = "http://question:8002/api/questions/generate";

if(process.env.NODE_ENV !== "production"){
url = "http://localhost:8002/api/questions/generate"
}

return (await axios.post(url)).data;
}

module.exports = {validate, getCurrentQuestion, requestQuestion}
Expand Down
54 changes: 52 additions & 2 deletions question_service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions question_service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.6.8",
"axios-mock-adapter": "^1.22.0",
"bcrypt": "^5.1.1",
"chance": "^1.1.11",
"cookie-parser": "^1.4.6",
Expand Down
39 changes: 20 additions & 19 deletions question_service/question.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
const request = require('supertest')
const app = require("./question")
const MockAdapter = require('axios-mock-adapter');
const axios = require('axios');
// Mocking axios call
const mock = new MockAdapter(axios);
const responseData = {
results: {
bindings: [
{ filmLabel: { value: "Pulp Fiction" }, directorLabel: { value: "Quentin Tarantino" } },
{ filmLabel: { value: "Inception" }, directorLabel: { value: "Christopher Nolan" } },
{ filmLabel: { value: "The Shawshank Redemption" }, directorLabel: { value: "Frank Darabont" } },
{ filmLabel: { value: "The Godfather" }, directorLabel: { value: "Francis Ford Coppola" } },
{ filmLabel: { value: "The Dark Knight" }, directorLabel: { value: "Christopher Nolan" } },
{ filmLabel: { value: "Fight Club" }, directorLabel: { value: "David Fincher" } },
{ filmLabel: { value: "Forrest Gump" }, directorLabel: { value: "Robert Zemeckis" } },
{ filmLabel: { value: "The Matrix" }, directorLabel: { value: "Lana Wachowski" } }
]
}
};

mock.onAny().reply(200, responseData);

jest.mock('./db/mongo/utils', () => ({
getRandomTemplate: () => { return Promise.resolve({
Expand All @@ -14,25 +34,6 @@ jest.mock('./db/mongo/utils', () => ({
)}
}));

// Mock the fetch function
global.fetch = jest.fn().mockResolvedValue({
ok: true, // Define the 'ok' property
json: async () => ({
results: {
bindings: [
{ filmLabel: { value: "Pulp Fiction" }, directorLabel: { value: "Quentin Tarantino" } },
{ filmLabel: { value: "Inception" }, directorLabel: { value: "Christopher Nolan" } },
{ filmLabel: { value: "The Shawshank Redemption" }, directorLabel: { value: "Frank Darabont" } },
{ filmLabel: { value: "The Godfather" }, directorLabel: { value: "Francis Ford Coppola" } },
{ filmLabel: { value: "The Dark Knight" }, directorLabel: { value: "Christopher Nolan" } },
{ filmLabel: { value: "Fight Club" }, directorLabel: { value: "David Fincher" } },
{ filmLabel: { value: "Forrest Gump" }, directorLabel: { value: "Robert Zemeckis" } },
{ filmLabel: { value: "The Matrix" }, directorLabel: { value: "Lana Wachowski" } }
]
}
})
});

// Import Chance library for random number generation
const Chance = require('chance')

Expand Down
11 changes: 4 additions & 7 deletions question_service/questions/wikiUtils/wikidata.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
const axios = require('axios');

async function query(SPARQL) {
const apiUrl = `https://query.wikidata.org/sparql?query=${encodeURIComponent(SPARQL)}&format=json`;

const response = await fetch(apiUrl, {
const response = await axios.get(apiUrl, {
headers: {
'Accept': 'application/json',
'User-Agent': 'QuestionCrawler/1.0 ([email protected])'
}
});

if (!response.ok) {
console.error('Error al realizar la consulta a Wikidata:', response.statusText);
return;
}

const datos = await response.json();
const datos = response.data;

const resultados = datos.results.bindings.map((resultado) => {
const resultadoFormateado = {};
Expand Down
1 change: 1 addition & 0 deletions userdetails_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN npm install

# Set the env var
ENV DB_URL=mariadb
ENV NODE_ENV=production

# Copy the app source code to the working directory
COPY . .
Expand Down
Loading