diff --git a/README.md b/README.md index 450d18db..d34adf53 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,9 @@ De tech-stack bestaat uit: Voor meer informatie over de keuze van deze tech-stack, zie [designkeuzes](https://github.com/SELab-2/Dwengo-1/wiki/Developer:-Design-keuzes). ## Testen + Voer volgende commando's uit om de te testen: + ``` npm run test:unit ``` diff --git a/backend/README.md b/backend/README.md index f0a9c746..442cea82 100644 --- a/backend/README.md +++ b/backend/README.md @@ -22,7 +22,9 @@ npm run start ``` ### Tests + Voer volgend commando uit om de unit tests uit te voeren: + ``` npm run test:unit ``` diff --git a/backend/src/data/questions/answer-repository.ts b/backend/src/data/questions/answer-repository.ts index 3447ec35..a28342bd 100644 --- a/backend/src/data/questions/answer-repository.ts +++ b/backend/src/data/questions/answer-repository.ts @@ -4,19 +4,13 @@ import { Question } from '../../entities/questions/question.entity.js'; import { Teacher } from '../../entities/users/teacher.entity.js'; export class AnswerRepository extends DwengoEntityRepository { - public createAnswer(answer: { - toQuestion: Question; - author: Teacher; - content: string; - }): Promise { - const answerEntity = this.create( - { - toQuestion: answer.toQuestion, - author: answer.author, - content: answer.content, - timestamp: new Date() - } - ); + public createAnswer(answer: { toQuestion: Question; author: Teacher; content: string }): Promise { + const answerEntity = this.create({ + toQuestion: answer.toQuestion, + author: answer.author, + content: answer.content, + timestamp: new Date(), + }); return this.insert(answerEntity); } public findAllAnswersToQuestion(question: Question): Promise { diff --git a/backend/src/data/questions/question-repository.ts b/backend/src/data/questions/question-repository.ts index fed2a56e..4099c528 100644 --- a/backend/src/data/questions/question-repository.ts +++ b/backend/src/data/questions/question-repository.ts @@ -11,7 +11,7 @@ export class QuestionRepository extends DwengoEntityRepository { learningObjectVersion: question.loId.version, author: question.author, content: question.content, - timestamp: new Date() + timestamp: new Date(), }); questionEntity.learningObjectHruid = question.loId.hruid; questionEntity.learningObjectLanguage = question.loId.language; diff --git a/backend/src/mikro-orm.config.ts b/backend/src/mikro-orm.config.ts index d02e3700..c9cf6ed9 100644 --- a/backend/src/mikro-orm.config.ts +++ b/backend/src/mikro-orm.config.ts @@ -24,7 +24,7 @@ import { LearningPath } from './entities/content/learning-path.entity.js'; import { Answer } from './entities/questions/answer.entity.js'; import { Question } from './entities/questions/question.entity.js'; -import {SqliteAutoincrementSubscriber} from "./sqlite-autoincrement-workaround.js"; +import { SqliteAutoincrementSubscriber } from './sqlite-autoincrement-workaround.js'; const entities = [ User, diff --git a/backend/src/orm.ts b/backend/src/orm.ts index d9c0057e..93feea7a 100644 --- a/backend/src/orm.ts +++ b/backend/src/orm.ts @@ -1,4 +1,4 @@ -import {EntityManager, MikroORM} from '@mikro-orm/core'; +import { EntityManager, MikroORM } from '@mikro-orm/core'; import config from './mikro-orm.config.js'; import { EnvVars, getEnvVar } from './util/envvars.js'; import { getLogger, Logger } from './logging/initalize.js'; diff --git a/backend/src/sqlite-autoincrement-workaround.ts b/backend/src/sqlite-autoincrement-workaround.ts index 66093ec4..a5c20dfd 100644 --- a/backend/src/sqlite-autoincrement-workaround.ts +++ b/backend/src/sqlite-autoincrement-workaround.ts @@ -1,4 +1,4 @@ -import {EntityProperty, EventArgs, EventSubscriber} from "@mikro-orm/core"; +import { EntityProperty, EventArgs, EventSubscriber } from '@mikro-orm/core'; /** * The tests are ran on an in-memory SQLite database. However, SQLite does not allow fields which are part of composite @@ -29,7 +29,7 @@ export class SqliteAutoincrementSubscriber implements EventSubscriber { const property = prop as EntityProperty; if (property.primary && property.autoincrement && !(args.entity as Record)[property.name]) { // Obtain and increment sequence number of this entity. - const propertyKey = args.meta.class.name + "." + property.name; + const propertyKey = args.meta.class.name + '.' + property.name; const nextSeqNumber = this.sequenceNumbersForEntityType.get(propertyKey) || 0; this.sequenceNumbersForEntityType.set(propertyKey, nextSeqNumber + 1); diff --git a/backend/tests/data/assignments/assignments.test.ts b/backend/tests/data/assignments/assignments.test.ts index d091722f..c26fb5ba 100644 --- a/backend/tests/data/assignments/assignments.test.ts +++ b/backend/tests/data/assignments/assignments.test.ts @@ -1,10 +1,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository'; -import { - getAssignmentRepository, - getClassRepository, -} from '../../../src/data/repositories'; +import { getAssignmentRepository, getClassRepository } from '../../../src/data/repositories'; import { ClassRepository } from '../../../src/data/classes/class-repository'; describe('AssignmentRepository', () => { @@ -19,10 +16,7 @@ describe('AssignmentRepository', () => { it('should return the requested assignment', async () => { const class_ = await classRepository.findById('id02'); - const assignment = await assignmentRepository.findByClassAndId( - class_!, - 2 - ); + const assignment = await assignmentRepository.findByClassAndId(class_!, 2); expect(assignment).toBeTruthy(); expect(assignment!.title).toBe('tool'); @@ -30,8 +24,7 @@ describe('AssignmentRepository', () => { it('should return all assignments for a class', async () => { const class_ = await classRepository.findById('id02'); - const assignments = - await assignmentRepository.findAllAssignmentsInClass(class_!); + const assignments = await assignmentRepository.findAllAssignmentsInClass(class_!); expect(assignments).toBeTruthy(); expect(assignments).toHaveLength(1); @@ -42,10 +35,7 @@ describe('AssignmentRepository', () => { const class_ = await classRepository.findById('id01'); await assignmentRepository.deleteByClassAndId(class_!, 3); - const assignment = await assignmentRepository.findByClassAndId( - class_!, - 3 - ); + const assignment = await assignmentRepository.findByClassAndId(class_!, 3); expect(assignment).toBeNull(); }); diff --git a/backend/tests/data/assignments/groups.test.ts b/backend/tests/data/assignments/groups.test.ts index d82f7e1f..96684d68 100644 --- a/backend/tests/data/assignments/groups.test.ts +++ b/backend/tests/data/assignments/groups.test.ts @@ -1,11 +1,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; import { GroupRepository } from '../../../src/data/assignments/group-repository'; -import { - getAssignmentRepository, - getClassRepository, - getGroupRepository, -} from '../../../src/data/repositories'; +import { getAssignmentRepository, getClassRepository, getGroupRepository } from '../../../src/data/repositories'; import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository'; import { ClassRepository } from '../../../src/data/classes/class-repository'; @@ -23,29 +19,18 @@ describe('GroupRepository', () => { it('should return the requested group', async () => { const class_ = await classRepository.findById('id01'); - const assignment = await assignmentRepository.findByClassAndId( - class_!, - 1 - ); + const assignment = await assignmentRepository.findByClassAndId(class_!, 1); - const group = await groupRepository.findByAssignmentAndGroupNumber( - assignment!, - 1 - ); + const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1); expect(group).toBeTruthy(); }); it('should return all groups for assignment', async () => { const class_ = await classRepository.findById('id01'); - const assignment = await assignmentRepository.findByClassAndId( - class_!, - 1 - ); + const assignment = await assignmentRepository.findByClassAndId(class_!, 1); - const groups = await groupRepository.findAllGroupsForAssignment( - assignment! - ); + const groups = await groupRepository.findAllGroupsForAssignment(assignment!); expect(groups).toBeTruthy(); expect(groups).toHaveLength(3); @@ -53,17 +38,11 @@ describe('GroupRepository', () => { it('should not find removed group', async () => { const class_ = await classRepository.findById('id02'); - const assignment = await assignmentRepository.findByClassAndId( - class_!, - 2 - ); + const assignment = await assignmentRepository.findByClassAndId(class_!, 2); await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1); - const group = await groupRepository.findByAssignmentAndGroupNumber( - assignment!, - 1 - ); + const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1); expect(group).toBeNull(); }); diff --git a/backend/tests/data/assignments/submissions.test.ts b/backend/tests/data/assignments/submissions.test.ts index 16b74a32..8712a710 100644 --- a/backend/tests/data/assignments/submissions.test.ts +++ b/backend/tests/data/assignments/submissions.test.ts @@ -33,11 +33,7 @@ describe('SubmissionRepository', () => { it('should find the requested submission', async () => { const id = new LearningObjectIdentifier('id03', Language.English, '1'); - const submission = - await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber( - id, - 1 - ); + const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(id, 1); expect(submission).toBeTruthy(); expect(submission?.content).toBe('sub1'); @@ -46,11 +42,7 @@ describe('SubmissionRepository', () => { it('should find the most recent submission for a student', async () => { const id = new LearningObjectIdentifier('id02', Language.English, '1'); const student = await studentRepository.findByUsername('Noordkaap'); - const submission = - await submissionRepository.findMostRecentSubmissionForStudent( - id, - student! - ); + const submission = await submissionRepository.findMostRecentSubmissionForStudent(id, student!); expect(submission).toBeTruthy(); expect(submission?.submissionTime.getDate()).toBe(25); @@ -59,19 +51,9 @@ describe('SubmissionRepository', () => { it('should find the most recent submission for a group', async () => { const id = new LearningObjectIdentifier('id03', Language.English, '1'); const class_ = await classRepository.findById('id01'); - const assignment = await assignmentRepository.findByClassAndId( - class_!, - 1 - ); - const group = await groupRepository.findByAssignmentAndGroupNumber( - assignment!, - 1 - ); - const submission = - await submissionRepository.findMostRecentSubmissionForGroup( - id, - group! - ); + const assignment = await assignmentRepository.findByClassAndId(class_!, 1); + const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1); + const submission = await submissionRepository.findMostRecentSubmissionForGroup(id, group!); expect(submission).toBeTruthy(); expect(submission?.submissionTime.getDate()).toBe(25); @@ -79,16 +61,9 @@ describe('SubmissionRepository', () => { it('should not find a deleted submission', async () => { const id = new LearningObjectIdentifier('id01', Language.English, '1'); - await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber( - id, - 1 - ); + await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(id, 1); - const submission = - await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber( - id, - 1 - ); + const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(id, 1); expect(submission).toBeNull(); }); diff --git a/backend/tests/data/classes/class-join-request.test.ts b/backend/tests/data/classes/class-join-request.test.ts index 23aabcb6..f0aa2f62 100644 --- a/backend/tests/data/classes/class-join-request.test.ts +++ b/backend/tests/data/classes/class-join-request.test.ts @@ -1,11 +1,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository'; -import { - getClassJoinRequestRepository, - getClassRepository, - getStudentRepository, -} from '../../../src/data/repositories'; +import { getClassJoinRequestRepository, getClassRepository, getStudentRepository } from '../../../src/data/repositories'; import { StudentRepository } from '../../../src/data/users/student-repository'; import { Class } from '../../../src/entities/classes/class.entity'; import { ClassRepository } from '../../../src/data/classes/class-repository'; @@ -25,9 +21,7 @@ describe('ClassJoinRequestRepository', () => { it('should list all requests from student to join classes', async () => { const student = await studentRepository.findByUsername('PinkFloyd'); - const requests = await classJoinRequestRepository.findAllRequestsBy( - student! - ); + const requests = await classJoinRequestRepository.findAllRequestsBy(student!); expect(requests).toBeTruthy(); expect(requests).toHaveLength(2); @@ -35,23 +29,18 @@ describe('ClassJoinRequestRepository', () => { it('should list all requests to a single class', async () => { const class_ = await cassRepository.findById('id02'); - const requests = await classJoinRequestRepository.findAllOpenRequestsTo( - class_! - ); + const requests = await classJoinRequestRepository.findAllOpenRequestsTo(class_!); expect(requests).toBeTruthy(); expect(requests).toHaveLength(2); }); it('should not find a removed request', async () => { - const student = - await studentRepository.findByUsername('SmashingPumpkins'); + const student = await studentRepository.findByUsername('SmashingPumpkins'); const class_ = await cassRepository.findById('id03'); await classJoinRequestRepository.deleteBy(student!, class_!); - const request = await classJoinRequestRepository.findAllRequestsBy( - student! - ); + const request = await classJoinRequestRepository.findAllRequestsBy(student!); expect(request).toHaveLength(0); }); diff --git a/backend/tests/data/classes/teacher-invitation.test.ts b/backend/tests/data/classes/teacher-invitation.test.ts index f5257286..dd03634a 100644 --- a/backend/tests/data/classes/teacher-invitation.test.ts +++ b/backend/tests/data/classes/teacher-invitation.test.ts @@ -1,10 +1,6 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; -import { - getClassRepository, - getTeacherInvitationRepository, - getTeacherRepository, -} from '../../../src/data/repositories'; +import { getClassRepository, getTeacherInvitationRepository, getTeacherRepository } from '../../../src/data/repositories'; import { TeacherInvitationRepository } from '../../../src/data/classes/teacher-invitation-repository'; import { TeacherRepository } from '../../../src/data/users/teacher-repository'; import { ClassRepository } from '../../../src/data/classes/class-repository'; @@ -23,8 +19,7 @@ describe('ClassRepository', () => { it('should return all invitations from a teacher', async () => { const teacher = await teacherRepository.findByUsername('LimpBizkit'); - const invitations = - await teacherInvitationRepository.findAllInvitationsBy(teacher!); + const invitations = await teacherInvitationRepository.findAllInvitationsBy(teacher!); expect(invitations).toBeTruthy(); expect(invitations).toHaveLength(2); @@ -32,8 +27,7 @@ describe('ClassRepository', () => { it('should return all invitations for a teacher', async () => { const teacher = await teacherRepository.findByUsername('FooFighters'); - const invitations = - await teacherInvitationRepository.findAllInvitationsFor(teacher!); + const invitations = await teacherInvitationRepository.findAllInvitationsFor(teacher!); expect(invitations).toBeTruthy(); expect(invitations).toHaveLength(2); @@ -41,10 +35,7 @@ describe('ClassRepository', () => { it('should return all invitations for a class', async () => { const class_ = await classRepository.findById('id02'); - const invitations = - await teacherInvitationRepository.findAllInvitationsForClass( - class_! - ); + const invitations = await teacherInvitationRepository.findAllInvitationsForClass(class_!); expect(invitations).toBeTruthy(); expect(invitations).toHaveLength(2); @@ -56,8 +47,7 @@ describe('ClassRepository', () => { const receiver = await teacherRepository.findByUsername('LimpBizkit'); await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!); - const invitation = - await teacherInvitationRepository.findAllInvitationsBy(sender!); + const invitation = await teacherInvitationRepository.findAllInvitationsBy(sender!); expect(invitation).toHaveLength(0); }); diff --git a/backend/tests/data/content/attachments.test.ts b/backend/tests/data/content/attachments.test.ts index 539d0fd6..a8bea88a 100644 --- a/backend/tests/data/content/attachments.test.ts +++ b/backend/tests/data/content/attachments.test.ts @@ -1,9 +1,6 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests.js'; -import { - getAttachmentRepository, - getLearningObjectRepository, -} from '../../../src/data/repositories.js'; +import { getAttachmentRepository, getLearningObjectRepository } from '../../../src/data/repositories.js'; import { AttachmentRepository } from '../../../src/data/content/attachment-repository.js'; import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository.js'; import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier.js'; @@ -21,15 +18,13 @@ describe('AttachmentRepository', () => { it('should return the requested attachment', async () => { const id = new LearningObjectIdentifier('id02', Language.English, '1'); - const learningObject = - await learningObjectRepository.findByIdentifier(id); + const learningObject = await learningObjectRepository.findByIdentifier(id); - const attachment = - await attachmentRepository.findByMostRecentVersionOfLearningObjectAndName( - learningObject!, - Language.English, - 'attachment01' - ); + const attachment = await attachmentRepository.findByMostRecentVersionOfLearningObjectAndName( + learningObject!, + Language.English, + 'attachment01' + ); expect(attachment).toBeTruthy(); }); diff --git a/backend/tests/data/content/learning-objects.test.ts b/backend/tests/data/content/learning-objects.test.ts index 629aa318..51f9c98e 100644 --- a/backend/tests/data/content/learning-objects.test.ts +++ b/backend/tests/data/content/learning-objects.test.ts @@ -17,8 +17,7 @@ describe('LearningObjectRepository', () => { const id02 = new LearningObjectIdentifier('test_id', Language.English, '1'); it('should return the learning object that matches identifier 1', async () => { - const learningObject = - await learningObjectRepository.findByIdentifier(id01); + const learningObject = await learningObjectRepository.findByIdentifier(id01); expect(learningObject).toBeTruthy(); expect(learningObject?.title).toBe('Undertow'); @@ -26,8 +25,7 @@ describe('LearningObjectRepository', () => { }); it('should return nothing because the identifier does not exist in the database', async () => { - const learningObject = - await learningObjectRepository.findByIdentifier(id02); + const learningObject = await learningObjectRepository.findByIdentifier(id02); expect(learningObject).toBeNull(); }); diff --git a/backend/tests/data/content/learning-paths.test.ts b/backend/tests/data/content/learning-paths.test.ts index 984fd995..01fd20e5 100644 --- a/backend/tests/data/content/learning-paths.test.ts +++ b/backend/tests/data/content/learning-paths.test.ts @@ -13,21 +13,13 @@ describe('LearningPathRepository', () => { }); it('should return nothing because no match for hruid and language', async () => { - const learningPath = - await learningPathRepository.findByHruidAndLanguage( - 'test_id', - Language.Dutch - ); + const learningPath = await learningPathRepository.findByHruidAndLanguage('test_id', Language.Dutch); expect(learningPath).toBeNull(); }); it('should return requested learning path', async () => { - const learningPath = - await learningPathRepository.findByHruidAndLanguage( - 'id01', - Language.English - ); + const learningPath = await learningPathRepository.findByHruidAndLanguage('id01', Language.English); expect(learningPath).toBeTruthy(); expect(learningPath?.title).toBe('repertoire Tool'); diff --git a/backend/tests/data/questions/answers.test.ts b/backend/tests/data/questions/answers.test.ts index 4b15c6b0..f15fed6a 100644 --- a/backend/tests/data/questions/answers.test.ts +++ b/backend/tests/data/questions/answers.test.ts @@ -1,11 +1,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; import { AnswerRepository } from '../../../src/data/questions/answer-repository'; -import { - getAnswerRepository, - getQuestionRepository, - getTeacherRepository, -} from '../../../src/data/repositories'; +import { getAnswerRepository, getQuestionRepository, getTeacherRepository } from '../../../src/data/repositories'; import { QuestionRepository } from '../../../src/data/questions/question-repository'; import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; import { Language } from '../../../src/entities/content/language'; @@ -25,13 +21,11 @@ describe('AnswerRepository', () => { it('should find all answers to a question', async () => { const id = new LearningObjectIdentifier('id05', Language.English, '1'); - const questions = - await questionRepository.findAllQuestionsAboutLearningObject(id); + const questions = await questionRepository.findAllQuestionsAboutLearningObject(id); const question = questions.filter((it) => it.sequenceNumber == 2)[0]; - const answers = - await answerRepository.findAllAnswersToQuestion(question); + const answers = await answerRepository.findAllAnswersToQuestion(question); expect(answers).toBeTruthy(); expect(answers).toHaveLength(2); @@ -42,8 +36,7 @@ describe('AnswerRepository', () => { it('should create an answer to a question', async () => { const teacher = await teacherRepository.findByUsername('FooFighters'); const id = new LearningObjectIdentifier('id05', Language.English, '1'); - const questions = - await questionRepository.findAllQuestionsAboutLearningObject(id); + const questions = await questionRepository.findAllQuestionsAboutLearningObject(id); const question = questions[0]; @@ -53,8 +46,7 @@ describe('AnswerRepository', () => { content: 'created answer', }); - const answers = - await answerRepository.findAllAnswersToQuestion(question); + const answers = await answerRepository.findAllAnswersToQuestion(question); expect(answers).toBeTruthy(); expect(answers).toHaveLength(1); @@ -63,17 +55,11 @@ describe('AnswerRepository', () => { it('should not find a removed answer', async () => { const id = new LearningObjectIdentifier('id04', Language.English, '1'); - const questions = - await questionRepository.findAllQuestionsAboutLearningObject(id); + const questions = await questionRepository.findAllQuestionsAboutLearningObject(id); - await answerRepository.removeAnswerByQuestionAndSequenceNumber( - questions[0], - 1 - ); + await answerRepository.removeAnswerByQuestionAndSequenceNumber(questions[0], 1); - const emptyList = await answerRepository.findAllAnswersToQuestion( - questions[0] - ); + const emptyList = await answerRepository.findAllAnswersToQuestion(questions[0]); expect(emptyList).toHaveLength(0); }); diff --git a/backend/tests/data/questions/questions.test.ts b/backend/tests/data/questions/questions.test.ts index dc0d6285..1a1cb034 100644 --- a/backend/tests/data/questions/questions.test.ts +++ b/backend/tests/data/questions/questions.test.ts @@ -1,11 +1,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; import { setupTestApp } from '../../setup-tests'; import { QuestionRepository } from '../../../src/data/questions/question-repository'; -import { - getLearningObjectRepository, - getQuestionRepository, - getStudentRepository, -} from '../../../src/data/repositories'; +import { getLearningObjectRepository, getQuestionRepository, getStudentRepository } from '../../../src/data/repositories'; import { StudentRepository } from '../../../src/data/users/student-repository'; import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository'; import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; @@ -25,8 +21,7 @@ describe('QuestionRepository', () => { it('should return all questions part of the given learning object', async () => { const id = new LearningObjectIdentifier('id05', Language.English, '1'); - const questions = - await questionRepository.findAllQuestionsAboutLearningObject(id); + const questions = await questionRepository.findAllQuestionsAboutLearningObject(id); expect(questions).toBeTruthy(); expect(questions).toHaveLength(2); @@ -40,8 +35,7 @@ describe('QuestionRepository', () => { author: student!, content: 'question?', }); - const question = - await questionRepository.findAllQuestionsAboutLearningObject(id); + const question = await questionRepository.findAllQuestionsAboutLearningObject(id); expect(question).toBeTruthy(); expect(question).toHaveLength(1); @@ -49,13 +43,9 @@ describe('QuestionRepository', () => { it('should not find removed question', async () => { const id = new LearningObjectIdentifier('id04', Language.English, '1'); - await questionRepository.removeQuestionByLearningObjectAndSequenceNumber( - id, - 1 - ); + await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(id, 1); - const question = - await questionRepository.findAllQuestionsAboutLearningObject(id); + const question = await questionRepository.findAllQuestionsAboutLearningObject(id); expect(question).toHaveLength(0); }); diff --git a/backend/tests/data/users/teachers.test.ts b/backend/tests/data/users/teachers.test.ts index 5aa69907..0bd014a6 100644 --- a/backend/tests/data/users/teachers.test.ts +++ b/backend/tests/data/users/teachers.test.ts @@ -30,12 +30,9 @@ describe('TeacherRepository', () => { }); it('should return the queried teacher after he was added', async () => { - await teacherRepository.insert( - new Teacher(username, firstName, lastName) - ); + await teacherRepository.insert(new Teacher(username, firstName, lastName)); - const retrievedTeacher = - await teacherRepository.findByUsername(username); + const retrievedTeacher = await teacherRepository.findByUsername(username); expect(retrievedTeacher).toBeTruthy(); expect(retrievedTeacher?.firstName).toBe(firstName); expect(retrievedTeacher?.lastName).toBe(lastName); @@ -44,8 +41,7 @@ describe('TeacherRepository', () => { it('should no longer return the queried teacher after he was removed again', async () => { await teacherRepository.deleteByUsername('ZesdeMetaal'); - const retrievedTeacher = - await teacherRepository.findByUsername('ZesdeMetaal'); + const retrievedTeacher = await teacherRepository.findByUsername('ZesdeMetaal'); expect(retrievedTeacher).toBeNull(); }); }); diff --git a/backend/tests/setup-tests.ts b/backend/tests/setup-tests.ts index 5f1bcbfd..9502bcb8 100644 --- a/backend/tests/setup-tests.ts +++ b/backend/tests/setup-tests.ts @@ -31,11 +31,7 @@ export async function setupTestApp() { assignments[0].groups = groups.slice(0, 3); assignments[1].groups = groups.slice(3, 4); - const teacherInvitations = makeTestTeacherInvitations( - em, - teachers, - classes - ); + const teacherInvitations = makeTestTeacherInvitations(em, teachers, classes); const classJoinRequests = makeTestClassJoinRequests(em, students, classes); const attachments = makeTestAttachments(em, learningObjects); diff --git a/backend/tests/test_assets/assignments/assignments.testdata.ts b/backend/tests/test_assets/assignments/assignments.testdata.ts index d5dae2d4..7f909de4 100644 --- a/backend/tests/test_assets/assignments/assignments.testdata.ts +++ b/backend/tests/test_assets/assignments/assignments.testdata.ts @@ -3,10 +3,7 @@ import { Assignment } from '../../../src/entities/assignments/assignment.entity' import { Class } from '../../../src/entities/classes/class.entity'; import { Language } from '../../../src/entities/content/language'; -export function makeTestAssignemnts( - em: EntityManager>, - classes: Array -): Array { +export function makeTestAssignemnts(em: EntityManager>, classes: Array): Array { const assignment01 = em.create(Assignment, { within: classes[0], id: 1, diff --git a/backend/tests/test_assets/assignments/submission.testdata.ts b/backend/tests/test_assets/assignments/submission.testdata.ts index 1e943926..058af70f 100644 --- a/backend/tests/test_assets/assignments/submission.testdata.ts +++ b/backend/tests/test_assets/assignments/submission.testdata.ts @@ -61,11 +61,5 @@ export function makeTestSubmissions( content: '', }); - return [ - submission01, - submission02, - submission03, - submission04, - submission05, - ]; + return [submission01, submission02, submission03, submission04, submission05]; } diff --git a/backend/tests/test_assets/classes/class-join-requests.testdata.ts b/backend/tests/test_assets/classes/class-join-requests.testdata.ts index e770ed6c..8d9e328f 100644 --- a/backend/tests/test_assets/classes/class-join-requests.testdata.ts +++ b/backend/tests/test_assets/classes/class-join-requests.testdata.ts @@ -1,8 +1,5 @@ import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; -import { - ClassJoinRequest, - ClassJoinRequestStatus, -} from '../../../src/entities/classes/class-join-request.entity'; +import { ClassJoinRequest, ClassJoinRequestStatus } from '../../../src/entities/classes/class-join-request.entity'; import { Student } from '../../../src/entities/users/student.entity'; import { Class } from '../../../src/entities/classes/class.entity'; @@ -35,10 +32,5 @@ export function makeTestClassJoinRequests( status: ClassJoinRequestStatus.Open, }); - return [ - classJoinRequest01, - classJoinRequest02, - classJoinRequest03, - classJoinRequest04, - ]; + return [classJoinRequest01, classJoinRequest02, classJoinRequest03, classJoinRequest04]; } diff --git a/backend/tests/test_assets/classes/classes.testdata.ts b/backend/tests/test_assets/classes/classes.testdata.ts index b3c93747..b3e98bc8 100644 --- a/backend/tests/test_assets/classes/classes.testdata.ts +++ b/backend/tests/test_assets/classes/classes.testdata.ts @@ -3,11 +3,7 @@ import { Class } from '../../../src/entities/classes/class.entity'; import { Student } from '../../../src/entities/users/student.entity'; import { Teacher } from '../../../src/entities/users/teacher.entity'; -export function makeTestClasses( - em: EntityManager>, - students: Array, - teachers: Array -): Array { +export function makeTestClasses(em: EntityManager>, students: Array, teachers: Array): Array { const studentsClass01 = students.slice(0, 7); const teacherClass01: Array = teachers.slice(0, 1); @@ -18,9 +14,7 @@ export function makeTestClasses( students: studentsClass01, }); - const studentsClass02: Array = students - .slice(0, 2) - .concat(students.slice(3, 4)); + const studentsClass02: Array = students.slice(0, 2).concat(students.slice(3, 4)); const teacherClass02: Array = teachers.slice(1, 2); const class02 = em.create(Class, { diff --git a/backend/tests/test_assets/classes/teacher-invitations.testdata.ts b/backend/tests/test_assets/classes/teacher-invitations.testdata.ts index ad5297ff..84eeab01 100644 --- a/backend/tests/test_assets/classes/teacher-invitations.testdata.ts +++ b/backend/tests/test_assets/classes/teacher-invitations.testdata.ts @@ -32,10 +32,5 @@ export function makeTestTeacherInvitations( class: classes[0], }); - return [ - teacherInvitation01, - teacherInvitation02, - teacherInvitation03, - teacherInvitation04, - ]; + return [teacherInvitation01, teacherInvitation02, teacherInvitation03, teacherInvitation04]; } diff --git a/backend/tests/test_assets/content/attachments.testdata.ts b/backend/tests/test_assets/content/attachments.testdata.ts index d0223fac..9f690d9c 100644 --- a/backend/tests/test_assets/content/attachments.testdata.ts +++ b/backend/tests/test_assets/content/attachments.testdata.ts @@ -2,10 +2,7 @@ import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; import { Attachment } from '../../../src/entities/content/attachment.entity'; import { LearningObject } from '../../../src/entities/content/learning-object.entity'; -export function makeTestAttachments( - em: EntityManager>, - learningObjects: Array -): Array { +export function makeTestAttachments(em: EntityManager>, learningObjects: Array): Array { const attachment01 = em.create(Attachment, { learningObject: learningObjects[1], name: 'attachment01', diff --git a/backend/tests/test_assets/content/learning-objects.testdata.ts b/backend/tests/test_assets/content/learning-objects.testdata.ts index afd8e149..17ed4f01 100644 --- a/backend/tests/test_assets/content/learning-objects.testdata.ts +++ b/backend/tests/test_assets/content/learning-objects.testdata.ts @@ -3,9 +3,7 @@ import { LearningObject, ReturnValue } from '../../../src/entities/content/learn import { Language } from '../../../src/entities/content/language'; import { DwengoContentType } from '../../../src/services/learning-objects/processing/content-type'; -export function makeTestLearningObjects( - em: EntityManager> -): Array { +export function makeTestLearningObjects(em: EntityManager>): Array { const returnValue: ReturnValue = new ReturnValue(); returnValue.callbackSchema = ''; returnValue.callbackUrl = ''; @@ -29,9 +27,7 @@ export function makeTestLearningObjects( available: true, contentLocation: '', attachments: [], - content: Buffer.from( - "there's a shadow just behind me, shrouding every step i take, making every promise empty pointing every finger at me" - ) + content: Buffer.from("there's a shadow just behind me, shrouding every step i take, making every promise empty pointing every finger at me"), }); const learningObject02 = em.create(LearningObject, { @@ -131,16 +127,8 @@ export function makeTestLearningObjects( available: true, contentLocation: '', attachments: [], - content: Buffer.from( - 'calling Elvis, is anybody home, calling elvis, I am here all alone' - ), + content: Buffer.from('calling Elvis, is anybody home, calling elvis, I am here all alone'), }); - return [ - learningObject01, - learningObject02, - learningObject03, - learningObject04, - learningObject05, - ]; + return [learningObject01, learningObject02, learningObject03, learningObject04, learningObject05]; } diff --git a/backend/tests/test_assets/content/learning-paths.testdata.ts b/backend/tests/test_assets/content/learning-paths.testdata.ts index c9efb7f8..d2e65c9e 100644 --- a/backend/tests/test_assets/content/learning-paths.testdata.ts +++ b/backend/tests/test_assets/content/learning-paths.testdata.ts @@ -1,14 +1,10 @@ import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; -import { - LearningPath, -} from '../../../src/entities/content/learning-path.entity'; +import { LearningPath } from '../../../src/entities/content/learning-path.entity'; import { Language } from '../../../src/entities/content/language'; import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity'; import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; -export function makeTestLearningPaths( - em: EntityManager> -): Array { +export function makeTestLearningPaths(em: EntityManager>): Array { const learningPathNode01: LearningPathNode = new LearningPathNode(); const learningPathNode02: LearningPathNode = new LearningPathNode(); const learningPathNode03: LearningPathNode = new LearningPathNode(); diff --git a/backend/tests/test_assets/questions/answers.testdata.ts b/backend/tests/test_assets/questions/answers.testdata.ts index 90039922..20e816da 100644 --- a/backend/tests/test_assets/questions/answers.testdata.ts +++ b/backend/tests/test_assets/questions/answers.testdata.ts @@ -3,11 +3,7 @@ import { Answer } from '../../../src/entities/questions/answer.entity'; import { Teacher } from '../../../src/entities/users/teacher.entity'; import { Question } from '../../../src/entities/questions/question.entity'; -export function makeTestAnswers( - em: EntityManager>, - teachers: Array, - questions: Array -): Array { +export function makeTestAnswers(em: EntityManager>, teachers: Array, questions: Array): Array { const answer01 = em.create(Answer, { author: teachers[0], toQuestion: questions[1], diff --git a/backend/tests/test_assets/questions/questions.testdata.ts b/backend/tests/test_assets/questions/questions.testdata.ts index 781cb9c3..23552152 100644 --- a/backend/tests/test_assets/questions/questions.testdata.ts +++ b/backend/tests/test_assets/questions/questions.testdata.ts @@ -3,10 +3,7 @@ import { Question } from '../../../src/entities/questions/question.entity'; import { Language } from '../../../src/entities/content/language'; import { Student } from '../../../src/entities/users/student.entity'; -export function makeTestQuestions( - em: EntityManager>, - students: Array -): Array { +export function makeTestQuestions(em: EntityManager>, students: Array): Array { const question01 = em.create(Question, { learningObjectLanguage: Language.English, learningObjectVersion: '1', diff --git a/backend/tests/test_assets/users/students.testdata.ts b/backend/tests/test_assets/users/students.testdata.ts index d55934e0..61e0b590 100644 --- a/backend/tests/test_assets/users/students.testdata.ts +++ b/backend/tests/test_assets/users/students.testdata.ts @@ -1,9 +1,7 @@ import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; import { Student } from '../../../src/entities/users/student.entity'; -export function makeTestStudents( - em: EntityManager> -): Array { +export function makeTestStudents(em: EntityManager>): Array { const student01 = em.create(Student, { username: 'Noordkaap', firstName: 'Stijn', @@ -47,13 +45,5 @@ export function makeTestStudents( lastName: 'Cobain', }); - return [ - student01, - student02, - student03, - student04, - student05, - student06, - student07, - ]; + return [student01, student02, student03, student04, student05, student06, student07]; } diff --git a/backend/tests/test_assets/users/teachers.testdata.ts b/backend/tests/test_assets/users/teachers.testdata.ts index 37e7ad20..d8985e44 100644 --- a/backend/tests/test_assets/users/teachers.testdata.ts +++ b/backend/tests/test_assets/users/teachers.testdata.ts @@ -1,9 +1,7 @@ import { Teacher } from '../../../src/entities/users/teacher.entity'; import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core'; -export function makeTestTeachers( - em: EntityManager> -): Array { +export function makeTestTeachers(em: EntityManager>): Array { const teacher01 = em.create(Teacher, { username: 'FooFighters', firstName: 'Dave', diff --git a/frontend/src/components/MenuBar.vue b/frontend/src/components/MenuBar.vue index e6d6df5d..7d7c4d88 100644 --- a/frontend/src/components/MenuBar.vue +++ b/frontend/src/components/MenuBar.vue @@ -2,10 +2,10 @@ import { ref } from "vue"; import { useRoute } from "vue-router"; import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg"; - import {useI18n} from "vue-i18n"; + import { useI18n } from "vue-i18n"; const route = useRoute(); - const { t, locale } = useI18n() + const { t, locale } = useI18n(); // Instantiate variables to use in html to render right // Links and content dependent on the role (student or teacher) @@ -30,7 +30,7 @@ // Logic to change the language of the website to the selected language const changeLanguage = (langCode: string) => { locale.value = langCode; - localStorage.setItem('user-lang', langCode); + localStorage.setItem("user-lang", langCode); console.log(langCode); }; @@ -59,22 +59,22 @@ :to="`/${role}/${userId}/assignment`" class="menu_item" > - {{ t('assignments') }} + {{ t("assignments") }}
  • {{ t('classes') }}{{ t("classes") }}
  • {{ t('discussions') }} + >{{ t("discussions") }} +
  • diff --git a/frontend/src/i18n/i18n.ts b/frontend/src/i18n/i18n.ts index 7cd6bf10..6e25cc19 100644 --- a/frontend/src/i18n/i18n.ts +++ b/frontend/src/i18n/i18n.ts @@ -1,4 +1,4 @@ -import { createI18n } from 'vue-i18n'; +import { createI18n } from "vue-i18n"; // Import translations import en from "@/i18n/locale/en.json"; @@ -6,11 +6,11 @@ import nl from "@/i18n/locale/nl.json"; import fr from "@/i18n/locale/fr.json"; import de from "@/i18n/locale/de.json"; -const savedLocale = localStorage.getItem('user-lang') || 'en'; +const savedLocale = localStorage.getItem("user-lang") || "en"; const i18n = createI18n({ locale: savedLocale, - fallbackLocale: 'en', + fallbackLocale: "en", messages: { en: en, nl: nl, diff --git a/frontend/src/main.ts b/frontend/src/main.ts index e82313b5..e4843dae 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,8 +1,8 @@ -import {createApp} from "vue"; +import { createApp } from "vue"; // Vuetify import "vuetify/styles"; -import {createVuetify} from "vuetify"; +import { createVuetify } from "vuetify"; import * as components from "vuetify/components"; import * as directives from "vuetify/directives"; import i18n from "./i18n/i18n.ts"; @@ -11,7 +11,6 @@ import i18n from "./i18n/i18n.ts"; import App from "./App.vue"; import router from "./router"; - const app = createApp(App); app.use(router);