Skip to content

Commit

Permalink
RecruitmentSession: controller, service, entity, tests (#15)
Browse files Browse the repository at this point in the history
RecruitmentSessionController:
- findActive: Retrieve the active recruitment session if it exists.
- createRecruitmentSession
- updateRecruitmentSession
- deleteRecruitmentSession

RecruitmentSessionService:
- createRecruitmentSession
- findAllRecruitmentSessions
- findRecruitmentSessionById
- findActiveRecruitmentSession
- deletRecruitmentSession
- updateRecruitmentSession
- sessionHasPendingInterviews: Check if a recruitment session has pending interviews (to be implemented).

DTOs:
- CreateRecruitmentSessionDTO
- UpdateRecruitmentSessionDTO
- RecruitmentSessionResponseDTO

Tests:
- Controller Unit tests: recruitment-session.controller.spec.ts
- Service Unit tests: recruitment-session.service.spec.ts


Commits:

* fix: missing dependencies and imports (#9)

* fix: added @joi/date library

* fix: added missing useState import
  fix: removed loading screen when auth token is empty

* docs: updated project description, useful links, and contributors in README.md (#10)

* feat session: service, controller, entity

* feat: update recruitment-session: service, controller, entity

* feat: update recruitment-session: service, controller, entity

* fix: dependencies in shared/abilities

* fix: mock shared -> required/optional fields

* fix: mock recruitment session service, insert data mock

* fix: relative import of recruitment-session from shared folder

* fix: recruitment-session service Delete test

* fix: removed lastModified from UpdateRecruitmentSessionDto

* fix: ability check on recruitment session creation

* feat: check if recruitment session has pending interviews before deleting it

* feat: check for conflicts and consistency when updating a recruitment session state

* fix: check ability for update recruitment session

* refactor: removed unused imports in recruitment-session.controller.ts

* fix: use const for unchanged variable in createRecruitmentSession service method

* refactor: removed unused code in creatre-recruitment-session.dto.ts

* fix: updated Date[] in create and update Recruitment session DTOs

* fix: added 'state' to recruitmentSession response DTO

* test: Recruitment Session Controller tests

* refactor: removed unused imports

---------

Co-authored-by: Alberto Baroso <[email protected]>
  • Loading branch information
whiitex and AlbertoBaroso committed Apr 9, 2024
1 parent 789e246 commit 7c7954c
Show file tree
Hide file tree
Showing 13 changed files with 989 additions and 2 deletions.
36 changes: 36 additions & 0 deletions api/src/mocks/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
PhdApplication,
} from 'src/application/application.entity';
import { UpdateApplicationDto } from 'src/application/update-application.dto';
import { RecruitmentSessionState } from '@hkrecruitment/shared/recruitment-session';
import { CreateRecruitmentSessionDto } from 'src/recruitment-session/create-recruitment-session.dto';
import { UpdateRecruitmentSessionDto } from 'src/recruitment-session/update-recruitment-session.dto';

export const testDate = new Date(2023, 0, 1, 10, 0, 0);
export const testDateTimeStart = new Date(2023, 0, 1, 10, 30, 0);
Expand All @@ -25,6 +28,39 @@ export const mockTimeSlot = {
id: 1,
};

export const testInterviewStart = '11:55' as unknown as Date;
export const testInterviewEnd = '20:35' as unknown as Date;
export const testDay1 = '2024-10-20' as unknown as Date;
export const testDay2 = '2024-10-21' as unknown as Date;
export const testDay3 = '2024-10-22' as unknown as Date;
export const testDateCreatedAt = '2024-9-10' as unknown as Date;
export const testDateLastModified = '2024-9-12' as unknown as Date;

export const mockRecruitmentSession = {
id: 1,
state: RecruitmentSessionState.Active,
slotDuration: 50,
interviewStart: testInterviewStart,
interviewEnd: testInterviewEnd,
days: [testDay1, testDay2, testDay3],
createdAt: testDateCreatedAt,
lastModified: testDateLastModified,
};

export const mockCreateRecruitmentSessionDto = {
slotDuration: 50,
interviewStart: testInterviewStart,
interviewEnd: testInterviewEnd,
days: [testDay1, testDay2, testDay3],
} as CreateRecruitmentSessionDto;

export const mockUpdateRecruitmentSessionDto = {
slotDuration: 50,
interviewStart: testInterviewStart,
interviewEnd: testInterviewEnd,
days: [testDay1, testDay2, testDay3],
} as UpdateRecruitmentSessionDto;

export const baseFile = {
encoding: '7bit',
mimetype: 'application/pdf',
Expand Down
18 changes: 18 additions & 0 deletions api/src/recruitment-session/create-recruitment-session.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { RecruitmentSession } from '@hkrecruitment/shared/recruitment-session';
import { ApiProperty } from '@nestjs/swagger';

export class CreateRecruitmentSessionDto
implements Partial<RecruitmentSession>
{
@ApiProperty()
slotDuration: number;

@ApiProperty()
interviewStart: Date;

@ApiProperty()
interviewEnd: Date;

@ApiProperty({ isArray: true })
days: Date[];
}
14 changes: 14 additions & 0 deletions api/src/recruitment-session/recruitment-session-response.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
RecruitmentSession,
RecruitmentSessionState,
} from '@hkrecruitment/shared/recruitment-session';
import { Exclude, Expose } from 'class-transformer';

@Exclude()
export class RecruitmentSessionResponseDto
implements Partial<RecruitmentSession>
{
@Expose() id: number;
@Expose() createdAt: Date;
@Expose() state: RecruitmentSessionState;
}
Loading

0 comments on commit 7c7954c

Please sign in to comment.