diff --git a/docs/quiz/quiz-schema.yaml b/docs/quiz/quiz-schema.yaml
index 42720b86..d6288cd3 100644
--- a/docs/quiz/quiz-schema.yaml
+++ b/docs/quiz/quiz-schema.yaml
@@ -31,7 +31,7 @@ definitions:
type: boolean
pointValues:
type: boolean
- scoredResponces:
+ scoredResponses:
type: boolean
correctAnswers:
type: boolean
@@ -66,7 +66,7 @@ definitions:
type: boolean
pointValues:
type: boolean
- scoredResponces:
+ scoredResponses:
type: boolean
correctAnswers:
type: boolean
@@ -100,7 +100,7 @@ definitions:
type: boolean
pointValues:
type: boolean
- scoredResponces:
+ scoredResponses:
type: boolean
correctAnswers:
type: boolean
diff --git a/docs/quiz/quiz.yaml b/docs/quiz/quiz.yaml
index 23e066b6..f8c786fd 100644
--- a/docs/quiz/quiz.yaml
+++ b/docs/quiz/quiz.yaml
@@ -49,7 +49,7 @@ paths:
view: Scroll,
shuffle: true,
pointValues: false,
- scoredResponces: false,
+ scoredResponses: false,
correctAnswers: true
}
- _id: 64ca5932b57f2442403394a9
@@ -61,7 +61,7 @@ paths:
view: Scroll,
shuffle: true,
pointValues: false,
- scoredResponces: false,
+ scoredResponses: false,
correctAnswers: true
}
count: 2
@@ -122,7 +122,7 @@ paths:
view: Scroll,
shuffle: false,
pointValues: false,
- scoredResponces: false,
+ scoredResponses: false,
correctAnswers: false
}
createdAt: 2023-02-14T23:44:21.334Z
@@ -182,7 +182,7 @@ paths:
view: Scroll,
shuffle: true,
pointValues: false,
- scoredResponces: false,
+ scoredResponses: false,
correctAnswers: true
}
401:
diff --git a/models/quiz.js b/models/quiz.js
index d6cf9919..f9c4b2dd 100644
--- a/models/quiz.js
+++ b/models/quiz.js
@@ -63,7 +63,7 @@ const quizSchema = new Schema(
type: Boolean,
default: false
},
- scoredResponces: {
+ scoredResponses: {
type: Boolean,
default: false
},
diff --git a/test/integration/controllers/lesson.spec.js b/test/integration/controllers/lesson.spec.js
index f98e1834..e130968e 100644
--- a/test/integration/controllers/lesson.spec.js
+++ b/test/integration/controllers/lesson.spec.js
@@ -11,7 +11,7 @@ const testLesson = {
title: 'title',
description: 'description',
category: '6502ec2060ec37be943353e2',
- content: '
Title
',
+ content: 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
',
attachments: ['65bed8ef260f18d04ab22da3', '65bed9ef260f19d05ab25bc6']
}
diff --git a/test/integration/controllers/message.spec.js b/test/integration/controllers/message.spec.js
index ed10a2fb..11a87280 100644
--- a/test/integration/controllers/message.spec.js
+++ b/test/integration/controllers/message.spec.js
@@ -169,16 +169,19 @@ describe('Message controller', () => {
describe(`PATCH ${endpointUrl}`, () => {
it('should clear chat history for current user', async () => {
- const response = await app.patch(endpointUrl(messageBody.chat)).set('Authorization', `Bearer ${accessToken}`)
+ const response = await app.patch(endpointUrl(messageBody.chat)).set('Cookie', [`accessToken=${accessToken}`])
expect(response.statusCode).toBe(200)
expect(response.body).toEqual(clearedStatusBody)
})
it('should throw NOT MODIFIED if there is nothing to clear', async () => {
- chatResponse = await app.post(chatEndpointUrl).set('Authorization', `Bearer ${accessToken}`).send(chatBody)
+ chatResponse = await app
+ .post(chatEndpointUrl)
+ .set('Cookie', [`accessToken=${accessToken}`])
+ .send(chatBody)
messageBody.chat = chatResponse.body._id
- const response = await app.patch(endpointUrl(messageBody.chat)).set('Authorization', `Bearer ${accessToken}`)
+ const response = await app.patch(endpointUrl(messageBody.chat)).set('Cookie', [`accessToken=${accessToken}`])
expect(response.statusCode).toBe(304)
})
@@ -194,13 +197,13 @@ describe('Message controller', () => {
const response = await app
.patch(endpointUrl(messageBody.chat))
- .set('Authorization', `Bearer ${accessTokenForbidden}`)
+ .set('Cookie', [`accessToken=${accessTokenForbidden}`])
expectError(403, FORBIDDEN, response)
})
it('should throw DOCUMENT_NOT_FOUND for chat', async () => {
- const response = await app.patch(endpointUrl(nonExistingChatId)).set('Authorization', `Bearer ${accessToken}`)
+ const response = await app.patch(endpointUrl(nonExistingChatId)).set('Cookie', [`accessToken=${accessToken}`])
expectError(404, DOCUMENT_NOT_FOUND([Chat.modelName]), response)
})
diff --git a/test/integration/controllers/notification.spec.js b/test/integration/controllers/notification.spec.js
index 236ac592..df82ea67 100644
--- a/test/integration/controllers/notification.spec.js
+++ b/test/integration/controllers/notification.spec.js
@@ -1,6 +1,9 @@
const { serverInit, serverCleanup, stopServer } = require('~/test/setup')
const { expectError } = require('~/test/helpers')
const { UNAUTHORIZED, DOCUMENT_NOT_FOUND } = require('~/consts/errors')
+const {
+ enums: { NOTIFICATION_TYPE_ENUM }
+} = require('~/consts/validation')
const testUserAuthentication = require('~/utils/testUserAuth')
const Notification = require('~/models/notification')
const TokenService = require('~/services/token')
@@ -29,7 +32,7 @@ describe('Notification controller', () => {
testNotification = await Notification.create({
user: currentUser.id,
userRole: currentUser.role,
- type: 'review',
+ type: NOTIFICATION_TYPE_ENUM[0],
...testNotificationData
})
})
@@ -43,7 +46,7 @@ describe('Notification controller', () => {
})
describe(`GET ${endpointUrl}`, () => {
- it("should get user's notifications and count them", async () => {
+ it('should get user`s notifications and count them', async () => {
const response = await app.get(endpointUrl).set('Cookie', [`accessToken=${accessToken}`])
expect(response.statusCode).toBe(200)
@@ -64,7 +67,7 @@ describe('Notification controller', () => {
})
describe(`DELETE ${endpointUrl}`, () => {
- it("should clear all user's notifications", async () => {
+ it('should clear all user`s notifications', async () => {
const response = await app.delete(endpointUrl).set('Cookie', [`accessToken=${accessToken}`])
const notifications = await app.get(endpointUrl).set('Cookie', [`accessToken=${accessToken}`])
diff --git a/test/integration/controllers/quiz.spec.js b/test/integration/controllers/quiz.spec.js
index 46e39103..2bbba9bb 100644
--- a/test/integration/controllers/quiz.spec.js
+++ b/test/integration/controllers/quiz.spec.js
@@ -6,19 +6,40 @@ const TokenService = require('~/services/token')
const {
roles: { TUTOR }
} = require('~/consts/auth')
+const {
+ enums: { QUIZ_VIEW_ENUM }
+} = require('~/consts/validation')
const endpointUrl = '/quizzes/'
+const questionEndpointUrl = '/questions/'
const testQuizData = {
title: 'Assembly',
description: 'Description',
- items: ['6527ed6c14c6b72f36962364']
+ settings: {
+ correctAnswers: false,
+ pointValues: false,
+ scoredResponses: false,
+ shuffle: false,
+ view: QUIZ_VIEW_ENUM[1]
+ }
}
const updateData = {
title: 'WebAssembly'
}
+const testQuestionData = {
+ title: 'Assembly',
+ text: 'What is Assembly',
+ answers: [
+ { text: 'Yes', isCorrect: true },
+ { text: 'Yes, of course', isCorrect: false }
+ ],
+ category: null,
+ type: 'multipleChoice'
+}
+
const studentUserData = {
role: 'student',
firstName: 'Yamada',
@@ -32,7 +53,7 @@ const studentUserData = {
}
describe('Quiz controller', () => {
- let app, server, accessToken, currentUser, studentAccessToken, testQuiz, testQuizId
+ let app, server, accessToken, currentUser, studentAccessToken, testQuiz, testQuizId, testQuestion, testQuestionId
beforeAll(async () => {
;({ app, server } = await serverInit())
@@ -44,10 +65,16 @@ describe('Quiz controller', () => {
currentUser = TokenService.validateAccessToken(accessToken)
+ testQuestion = await app
+ .post(questionEndpointUrl)
+ .send(testQuestionData)
+ .set('Cookie', [`accessToken=${accessToken}`])
+ testQuestionId = testQuestion._body._id
+
testQuiz = await app
.post(endpointUrl)
.set('Cookie', [`accessToken=${accessToken}`])
- .send(testQuizData)
+ .send({ ...testQuizData, items: [testQuestionId] })
testQuizId = testQuiz.body._id
})
@@ -101,7 +128,8 @@ describe('Quiz controller', () => {
createdAt: expect.any(String),
updatedAt: expect.any(String),
...testQuizData,
- category: null
+ category: null,
+ items: [testQuestionId]
}
],
count: 1
@@ -131,7 +159,15 @@ describe('Quiz controller', () => {
author: currentUser.id,
createdAt: expect.any(String),
updatedAt: expect.any(String),
- ...testQuizData
+ ...testQuizData,
+ items: [
+ {
+ _id: testQuestionId,
+ title: testQuestionData.title,
+ text: testQuestionData.text,
+ answers: testQuestionData.answers
+ }
+ ]
})
})