Merge remote-tracking branch 'origin/feat/user-routes' into feat/user-routes
# Conflicts: # backend/src/interfaces/answer.ts # backend/src/services/questions.ts # frontend/src/controllers/students.ts # frontend/src/controllers/teachers.ts # frontend/src/queries/students.ts # frontend/src/queries/teachers.ts
This commit is contained in:
		
						commit
						87366b2821
					
				
					 7 changed files with 23 additions and 41 deletions
				
			
		|  | @ -4,7 +4,8 @@ import { | |||
|     createStudent, | ||||
|     deleteClassJoinRequest, | ||||
|     deleteStudent, | ||||
|     getAllStudents, getJoinRequestByStudentClass, | ||||
|     getAllStudents, | ||||
|     getJoinRequestByStudentClass, | ||||
|     getJoinRequestsByStudent, | ||||
|     getStudent, | ||||
|     getStudentAssignments, | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import { | |||
|     createStudentRequestHandler, | ||||
|     deleteClassJoinRequestHandler, | ||||
|     getStudentRequestHandler, | ||||
|     getStudentRequestsHandler | ||||
|     getStudentRequestsHandler, | ||||
| } from '../controllers/students.js'; | ||||
| 
 | ||||
| const router = express.Router({ mergeParams: true }); | ||||
|  |  | |||
|  | @ -12,12 +12,7 @@ import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js | |||
| import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; | ||||
| import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js'; | ||||
| import { getAllAssignments } from './assignments.js'; | ||||
| import { | ||||
|     mapToQuestionDTO, | ||||
|     mapToQuestionDTOId, | ||||
|     QuestionDTO, | ||||
|     QuestionId | ||||
| } from '../interfaces/question.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; | ||||
| import { mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO } from '../interfaces/student-request.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
|  |  | |||
|  | @ -6,12 +6,7 @@ import { | |||
|     getTeacherRepository, | ||||
| } from '../data/repositories.js'; | ||||
| import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; | ||||
| import { | ||||
|     mapToQuestionDTO, | ||||
|     mapToQuestionDTOId, | ||||
|     QuestionDTO, | ||||
|     QuestionId | ||||
| } from '../interfaces/question.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId } from '../interfaces/question.js'; | ||||
| import { mapToTeacher, mapToTeacherDTO, TeacherDTO } from '../interfaces/teacher.js'; | ||||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { fetchStudent } from './students.js'; | ||||
|  |  | |||
|  | @ -12,7 +12,8 @@ import { | |||
|     getStudentQuestionsHandler, | ||||
|     createStudentRequestHandler, | ||||
|     getStudentRequestsHandler, | ||||
|     deleteClassJoinRequestHandler, getStudentRequestHandler, | ||||
|     deleteClassJoinRequestHandler, | ||||
|     getStudentRequestHandler, | ||||
| } from '../../src/controllers/students.js'; | ||||
| import { TEST_STUDENTS } from '../test_assets/users/students.testdata.js'; | ||||
| import { NotFoundException } from '../../src/exceptions/not-found-exception.js'; | ||||
|  | @ -49,15 +50,13 @@ describe('Student controllers', () => { | |||
|     it('Student not found', async () => { | ||||
|         req = { params: { username: 'doesnotexist' } }; | ||||
| 
 | ||||
|         await expect(async () => getStudentHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrow(NotFoundException); | ||||
|         await expect(async () => getStudentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); | ||||
|     }); | ||||
| 
 | ||||
|     it('No username', async () => { | ||||
|         req = { params: {} }; | ||||
| 
 | ||||
|         await expect(async () => getStudentHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(BadRequestException); | ||||
|         await expect(async () => getStudentHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Create and delete student', async () => { | ||||
|  | @ -68,7 +67,7 @@ describe('Student controllers', () => { | |||
|             lastName: 'Student', | ||||
|         } as StudentDTO; | ||||
|         req = { | ||||
|             body: student | ||||
|             body: student, | ||||
|         }; | ||||
| 
 | ||||
|         await createStudentHandler(req as Request, res as Response); | ||||
|  | @ -91,15 +90,13 @@ describe('Student controllers', () => { | |||
|             }, | ||||
|         }; | ||||
| 
 | ||||
|         await expect(async () => createStudentHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(EntityAlreadyExistsException); | ||||
|         await expect(async () => createStudentHandler(req as Request, res as Response)).rejects.toThrowError(EntityAlreadyExistsException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Create student no body', async () => { | ||||
|         req = { body: {} }; | ||||
| 
 | ||||
|         await expect(async () => createStudentHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(BadRequestException); | ||||
|         await expect(async () => createStudentHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Student list', async () => { | ||||
|  | @ -218,8 +215,7 @@ describe('Student controllers', () => { | |||
|             body: { classId: 'id02' }, | ||||
|         }; | ||||
| 
 | ||||
|         await expect(async () => createStudentRequestHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrow(ConflictException); | ||||
|         await expect(async () => createStudentRequestHandler(req as Request, res as Response)).rejects.toThrow(ConflictException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Delete join request', async () => { | ||||
|  | @ -231,7 +227,6 @@ describe('Student controllers', () => { | |||
| 
 | ||||
|         expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ request: expect.anything() })); | ||||
| 
 | ||||
|         await expect(async () => deleteClassJoinRequestHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrow(NotFoundException); | ||||
|         await expect(async () => deleteClassJoinRequestHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); | ||||
|     }); | ||||
| }); | ||||
|  |  | |||
|  | @ -46,15 +46,13 @@ describe('Teacher controllers', () => { | |||
|     it('Teacher not found', async () => { | ||||
|         req = { params: { username: 'doesnotexist' } }; | ||||
| 
 | ||||
|         await expect(async () => getTeacherHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrow(NotFoundException); | ||||
|         await expect(async () => getTeacherHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); | ||||
|     }); | ||||
| 
 | ||||
|     it('No username', async () => { | ||||
|         req = { params: {} }; | ||||
| 
 | ||||
|         await expect(async () => getTeacherHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(BadRequestException); | ||||
|         await expect(async () => getTeacherHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Create and delete teacher', async () => { | ||||
|  | @ -63,7 +61,7 @@ describe('Teacher controllers', () => { | |||
|             username: 'coolteacher', | ||||
|             firstName: 'New', | ||||
|             lastName: 'Teacher', | ||||
|         } | ||||
|         }; | ||||
|         req = { | ||||
|             body: teacher, | ||||
|         }; | ||||
|  | @ -88,15 +86,13 @@ describe('Teacher controllers', () => { | |||
|             }, | ||||
|         }; | ||||
| 
 | ||||
|         await expect(async () => createTeacherHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(EntityAlreadyExistsException); | ||||
|         await expect(async () => createTeacherHandler(req as Request, res as Response)).rejects.toThrowError(EntityAlreadyExistsException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Create teacher no body', async () => { | ||||
|         req = { body: {} }; | ||||
| 
 | ||||
|         await expect(async () => createTeacherHandler(req as Request, res as Response)) | ||||
|             .rejects.toThrowError(BadRequestException); | ||||
|         await expect(async () => createTeacherHandler(req as Request, res as Response)).rejects.toThrowError(BadRequestException); | ||||
|     }); | ||||
| 
 | ||||
|     it('Teacher list', async () => { | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl