diff --git a/api/src/mocks/db-data.ts b/api/src/mocks/db-data.ts new file mode 100644 index 0000000..e54310e --- /dev/null +++ b/api/src/mocks/db-data.ts @@ -0,0 +1,810 @@ +import { + Person, + Role, + TimeSlot, + AvailabilityState, + RecruitmentSessionState, +} from '@hkrecruitment/shared'; + +export let mockRecruitmentSessions = [ + { + id: 1, + state: RecruitmentSessionState.Concluded, + slotDuration: 1, + lastModified: new Date('2024-04-10'), + createdAt: new Date('2024-04-04'), + days: [ + new Date('2024-04-05'), + new Date('2024-04-06'), + new Date('2024-04-07'), + new Date('2024-04-08'), + new Date('2024-04-09'), + ], + interviewStart: new Date('2024-04-05'), + interviewEnd: new Date('2024-04-10'), + }, + { + id: 2, + state: RecruitmentSessionState.Concluded, + slotDuration: 1, + lastModified: new Date('2024-05-10'), + createdAt: new Date('2024-05-04'), + days: [ + new Date('2024-05-05'), + new Date('2024-05-06'), + new Date('2024-05-07'), + new Date('2024-05-08'), + ], + interviewStart: new Date('2024-05-05'), + interviewEnd: new Date('2024-05-09'), + }, + { + id: 3, + state: RecruitmentSessionState.Active, + slotDuration: 1, + lastModified: new Date('2024-05-14'), + createdAt: new Date('2024-05-14'), + days: [ + new Date('2024-05-16'), + new Date('2024-05-17'), + new Date('2024-05-18'), + new Date('2024-05-19'), + new Date('2024-05-20'), + ], + interviewStart: new Date('2024-05-16'), + interviewEnd: new Date('2024-05-21'), + }, +]; + +export let mockUsers = [ + { + oauthId: '1', + firstName: 'Pasquale', + lastName: 'Bianco', + sex: 'M', + email: 'p.bianco@gmail.com', + role: Role.Member, + is_board: true, + is_expert: true, + }, + { + oauthId: '2', + firstName: 'John', + lastName: 'Doe', + sex: 'M', + email: 'j.doe@gmail.com', + role: Role.Member, + is_board: false, + is_expert: true, + }, + { + oauthId: '3', + firstName: 'Jane', + lastName: 'Smith', + sex: 'F', + email: 'j.smith@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '4', + firstName: 'Michael', + lastName: 'Johnson', + sex: 'M', + email: 'm.johnson@gmail.com', + role: Role.Member, + is_board: true, + is_expert: true, + }, + { + oauthId: '5', + firstName: 'Emily', + lastName: 'Brown', + sex: 'F', + email: 'e.brown@gmail.com', + role: Role.Member, + is_board: false, + is_expert: true, + }, + { + oauthId: '6', + firstName: 'David', + lastName: 'Wilson', + sex: 'M', + email: 'd.wilson@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '7', + firstName: 'Olivia', + lastName: 'Johnson', + sex: 'F', + email: 'o.johnson@gmail.com', + role: Role.Member, + is_board: true, + is_expert: false, + }, + { + oauthId: '8', + firstName: 'James', + lastName: 'Smith', + sex: 'M', + email: 'j.smith@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '9', + firstName: 'Sophia', + lastName: 'Miller', + sex: 'F', + email: 's.miller@gmail.com', + role: Role.Member, + is_board: false, + is_expert: true, + }, + { + oauthId: '10', + firstName: 'Benjamin', + lastName: 'Davis', + sex: 'M', + email: 'b.davis@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '11', + firstName: 'Ava', + lastName: 'Wilson', + sex: 'female', + email: 'a.wilson@gmail.com', + role: Role.Member, + is_board: true, + is_expert: true, + }, + { + oauthId: '12', + firstName: 'William', + lastName: 'Anderson', + sex: 'M', + email: 'w.anderson@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '13', + firstName: 'Mia', + lastName: 'Thomas', + sex: 'F', + email: 'm.thomas@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '14', + firstName: 'Alexander', + lastName: 'Taylor', + sex: 'M', + email: 'a.taylor@gmail.com', + role: Role.Member, + is_board: false, + is_expert: true, + }, + { + oauthId: '15', + firstName: 'Charlotte', + lastName: 'Clark', + sex: 'F', + email: 'c.clark@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '16', + firstName: 'Daniel', + lastName: 'Moore', + sex: 'M', + email: 'd.moore@gmail.com', + role: Role.Member, + is_board: false, + is_expert: false, + }, + { + oauthId: '17', + firstName: 'Amelia', + lastName: 'Walker', + sex: 'F', + email: 'a.walker@gmail.com', + role: Role.Clerk, + is_board: false, + is_expert: false, + }, + { + oauthId: '18', + firstName: 'Matthew', + lastName: 'Lewis', + sex: 'M', + email: 'm.lewis@gmail.com', + role: Role.Admin, + is_board: false, + is_expert: true, + }, + { + oauthId: '19', + firstName: 'Ella', + lastName: 'Harris', + sex: 'F', + email: 'e.harris@gmail.com', + role: Role.Supervisor, + is_board: false, + is_expert: true, + }, + { + oauthId: '20', + firstName: 'Joseph', + lastName: 'King', + sex: 'M', + email: 'j.king@gmail.com', + role: Role.Supervisor, + is_board: true, + is_expert: false, + }, +]; + +export let mockTimeSlots = [ + { + id: 51, + start: new Date('2024-05-16 10:00:00'), + end: new Date('2024-05-16 11:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 52, + start: new Date('2024-05-16 11:00:00'), + end: new Date('2024-05-16 12:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 53, + start: new Date('2024-05-16 15:00:00'), + end: new Date('2024-05-16 16:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 54, + start: new Date('2024-05-16 16:00:00'), + end: new Date('2024-05-16 17:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 55, + start: new Date('2024-05-16 17:00:00'), + end: new Date('2024-05-16 18:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 56, + start: new Date('2024-05-16 18:00:00'), + end: new Date('2024-05-16 19:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 57, + start: new Date('2024-05-17 10:00:00'), + end: new Date('2024-05-17 11:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 58, + start: new Date('2024-05-17 11:00:00'), + end: new Date('2024-05-17 12:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 59, + start: new Date('2024-05-17 15:00:00'), + end: new Date('2024-05-17 16:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 60, + start: new Date('2024-05-17 16:00:00'), + end: new Date('2024-05-17 17:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 61, + start: new Date('2024-05-17 17:00:00'), + end: new Date('2024-05-17 18:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 62, + start: new Date('2024-05-17 18:00:00'), + end: new Date('2024-05-17 19:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 63, + start: new Date('2024-05-18 10:00:00'), + end: new Date('2024-05-18 11:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 64, + start: new Date('2024-05-18 11:00:00'), + end: new Date('2024-05-18 12:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 65, + start: new Date('2024-05-18 15:00:00'), + end: new Date('2024-05-18 16:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 66, + start: new Date('2024-05-18 16:00:00'), + end: new Date('2024-05-18 17:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 67, + start: new Date('2024-05-18 17:00:00'), + end: new Date('2024-05-18 18:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 68, + start: new Date('2024-05-18 18:00:00'), + end: new Date('2024-05-18 19:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 69, + start: new Date('2024-05-19 10:00:00'), + end: new Date('2024-05-19 11:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 70, + start: new Date('2024-05-19 11:00:00'), + end: new Date('2024-05-19 12:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 71, + start: new Date('2024-05-19 15:00:00'), + end: new Date('2024-05-19 16:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 72, + start: new Date('2024-05-19 16:00:00'), + end: new Date('2024-05-19 17:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 73, + start: new Date('2024-05-19 17:00:00'), + end: new Date('2024-05-19 18:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 74, + start: new Date('2024-05-19 18:00:00'), + end: new Date('2024-05-19 19:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 75, + start: new Date('2024-05-20 10:00:00'), + end: new Date('2024-05-20 11:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 76, + start: new Date('2024-05-20 11:00:00'), + end: new Date('2024-05-20 12:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 77, + start: new Date('2024-05-20 15:00:00'), + end: new Date('2024-05-20 16:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 78, + start: new Date('2024-05-20 16:00:00'), + end: new Date('2024-05-20 17:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 79, + start: new Date('2024-05-20 17:00:00'), + end: new Date('2024-05-20 18:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, + { + id: 80, + start: new Date('2024-05-20 18:00:00'), + end: new Date('2024-05-20 19:00:00'), + recruitmentSession: mockRecruitmentSessions[2], + }, +]; + +export let mockAvailability = [ + { + id: 1, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 51, + userOauthId: '5', + }, + { + id: 2, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 53, + userOauthId: '7', + }, + { + id: 3, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 55, + userOauthId: '12', + }, + { + id: 4, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 61, + userOauthId: '19', + }, + { + id: 5, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 71, + userOauthId: '3', + }, + { + id: 6, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 78, + userOauthId: '15', + }, + { + id: 7, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 58, + userOauthId: '11', + }, + { + id: 8, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 57, + userOauthId: '8', + }, + { + id: 9, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 64, + userOauthId: '5', + }, + { + id: 10, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 53, + userOauthId: '17', + }, + { + id: 11, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 62, + userOauthId: '2', + }, + { + id: 12, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 71, + userOauthId: '9', + }, + { + id: 13, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 72, + userOauthId: '14', + }, + { + id: 14, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 74, + userOauthId: '6', + }, + { + id: 15, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 75, + userOauthId: '13', + }, + { + id: 16, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 74, + userOauthId: '10', + }, + { + id: 17, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 71, + userOauthId: '4', + }, + { + id: 18, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 64, + userOauthId: '16', + }, + { + id: 19, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 59, + userOauthId: '18', + }, + { + id: 20, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 57, + userOauthId: '1', + }, + { + id: 21, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 66, + userOauthId: '20', + }, + { + id: 22, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 68, + userOauthId: '19', + }, + { + id: 23, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 69, + userOauthId: '7', + }, + { + id: 24, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 70, + userOauthId: '16', + }, + { + id: 25, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 72, + userOauthId: '15', + }, + { + id: 26, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 73, + userOauthId: '11', + }, + { + id: 27, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 75, + userOauthId: '14', + }, + { + id: 28, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 76, + userOauthId: '9', + }, + { + id: 29, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 77, + userOauthId: '8', + }, + { + id: 30, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 78, + userOauthId: '10', + }, + { + id: 31, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 79, + userOauthId: '13', + }, + { + id: 32, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 80, + userOauthId: '12', + }, + { + id: 33, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 79, + userOauthId: '20', + }, + { + id: 34, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 78, + userOauthId: '18', + }, + { + id: 35, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 77, + userOauthId: '17', + }, + { + id: 36, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 76, + userOauthId: '19', + }, + { + id: 37, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 75, + userOauthId: '16', + }, + { + id: 38, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 74, + userOauthId: '15', + }, + { + id: 39, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 73, + userOauthId: '14', + }, + { + id: 40, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 72, + userOauthId: '13', + }, + { + id: 41, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 71, + userOauthId: '12', + }, + { + id: 42, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 70, + userOauthId: '11', + }, + { + id: 43, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 69, + userOauthId: '10', + }, + { + id: 44, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 68, + userOauthId: '9', + }, + { + id: 45, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 67, + userOauthId: '8', + }, + { + id: 46, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 66, + userOauthId: '7', + }, + { + id: 47, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 65, + userOauthId: '6', + }, + { + id: 48, + state: AvailabilityState.Interviewing, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 64, + userOauthId: '5', + }, + { + id: 49, + state: AvailabilityState.Recovering, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 63, + userOauthId: '8', + }, + { + id: 50, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 62, + userOauthId: '14', + }, + { + id: 51, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 61, + userOauthId: '4', + }, + { + id: 52, + state: AvailabilityState.Free, + lastModified: new Date('2024-05-14 00:00:00'), + timeSlot: 60, + userOauthId: '13', + }, +]; diff --git a/api/src/mocks/requests.http b/api/src/mocks/requests.http index c0f0e99..1dcbb14 100644 --- a/api/src/mocks/requests.http +++ b/api/src/mocks/requests.http @@ -1,2 +1,2 @@ GET http://localhost:3000/v1/timeslots/ -Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Imc4aFdBRTB0U00tX3JJVUR0WElNMyJ9.eyJlbWFpbCI6InBhc3F1YWxlLmJpYW5jb0Boa25wb2xpdG8ub3JnIiwiaXNzIjoiaHR0cHM6Ly9kZXYtYzhyb29jZGw3NjNsbDVxZi5ldS5hdXRoMC5jb20vIiwic3ViIjoiZ29vZ2xlLW9hdXRoMnwxMDYyMjgyMTU0MzYxNTk5ODcwNTEiLCJhdWQiOlsiaHR0cDovL2hrcmVjcnVpdG1lbnQub3JnIiwiaHR0cHM6Ly9kZXYtYzhyb29jZGw3NjNsbDVxZi5ldS5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNzE2MTEzNTk3LCJleHAiOjE3MTYxOTk5OTcsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgZW1haWwiLCJhenAiOiJaekNWd2R2eUJOUWZKc3R1ZUJPcVh3TW1jazZCa0d4NiJ9.PyyW67LJIWc9NbMibzvzfxlY0Pe1YTsZVsV2--ckBQ5hfYsCKqCUi6aIjmiliz_uZO5qdPAsZ7FYNOtOI8fGhPt9QfKSqA166D-CZWnpuwE4cM_EjbpCoHRRQ49r2Ycv_ZnzVXrO6zCyEVZYgx-USGiuBnRcKbIPDJCS4Tc9bcmklcUdq4ujAPtSDdmid9jcVN3DM5eLtXAQuYIUho3G3NRVuKlUnoNIsK16yrKtx5kgOHKuUP6dFYExpp2ViB4oZV-v_linCsXZEE5x-7GBMntJAGtenCs-1uihB-OGLYJY_6fPsRG2rgw5Fl8Ax0Ioc8LeXkwlJ2L-MO1ms-r8uQ +Authorization: Bearer diff --git a/api/src/timeslots/create-timeslot.dto.ts b/api/src/timeslots/create-timeslot.dto.ts index 0b50071..2d40f64 100644 --- a/api/src/timeslots/create-timeslot.dto.ts +++ b/api/src/timeslots/create-timeslot.dto.ts @@ -4,7 +4,7 @@ import { Availability } from 'src/availability/availability.entity'; import { RecruitmentSession } from 'src/recruitment-session/recruitment-session.entity'; export class CreateTimeSlotDto implements Partial { - @ApiProperty() // + @ApiProperty() start: Date; @ApiProperty() diff --git a/api/src/timeslots/timeslots.e2e-spec.ts b/api/src/timeslots/timeslots.e2e-spec.ts index 261da44..065e852 100644 --- a/api/src/timeslots/timeslots.e2e-spec.ts +++ b/api/src/timeslots/timeslots.e2e-spec.ts @@ -4,16 +4,14 @@ import { TimeSlotsService } from './timeslots.service'; import { UsersService } from '../users/users.service'; import { AvailabilityService } from '../availability/availability.service'; import { RecruitmentSessionService } from '../recruitment-session/recruitment-session.service'; -import { - Person, - Role, - TimeSlot, - AvailabilityState, - RecruitmentSessionState, -} from '@hkrecruitment/shared'; -import { RecruitmentSession } from 'src/recruitment-session/recruitment-session.entity'; import { Availability } from 'src/availability/availability.entity'; import { createApp, getAccessToken } from 'test/app.e2e-spec'; +import { + mockAvailability, + mockRecruitmentSessions, + mockTimeSlots, + mockUsers, +} from '../mocks/db-data'; describe('TimeslotsController', () => { let app: INestApplication; @@ -22,824 +20,9 @@ describe('TimeslotsController', () => { let usersService: UsersService; let availabilityService: AvailabilityService; let recruitmentSessionService: RecruitmentSessionService; - let mockUsers: Person[]; - let mockTimeSlots: TimeSlot[]; - let mockRecruitmentSessions: RecruitmentSession[]; - - class mockAv { - id: number; - state: AvailabilityState; - lastModified: Date; - timeSlot: number; - userOauthId: string; - } - let mockAvailability: mockAv[]; beforeAll(async () => { newMemberToken = await getAccessToken('newMember'); - - mockRecruitmentSessions = [ - { - id: 1, - state: RecruitmentSessionState.Concluded, - slotDuration: 1, - lastModified: new Date('2024-04-10'), - createdAt: new Date('2024-04-04'), - days: [ - new Date('2024-04-05'), - new Date('2024-04-06'), - new Date('2024-04-07'), - new Date('2024-04-08'), - new Date('2024-04-09'), - ], - interviewStart: new Date('2024-04-05'), - interviewEnd: new Date('2024-04-10'), - }, - { - id: 2, - state: RecruitmentSessionState.Concluded, - slotDuration: 1, - lastModified: new Date('2024-05-10'), - createdAt: new Date('2024-05-04'), - days: [ - new Date('2024-05-05'), - new Date('2024-05-06'), - new Date('2024-05-07'), - new Date('2024-05-08'), - ], - interviewStart: new Date('2024-05-05'), - interviewEnd: new Date('2024-05-09'), - }, - { - id: 3, - state: RecruitmentSessionState.Active, - slotDuration: 1, - lastModified: new Date('2024-05-14'), - createdAt: new Date('2024-05-14'), - days: [ - new Date('2024-05-16'), - new Date('2024-05-17'), - new Date('2024-05-18'), - new Date('2024-05-19'), - new Date('2024-05-20'), - ], - interviewStart: new Date('2024-05-16'), - interviewEnd: new Date('2024-05-21'), - }, - ]; - - mockUsers = [ - { - oauthId: '1', - firstName: 'Pasquale', - lastName: 'Bianco', - sex: 'M', - email: 'p.bianco@gmail.com', - role: Role.Member, - is_board: true, - is_expert: true, - }, - { - oauthId: '2', - firstName: 'John', - lastName: 'Doe', - sex: 'M', - email: 'j.doe@gmail.com', - role: Role.Member, - is_board: false, - is_expert: true, - }, - { - oauthId: '3', - firstName: 'Jane', - lastName: 'Smith', - sex: 'F', - email: 'j.smith@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '4', - firstName: 'Michael', - lastName: 'Johnson', - sex: 'M', - email: 'm.johnson@gmail.com', - role: Role.Member, - is_board: true, - is_expert: true, - }, - { - oauthId: '5', - firstName: 'Emily', - lastName: 'Brown', - sex: 'F', - email: 'e.brown@gmail.com', - role: Role.Member, - is_board: false, - is_expert: true, - }, - { - oauthId: '6', - firstName: 'David', - lastName: 'Wilson', - sex: 'M', - email: 'd.wilson@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '7', - firstName: 'Olivia', - lastName: 'Johnson', - sex: 'F', - email: 'o.johnson@gmail.com', - role: Role.Member, - is_board: true, - is_expert: false, - }, - { - oauthId: '8', - firstName: 'James', - lastName: 'Smith', - sex: 'M', - email: 'j.smith@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '9', - firstName: 'Sophia', - lastName: 'Miller', - sex: 'F', - email: 's.miller@gmail.com', - role: Role.Member, - is_board: false, - is_expert: true, - }, - { - oauthId: '10', - firstName: 'Benjamin', - lastName: 'Davis', - sex: 'M', - email: 'b.davis@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '11', - firstName: 'Ava', - lastName: 'Wilson', - sex: 'female', - email: 'a.wilson@gmail.com', - role: Role.Member, - is_board: true, - is_expert: true, - }, - { - oauthId: '12', - firstName: 'William', - lastName: 'Anderson', - sex: 'M', - email: 'w.anderson@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '13', - firstName: 'Mia', - lastName: 'Thomas', - sex: 'F', - email: 'm.thomas@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '14', - firstName: 'Alexander', - lastName: 'Taylor', - sex: 'M', - email: 'a.taylor@gmail.com', - role: Role.Member, - is_board: false, - is_expert: true, - }, - { - oauthId: '15', - firstName: 'Charlotte', - lastName: 'Clark', - sex: 'F', - email: 'c.clark@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '16', - firstName: 'Daniel', - lastName: 'Moore', - sex: 'M', - email: 'd.moore@gmail.com', - role: Role.Member, - is_board: false, - is_expert: false, - }, - { - oauthId: '17', - firstName: 'Amelia', - lastName: 'Walker', - sex: 'F', - email: 'a.walker@gmail.com', - role: Role.Clerk, - is_board: false, - is_expert: false, - }, - { - oauthId: '18', - firstName: 'Matthew', - lastName: 'Lewis', - sex: 'M', - email: 'm.lewis@gmail.com', - role: Role.Admin, - is_board: false, - is_expert: true, - }, - { - oauthId: '19', - firstName: 'Ella', - lastName: 'Harris', - sex: 'F', - email: 'e.harris@gmail.com', - role: Role.Supervisor, - is_board: false, - is_expert: true, - }, - { - oauthId: '20', - firstName: 'Joseph', - lastName: 'King', - sex: 'M', - email: 'j.king@gmail.com', - role: Role.Supervisor, - is_board: true, - is_expert: false, - }, - ]; - - mockTimeSlots = [ - { - id: 51, - start: new Date('2024-05-16 10:00:00'), - end: new Date('2024-05-16 11:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 52, - start: new Date('2024-05-16 11:00:00'), - end: new Date('2024-05-16 12:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 53, - start: new Date('2024-05-16 15:00:00'), - end: new Date('2024-05-16 16:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 54, - start: new Date('2024-05-16 16:00:00'), - end: new Date('2024-05-16 17:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 55, - start: new Date('2024-05-16 17:00:00'), - end: new Date('2024-05-16 18:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 56, - start: new Date('2024-05-16 18:00:00'), - end: new Date('2024-05-16 19:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 57, - start: new Date('2024-05-17 10:00:00'), - end: new Date('2024-05-17 11:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 58, - start: new Date('2024-05-17 11:00:00'), - end: new Date('2024-05-17 12:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 59, - start: new Date('2024-05-17 15:00:00'), - end: new Date('2024-05-17 16:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 60, - start: new Date('2024-05-17 16:00:00'), - end: new Date('2024-05-17 17:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 61, - start: new Date('2024-05-17 17:00:00'), - end: new Date('2024-05-17 18:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 62, - start: new Date('2024-05-17 18:00:00'), - end: new Date('2024-05-17 19:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 63, - start: new Date('2024-05-18 10:00:00'), - end: new Date('2024-05-18 11:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 64, - start: new Date('2024-05-18 11:00:00'), - end: new Date('2024-05-18 12:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 65, - start: new Date('2024-05-18 15:00:00'), - end: new Date('2024-05-18 16:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 66, - start: new Date('2024-05-18 16:00:00'), - end: new Date('2024-05-18 17:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 67, - start: new Date('2024-05-18 17:00:00'), - end: new Date('2024-05-18 18:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 68, - start: new Date('2024-05-18 18:00:00'), - end: new Date('2024-05-18 19:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 69, - start: new Date('2024-05-19 10:00:00'), - end: new Date('2024-05-19 11:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 70, - start: new Date('2024-05-19 11:00:00'), - end: new Date('2024-05-19 12:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 71, - start: new Date('2024-05-19 15:00:00'), - end: new Date('2024-05-19 16:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 72, - start: new Date('2024-05-19 16:00:00'), - end: new Date('2024-05-19 17:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 73, - start: new Date('2024-05-19 17:00:00'), - end: new Date('2024-05-19 18:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 74, - start: new Date('2024-05-19 18:00:00'), - end: new Date('2024-05-19 19:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 75, - start: new Date('2024-05-20 10:00:00'), - end: new Date('2024-05-20 11:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 76, - start: new Date('2024-05-20 11:00:00'), - end: new Date('2024-05-20 12:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 77, - start: new Date('2024-05-20 15:00:00'), - end: new Date('2024-05-20 16:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 78, - start: new Date('2024-05-20 16:00:00'), - end: new Date('2024-05-20 17:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 79, - start: new Date('2024-05-20 17:00:00'), - end: new Date('2024-05-20 18:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - { - id: 80, - start: new Date('2024-05-20 18:00:00'), - end: new Date('2024-05-20 19:00:00'), - recruitmentSession: mockRecruitmentSessions[2], - }, - ]; - - mockAvailability = [ - { - id: 1, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 51, - userOauthId: '5', - }, - { - id: 2, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 53, - userOauthId: '7', - }, - { - id: 3, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 55, - userOauthId: '12', - }, - { - id: 4, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 61, - userOauthId: '19', - }, - { - id: 5, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 71, - userOauthId: '3', - }, - { - id: 6, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 78, - userOauthId: '15', - }, - { - id: 7, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 58, - userOauthId: '11', - }, - { - id: 8, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 57, - userOauthId: '8', - }, - { - id: 9, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 64, - userOauthId: '5', - }, - { - id: 10, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 53, - userOauthId: '17', - }, - { - id: 11, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 62, - userOauthId: '2', - }, - { - id: 12, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 71, - userOauthId: '9', - }, - { - id: 13, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 72, - userOauthId: '14', - }, - { - id: 14, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 74, - userOauthId: '6', - }, - { - id: 15, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 75, - userOauthId: '13', - }, - { - id: 16, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 74, - userOauthId: '10', - }, - { - id: 17, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 71, - userOauthId: '4', - }, - { - id: 18, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 64, - userOauthId: '16', - }, - { - id: 19, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 59, - userOauthId: '18', - }, - { - id: 20, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 57, - userOauthId: '1', - }, - { - id: 21, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 66, - userOauthId: '20', - }, - { - id: 22, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 68, - userOauthId: '19', - }, - { - id: 23, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 69, - userOauthId: '7', - }, - { - id: 24, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 70, - userOauthId: '16', - }, - { - id: 25, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 72, - userOauthId: '15', - }, - { - id: 26, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 73, - userOauthId: '11', - }, - { - id: 27, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 75, - userOauthId: '14', - }, - { - id: 28, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 76, - userOauthId: '9', - }, - { - id: 29, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 77, - userOauthId: '8', - }, - { - id: 30, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 78, - userOauthId: '10', - }, - { - id: 31, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 79, - userOauthId: '13', - }, - { - id: 32, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 80, - userOauthId: '12', - }, - { - id: 33, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 79, - userOauthId: '20', - }, - { - id: 34, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 78, - userOauthId: '18', - }, - { - id: 35, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 77, - userOauthId: '17', - }, - { - id: 36, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 76, - userOauthId: '19', - }, - { - id: 37, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 75, - userOauthId: '16', - }, - { - id: 38, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 74, - userOauthId: '15', - }, - { - id: 39, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 73, - userOauthId: '14', - }, - { - id: 40, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 72, - userOauthId: '13', - }, - { - id: 41, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 71, - userOauthId: '12', - }, - { - id: 42, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 70, - userOauthId: '11', - }, - { - id: 43, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 69, - userOauthId: '10', - }, - { - id: 44, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 68, - userOauthId: '9', - }, - { - id: 45, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 67, - userOauthId: '8', - }, - { - id: 46, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 66, - userOauthId: '7', - }, - { - id: 47, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 65, - userOauthId: '6', - }, - { - id: 48, - state: AvailabilityState.Interviewing, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 64, - userOauthId: '5', - }, - { - id: 49, - state: AvailabilityState.Recovering, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 63, - userOauthId: '8', - }, - { - id: 50, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 62, - userOauthId: '14', - }, - { - id: 51, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 61, - userOauthId: '4', - }, - { - id: 52, - state: AvailabilityState.Free, - lastModified: new Date('2024-05-14 00:00:00'), - timeSlot: 60, - userOauthId: '13', - }, - ]; }); beforeEach(async () => { diff --git a/api/src/timeslots/timeslots.service.ts b/api/src/timeslots/timeslots.service.ts index b1885ca..075ba9c 100644 --- a/api/src/timeslots/timeslots.service.ts +++ b/api/src/timeslots/timeslots.service.ts @@ -184,21 +184,6 @@ export class TimeSlotsService { ); const allMatches = await queryBuilder.getMany(); - // const allMatches = await this.timeSlotRepository.find({ - // relations: [ - // 'availabilities', - // 'availabilities.user', - // 'recruitmentSession', - // ], - // where: { - // availabilities: { - // state: AvailabilityState.Free, - // user: { - // role: Not(In([Role.Applicant, Role.None])), - // }, - // }, - // }, - // }); let goodTimeSlots: TimeSlot[] = []; allMatches.forEach((timeSlot) => {