Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate develop into master #336

Merged
merged 165 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
f3d3ef6
Added New Questions
PBC003 Apr 17, 2024
bc864fa
Restored Questions
PBC003 Apr 17, 2024
c6ca347
Improving question generation coverage
uo288347 Apr 20, 2024
c1a721f
Tested more questions routes
uo288347 Apr 20, 2024
2d9a7f1
Trying to fix e2e tests
uo288347 Apr 21, 2024
3c59bce
changing xpath
uo288347 Apr 21, 2024
c6b6f1e
Trying e2e
uo288347 Apr 21, 2024
c3003ed
Discovering cities e2e tests
uo288347 Apr 22, 2024
0c9c388
Changed login link in e2e
uo288347 Apr 22, 2024
2e3b412
Updated The Challange Game look and feel
uo289689 Apr 23, 2024
a558b9d
Changing grafana configuration
uo288347 Apr 23, 2024
5cc0cf9
Merge branch 'develop' into develop-teresa
uo288347 Apr 23, 2024
58e8f4f
Checking e2e
uo288347 Apr 23, 2024
215af9e
Fixing merge mistake
uo288347 Apr 23, 2024
ffe3c0c
Internacionalized view of statistics
uo289689 Apr 23, 2024
78e0ac5
Internacionalized view of homePage
uo289689 Apr 23, 2024
6050d48
Internacionalized view of instrucctions
uo289689 Apr 23, 2024
ba2e452
Internacionalized view of home
uo289689 Apr 23, 2024
be6d275
Adding testing to question generation
uo288347 Apr 23, 2024
de95620
Fixed some internatinalization problems
uo289689 Apr 23, 2024
4347c1b
Increasing coverage in questions and changing grafana configuration
uo288347 Apr 23, 2024
cc665b7
Implemented e2e for the Challaange game
uo289689 Apr 23, 2024
4ddc9b0
Fixing bug in build configuration
uo289689 Apr 23, 2024
266ddb3
Fixed unitary tests and e2e
uo289689 Apr 23, 2024
0c0c7f7
Fixing e2e
uo289689 Apr 23, 2024
ecf2c82
fixing e2e tests
uo289689 Apr 23, 2024
438ba65
Fixed e2e
uo289689 Apr 23, 2024
b1f2b85
Fixing e2e tests
uo289689 Apr 23, 2024
8912abc
fixing e2e
uo289689 Apr 23, 2024
a3e0b3c
fixing e2e
uo289689 Apr 23, 2024
a23ba19
Merge pull request #315 from Arquisoft/develop-teresa
PabloGOP Apr 23, 2024
5cb751b
Merge remote-tracking branch 'origin/develop' into develop_samuel
uo289689 Apr 23, 2024
c04b7c3
Column distribution in Instructions
PabloGOP Apr 23, 2024
2ee61c4
Change security in multiplayer
uo288543 Apr 23, 2024
3718632
Merge branch 'develop-hugo' into develop-deploy
uo288543 Apr 23, 2024
ea0dac4
Merge pull request #316 from Arquisoft/develop-hugo
uo288543 Apr 23, 2024
e4f553a
Unnifyied title style for all pages
PabloGOP Apr 23, 2024
dfe4200
Inter for homepage tilte
PabloGOP Apr 23, 2024
b8cc515
Stablished theme colors in Instructions.js
PabloGOP Apr 23, 2024
7a1e3cf
Merge branch 'develop-pablo-style' into develop
PabloGOP Apr 23, 2024
7a69a8f
Update security other time
uo288543 Apr 23, 2024
b5759bc
Merge branch 'develop-hugo' into develop-deploy
uo288543 Apr 23, 2024
e9141f3
Merge branch 'develop' into develop_samuel
uo289689 Apr 23, 2024
b2dd6a2
Restart containers and modified grafana
uo288347 Apr 23, 2024
d1b1afd
Merge pull request #317 from Arquisoft/develop_samuel
uo288543 Apr 23, 2024
85dc2c7
Merge pull request #319 from Arquisoft/develop-hugo
uo288543 Apr 23, 2024
e6393e5
PabloGOP Apr 23, 2024
6235406
Update HomePage
PBC003 Apr 23, 2024
ee03213
FIXED profile and groupdetails tests and views.
alagoconde Apr 24, 2024
f4ed9b0
Inter in TheChallengeGame.js
PabloGOP Apr 24, 2024
03b14ec
Forgot to add the categories as their keys are in a bizarre place
PabloGOP Apr 24, 2024
80d27c3
Fixed some i18n words.
alagoconde Apr 24, 2024
a687a7c
Default page title formating
PabloGOP Apr 24, 2024
980943c
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
PabloGOP Apr 24, 2024
54e35c2
Refactored categories names in the internationalization dictionaries …
PabloGOP Apr 24, 2024
5c2214f
<- XIF <- the layout of the challenge form
PabloGOP Apr 24, 2024
e447204
Add button to download apk
uo288543 Apr 24, 2024
2d8da6b
Merge branch 'develop' into develop-hugo
uo288543 Apr 24, 2024
f1cd43b
add other languages to the link text
uo288543 Apr 24, 2024
208e36f
Changed html components for mui material
PabloGOP Apr 24, 2024
2434848
Beatify increment/decrement buttons
PabloGOP Apr 24, 2024
7f3121d
Beautify final form button
PabloGOP Apr 24, 2024
747362a
Final layout adjustement
PabloGOP Apr 24, 2024
f067811
Definitive "retoque"
PabloGOP Apr 24, 2024
d1f5b47
Customized login and register buttoms to match general style
PabloGOP Apr 24, 2024
f0483cf
Solved enormous visual issue in VSC code
PabloGOP Apr 24, 2024
ce1862b
Solved problem to display initial form with npm start
PabloGOP Apr 24, 2024
f884ce3
Changing all the Discovering Cities game style.
alagoconde Apr 24, 2024
5c26192
Improved the code in the Discovering CIties game.
alagoconde Apr 24, 2024
dabf639
Wise men stack configuration layout
PabloGOP Apr 24, 2024
1c872e6
Improved the game code
alagoconde Apr 24, 2024
da3d29c
MUI components in Wise Men and unifyied internationalization dict ele…
PabloGOP Apr 24, 2024
96e16ed
Final form button style
PabloGOP Apr 24, 2024
f4e353b
Magic
PabloGOP Apr 24, 2024
44a59d5
Removed strange console.log in onClick event
PabloGOP Apr 24, 2024
10963ee
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
alagoconde Apr 24, 2024
1022cfd
Fixing react components in Games.
alagoconde Apr 24, 2024
e6260bf
Fixed the Challenge game view.
alagoconde Apr 24, 2024
c0b2f36
Minor style changes in game
PabloGOP Apr 24, 2024
3e6a939
Style changes in Wise Men
PabloGOP Apr 24, 2024
7f5b664
Final style for WiseMen
PabloGOP Apr 24, 2024
18b2576
Remove test question
PabloGOP Apr 24, 2024
59bf639
Stylized pause & play button
PabloGOP Apr 24, 2024
d13cdf5
Fixed the Warm Question game view.
alagoconde Apr 24, 2024
a0f8211
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
alagoconde Apr 24, 2024
b068041
Improved pause button with labels and applied to other games
PabloGOP Apr 24, 2024
99a03f2
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
alagoconde Apr 24, 2024
4fa6b72
Finished fising Warm Question game.
alagoconde Apr 24, 2024
2363c30
Removed the question template.
alagoconde Apr 24, 2024
e52776c
Included the new pause button in the last game that needed it.
alagoconde Apr 24, 2024
045ad6b
Solved code duplicity and change of texts in Wise Men tests
PabloGOP Apr 24, 2024
0f28bdc
Added tests to Wise Men until reach > 80%
PabloGOP Apr 24, 2024
ef57f93
Merge branch 'develop-pabloYalberto-fixes' of https://github.com/Arqu…
PabloGOP Apr 24, 2024
38882e9
Added test-ids to test progress bars in games
PabloGOP Apr 24, 2024
962e911
Why TF is this test suite failing if i execute all but passes individ…
PabloGOP Apr 24, 2024
4f9ffaa
OMG I am a genius
PabloGOP Apr 25, 2024
9fb0592
Áureo update of the challenge form
PabloGOP Apr 25, 2024
b328472
Auricidad applied also to Wise Men
PabloGOP Apr 25, 2024
3d4c221
Updated multiplayer first screen style
PabloGOP Apr 25, 2024
b849aff
move icon to home and make examples
uo288543 Apr 25, 2024
7e7aba1
add fav button
uo288543 Apr 25, 2024
7c29ba8
Add tooltip
uo288543 Apr 25, 2024
ccdb76e
Improved the default game managment.
alagoconde Apr 25, 2024
8c72e62
Adapted the Wise Men Stack tests to the new style of its view.
alagoconde Apr 25, 2024
ee9cd43
Improved Warm Question Game calling.
alagoconde Apr 25, 2024
1c32683
Updated the Warm Question Game tests to match the new view style.
alagoconde Apr 25, 2024
6c6d2d0
Improved and adapted the Challenge game tests to the new style.
alagoconde Apr 25, 2024
ea51299
Fixed the Challenge game tests.
alagoconde Apr 25, 2024
fcf5359
Upgraded tests of the Discovering Cities game.
alagoconde Apr 25, 2024
9249d81
I don't know wtf happened with the tests that they were like, bad done.
alagoconde Apr 25, 2024
73109e5
Code improvements in the games.
alagoconde Apr 25, 2024
c34a620
Updated de Multiplayer Game principal view.
alagoconde Apr 25, 2024
333a5b6
Finished updating the Multiplayer style.
alagoconde Apr 25, 2024
1060b5c
Updated the multiplayer tests to match the new style.
alagoconde Apr 25, 2024
375dac7
Merge branch 'develop' into develop-teresa
uo288347 Apr 26, 2024
0f080d7
Merge pull request #322 from Arquisoft/develop-teresa
uo288543 Apr 26, 2024
8f30cd6
Merge branch 'develop' into develop-hugo
uo288543 Apr 26, 2024
2f829c0
Merge branch 'develop' into develop-deploy
uo288543 Apr 26, 2024
439f287
add force true
uo288543 Apr 26, 2024
a409b17
remove force true
uo288543 Apr 26, 2024
4d82448
Removed absolute height in circular progress in games
PabloGOP Apr 26, 2024
bf49165
Solved not passing e2e discovering cities tests
PabloGOP Apr 26, 2024
00fa20e
Solved failing e2e wise men tests
PabloGOP Apr 26, 2024
03273bd
Solved style dependant e2e tests
PabloGOP Apr 26, 2024
c35c96c
Minor error in test-id for the answers
PabloGOP Apr 26, 2024
118c961
Usual duplication problem in unit tests for warm question
PabloGOP Apr 26, 2024
7c37444
Same for thechallenge + failing test
PabloGOP Apr 26, 2024
59ca40a
added force true
uo289689 Apr 26, 2024
b558dc6
Removed incorrect prog bar test in Game
PabloGOP Apr 26, 2024
f2f29f3
Fixed sonar cloud issue with label for the pause button
PabloGOP Apr 26, 2024
899b4cb
Removed flaky e2e test (note the two last action runs)
PabloGOP Apr 26, 2024
0cec2c1
Fixed error on get the statistics of an user
uo289689 Apr 26, 2024
620cb67
Merge branch 'develop_samuel' into develop-deploy
uo289689 Apr 26, 2024
04ed7c6
Merge branch 'develop-deploy' of https://github.com/Arquisoft/wiq_es0…
uo289689 Apr 26, 2024
8ad436b
Added tests for warm question (fuck sonar cloud)
PabloGOP Apr 26, 2024
17462bd
Duplicity in unit tests in multiplayer + added test for the coverage
PabloGOP Apr 26, 2024
659efad
fixed tests
uo289689 Apr 26, 2024
879229b
Merge branch 'develop_samuel' into develop-deploy
uo289689 Apr 26, 2024
98e8c7b
Implemented redirecction to /login or /homepage in home
uo289689 Apr 26, 2024
e8a0e69
Merge branch 'develop-pabloYalberto-fixes' into develop-pablo-nav
PabloGOP Apr 26, 2024
27b588c
Fixed home tests
uo289689 Apr 26, 2024
50ff88a
Merge pull request #323 from Arquisoft/develop-pabloYalberto-fixes
uo289689 Apr 26, 2024
db48c64
Refactored pages to clean the directory
PabloGOP Apr 26, 2024
fe24bd5
Adapted unit tests
PabloGOP Apr 26, 2024
884dcc2
Merge remote-tracking branch 'origin/develop' into develop_samuel
uo289689 Apr 26, 2024
fe013d3
I forgot a path hehe
PabloGOP Apr 26, 2024
1e95303
fixed error e2e
uo289689 Apr 26, 2024
0c510f5
Updated Chat component test as it has a route to multiplayer room too
PabloGOP Apr 26, 2024
60299ae
Merge pull request #330 from Arquisoft/develop-pablo-refactor-pages
PabloGOP Apr 26, 2024
fb601d6
Moved logo to the right of the menu in mobile
PabloGOP Apr 26, 2024
a165b6e
Eluded code repetition in logo
PabloGOP Apr 26, 2024
6e8795e
Solved lang menu display issue
PabloGOP Apr 26, 2024
d280b6b
Improved nav layout
PabloGOP Apr 26, 2024
20b6bcc
LGTM
PabloGOP Apr 27, 2024
1aa04ae
fixed .json error
uo289689 Apr 27, 2024
d85a4df
Sorry guys I had messed up :(
PabloGOP Apr 27, 2024
d3af04c
Update code to include only last rectangle button
uo288543 Apr 27, 2024
d787974
Merge branch 'develop' into develop-hugo
uo288543 Apr 27, 2024
417c693
Merge remote-tracking branch 'origin/develop' into develop_samuel
uo289689 Apr 27, 2024
c0a2070
Merge pull request #321 from Arquisoft/develop-hugo
uo288543 Apr 27, 2024
2b7ca8a
Updated the challange game
uo289689 Apr 27, 2024
8896ea2
Merge branch 'develop' into develop_samuel
uo289689 Apr 27, 2024
c3af4e2
Merge pull request #331 from Arquisoft/develop_samuel
uo288543 Apr 27, 2024
1a51a64
margin for multiplayer
uo288543 Apr 27, 2024
2ea80b4
Merge branch 'develop' into develop-hugo
uo288543 Apr 27, 2024
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build
on:
push:
branches: [master, develop, develop-deploy, develop-teresa]
branches: [master, develop, develop-deploy, develop-teresa, develop_samuel]

pull_request:
types: [opened, synchronize, reopened]
Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- "27017:27017"
networks:
- mynetwork
restart: always

mariadb:
container_name: mariadb
Expand All @@ -24,6 +25,7 @@ services:
- "3306:3306"
networks:
- mynetwork
restart: always

users:
container_name: users
Expand All @@ -38,6 +40,7 @@ services:
- mynetwork
environment:
DATABASE_URL: mariadb:3306/userdb
restart: always

questions:
container_name: questions
Expand All @@ -53,6 +56,7 @@ services:
environment:
DATABASE_URI: mongodb://mongodb:27017/questionDB
TEST_DATABASE_URI: mongodb://mongodb:27017/test
restart: always

gatewayservice:
container_name: gatewayservice
Expand All @@ -69,6 +73,7 @@ services:
environment:
USER_SERVICE_URL: http://users:8001
QUESTION_SERVICE_URL: http://questions:8010
restart: always

webapp:
container_name: webapp
Expand All @@ -85,6 +90,7 @@ services:
environment:
REACT_APP_API_ENDPOINT: http://gatewayservice:8000
REACT_APP_MULTIPLAYER_ENDPOINT: http://multiplayer:5010
restart: always

multiplayer:
container_name: multiplayer
Expand All @@ -100,6 +106,7 @@ services:
environment:
WEBAPP_ENDPOINT: http://webapp:3000
GATEWAY_SERVICE_ENDPOINT: http://gatewayservice:8000
restart: always

prometheus:
image: prom/prometheus
Expand All @@ -114,6 +121,7 @@ services:
- "9090:9090"
depends_on:
- gatewayservice
restart: always

grafana:
image: grafana/grafana
Expand All @@ -133,6 +141,7 @@ services:
- "9091:9091"
depends_on:
- prometheus
restart: always

volumes:
mariadb_data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@
"steppedLine": false,
"targets": [
{
"expr": "sum(increase(http_request_duration_seconds_count[1m]))",
"expr": "sum(increase(http_request_duration_seconds_count[1h]))",
"interval": "",
"legendFormat": "Requests per minute",
"legendFormat": "Requests per hour",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Rate (R): Number of requests per minute",
"title": "Rate (R): Number of requests per hour",
"tooltip": {
"shared": true,
"sort": 0,
Expand Down Expand Up @@ -189,7 +189,7 @@
"steppedLine": false,
"targets": [
{
"expr": "sum(increase(http_request_duration_seconds_count{code=~\"5.*\"}[1m]))",
"expr": "sum(increase(http_request_duration_seconds_count{status_code=~\"4.*\"}[1m]))",
"interval": "",
"legendFormat": "",
"refId": "A"
Expand Down Expand Up @@ -369,7 +369,7 @@
]
},
"timezone": "",
"title": "Example Service Dashboard",
"title": "Wiq_es04 Dashboard",
"uid": "1DYaynomMk",
"version": 2
}
2 changes: 1 addition & 1 deletion gatewayservice/monitoring/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
global:
scrape_interval: 5s
scrape_configs:
- job_name: "example-nodejs-app"
- job_name: "wiq-es04-nodejs-app"
static_configs:
- targets: ["gatewayservice:8000"]
6 changes: 3 additions & 3 deletions multiplayer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const app = express();
const server = http.createServer(app);
const io = socketIO(server, {
cors: { //permit connections from webapp
origin: [process.env.WEBAPP_ENDPOINT, "http://localhost:3000"],
//origin: "*", //this should be changed to improve security
//origin: [process.env.WEBAPP_ENDPOINT, "http://localhost:3000"],
origin: "*", //this should be changed to improve security
methods: ["GET", "POST"],
//allowedHeaders: "*" //this should be changed to improve security
allowedHeaders: "*" //this should be changed to improve security
}
});

Expand Down
105 changes: 89 additions & 16 deletions questions/__tests/routes/question-routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const bodyParser = require('body-parser');
let mongoServer;
let questionFunctions;
let questionRoutes;
let generateQuestionsService;

//let mongoServer;
let app = express();
Expand All @@ -21,11 +22,11 @@ const questionData1 = {
};

const questionData2 = {
question: "Which is the capital of UK?",
question: "Which is the capital of Spain?",
options: ["Madrid", "Barcelona", "Paris", "London"],
correctAnswer: "London",
categories: ["Geography"],
language: "es"
language: "en"
};

async function addingQuestion(questionData) {
Expand All @@ -40,6 +41,12 @@ async function addingQuestion(questionData) {
await questionFunctions.addQuestion(newQuestion);
}

async function addingQuestions() {
for(var i = 0; i < 24; i++) {
await addingQuestion(questionData1);
await addingQuestion(questionData2);
}
}

beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
Expand All @@ -48,19 +55,17 @@ beforeAll(async () => {
await mongoose.connect(mongoURI);
questionFunctions = require('../../services/question-data-service');
questionRoutes = require('../../routes/question-routes.js');
generateQuestionsService = require('../../services/generate-questions-service');
jest.mock('../../services/generate-questions-service');
app.use(bodyParser.json());
app.use('/questions', questionRoutes);

});

beforeEach(async () => {
//Load database with initial conditions
//await mongoose.connection.dropDatabase();
await Question.deleteMany({});
for(var i = 0; i < 100; i++) {
await addingQuestion(questionData1);
await addingQuestion(questionData2);
}
await addingQuestions();
});

afterAll(async () => {
Expand All @@ -71,25 +76,92 @@ beforeEach(async () => {


describe('Question routes', function() {
it('It should get a question from the database', async function() {

describe('Get a question from the database', function() {
it('get question when 0 questions', async function() {
await Question.deleteMany({});
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/es');
await expect(response.status).toBe(200);
await expect(response.body.question).toBe(undefined);
});

it('get question when less than 50 questions', async function() {
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/en');
await expect(response.status).toBe(200);
await expect(response.body.question).toBe('Which is the capital of Spain?');
});


it('It should get n questions from the database', async function() {
const response = await request(app).get('/questions/getQuestionsFromDb/3/en');
it('get question when less than 100 questions', async function() {
await addingQuestions();
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(3);
});
await expect(response.body.question).toBe('Which is the capital of Spain?');
});

it('get question when more than 100 questions', async function() {
await addingQuestions();
await addingQuestions();
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/en');
await expect(response.status).toBe(200);
await expect(response.body.question).toBe('Which is the capital of Spain?');
});
});
describe('Get n questions from the database', function() {
it('get question when less than 50 questions', async function() {
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/getQuestionsFromDb/3/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(3);
});

it('get question when less than 100 questions', async function() {
await addingQuestions();
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/getQuestionsFromDb/3/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(3);
});

it('get question when more than 100 questions', async function() {
await addingQuestions();
await addingQuestions();
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/getQuestionsFromDb/3/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(3);
});

it('It should not get n questions from the database', async function() {
const response = await request(app).get('/questions/getQuestionsFromDb/-1/en');
await expect(response.status).toBe(400);
});

it('It should get n questions of certain category from the database', async function() {
});
describe('Get n questions from the database filtered by category', function() {

it('get question when less than 50 questions', async function() {
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/getQuestionsFromDb/2/Geography/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(2);
await expect(response.body[0].categories[0]).toBe("Geography");
});
it('get question when less than 100 questions', async function() {
await addingQuestions();
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/getQuestionsFromDb/2/Geography/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(2);
await expect(response.body[0].categories[0]).toBe("Geography");
});

it('get question when more than 100 questions', async function() {
await addingQuestions();
await addingQuestions();
await generateQuestionsService.generateQuestions.mockResolvedValue({"response":{"status":"200"}});
const response = await request(app).get('/questions/getQuestionsFromDb/2/Geography/en');
await expect(response.status).toBe(200);
await expect(response.body.length).toBe(2);
Expand All @@ -106,4 +178,5 @@ describe('Question routes', function() {
it('should connect to the MongoDB server in memory', async () => {
expect(mongoose.connection.readyState).toBe(1); // 1 means connected
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Question generation', function() {

dbService.addQuestion.mockResolvedValue();
// Llama a la función que deseas probar
await generator.generateQuestions(1);
await generator.generateQuestions(1,"en","Geography");

// Verifica que la función haya realizado las operaciones esperadas
expect(dbService.addQuestion).toHaveBeenCalledTimes(1);
Expand All @@ -76,7 +76,7 @@ describe('Question generation', function() {

console.error = jest.fn();
// Llama a la función que deseas probar
await generator.generateQuestions(1);
await generator.generateQuestions(1,"en");

// Verifica que la función haya realizado las operaciones esperadas
expect(dbService.addQuestion).toHaveBeenCalledTimes(0);
Expand Down
Loading