diff --git a/services/apps/alcs/src/alcs/application/application-tag/application-tag.controller.spec.ts b/services/apps/alcs/src/alcs/application/application-tag/application-tag.controller.spec.ts new file mode 100644 index 000000000..4559a9a33 --- /dev/null +++ b/services/apps/alcs/src/alcs/application/application-tag/application-tag.controller.spec.ts @@ -0,0 +1,69 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ApplicationTagController } from './application-tag.controller'; +import { ApplicationTagService } from './application-tag.service'; +import { createMock, DeepMocked } from '@golevelup/nestjs-testing'; +import { + initApplicationMockEntity, + initApplicationWithTagsMockEntity, + initTagMockEntity, +} from '../../../../test/mocks/mockEntities'; +import { ClsService } from 'nestjs-cls'; +import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes'; +import { TagModule } from '../../tag/tag.module'; +import { ApplicationTagDto } from './application-tag.dto'; + +describe('ApplicationTagController', () => { + let controller: ApplicationTagController; + let applicationTagService: DeepMocked; + + const mockApplicationEntityWithoutTags = initApplicationMockEntity(); + mockApplicationEntityWithoutTags.tags = []; + const mockApplicationEntityWithTags = initApplicationWithTagsMockEntity(); + const mockTagEntity = initTagMockEntity(); + + beforeEach(async () => { + applicationTagService = createMock(); + const module: TestingModule = await Test.createTestingModule({ + controllers: [ApplicationTagController], + providers: [ + { provide: ApplicationTagService, useValue: applicationTagService }, + { provide: ClsService, useValue: {} }, + ...mockKeyCloakProviders, + ], + imports: [], + }).compile(); + + controller = module.get(ApplicationTagController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); + + it('should return tags for the application', async () => { + applicationTagService.getApplicationTags.mockResolvedValue([mockTagEntity]); + + const result = await controller.getApplicationTags('app_1'); + expect(applicationTagService.getApplicationTags).toHaveBeenCalledTimes(1); + expect(result[0].name).toEqual('tag-name'); + }); + + it('should create tags', async () => { + applicationTagService.addTagToApplication.mockResolvedValue(mockApplicationEntityWithTags); + + const mockTagDto = new ApplicationTagDto(); + mockTagDto.tagName = 'tag-name'; + + const result = await controller.addTagToApplication('app_1', mockTagDto); + expect(applicationTagService.addTagToApplication).toHaveBeenCalledTimes(1); + expect(result.tags[0].name).toEqual('tag-name'); + }); + + it('should remove tags', async () => { + applicationTagService.removeTagFromApplication.mockResolvedValue(mockApplicationEntityWithoutTags); + + const result = await controller.removeTagFromApplication('app_1', 'tag-name'); + expect(applicationTagService.removeTagFromApplication).toHaveBeenCalledTimes(1); + expect(result.tags.length).toEqual(0); + }); +}); diff --git a/services/apps/alcs/src/alcs/application/application-tag/application-tag.controller.ts b/services/apps/alcs/src/alcs/application/application-tag/application-tag.controller.ts new file mode 100644 index 000000000..c8d508e50 --- /dev/null +++ b/services/apps/alcs/src/alcs/application/application-tag/application-tag.controller.ts @@ -0,0 +1,44 @@ +import { + Body, + Controller, + Delete, + Get, + HttpException, + HttpStatus, + Logger, + Param, + Post, + UseGuards, +} from '@nestjs/common'; +import { ApiOAuth2 } from '@nestjs/swagger'; +import { RolesGuard } from '../../../common/authorization/roles-guard.service'; +import * as config from 'config'; +import { ApplicationTagService } from './application-tag.service'; +import { ApplicationTagDto } from './application-tag.dto'; +import { UserRoles } from '../../../common/authorization/roles.decorator'; +import { ROLES_ALLOWED_APPLICATIONS } from '../../../common/authorization/roles'; + +@Controller('application/:fileNumber/tag') +@ApiOAuth2(config.get('KEYCLOAK.SCOPES')) +@UseGuards(RolesGuard) +export class ApplicationTagController { + constructor(private service: ApplicationTagService) {} + + @Get('') + @UserRoles(...ROLES_ALLOWED_APPLICATIONS) + async getApplicationTags(@Param('fileNumber') fileNumber: string) { + return await this.service.getApplicationTags(fileNumber); + } + + @Post('') + @UserRoles(...ROLES_ALLOWED_APPLICATIONS) + async addTagToApplication(@Param('fileNumber') fileNumber: string, @Body() dto: ApplicationTagDto) { + return await this.service.addTagToApplication(fileNumber, dto.tagName); + } + + @Delete('/:tagName') + @UserRoles(...ROLES_ALLOWED_APPLICATIONS) + async removeTagFromApplication(@Param('fileNumber') fileNumber: string, @Param('tagName') tagName: string) { + return await this.service.removeTagFromApplication(fileNumber, tagName); + } +} diff --git a/services/apps/alcs/src/alcs/application/application-tag/application-tag.dto.ts b/services/apps/alcs/src/alcs/application/application-tag/application-tag.dto.ts new file mode 100644 index 000000000..c0f9b4b74 --- /dev/null +++ b/services/apps/alcs/src/alcs/application/application-tag/application-tag.dto.ts @@ -0,0 +1,6 @@ +import { IsString } from 'class-validator'; + +export class ApplicationTagDto { + @IsString() + tagName: string; +} diff --git a/services/apps/alcs/src/alcs/application/application-tag/application-tag.service.spec.ts b/services/apps/alcs/src/alcs/application/application-tag/application-tag.service.spec.ts new file mode 100644 index 000000000..95c5e0e34 --- /dev/null +++ b/services/apps/alcs/src/alcs/application/application-tag/application-tag.service.spec.ts @@ -0,0 +1,122 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ApplicationTagService } from './application-tag.service'; +import { TagModule } from '../../tag/tag.module'; +import { createMock, DeepMocked } from '@golevelup/nestjs-testing'; +import { Repository } from 'typeorm'; +import { Tag } from '../../tag/tag.entity'; +import { Application } from '../application.entity'; +import { + initApplicationMockEntity, + initApplicationWithTagsMockEntity, + initTagMockEntity, +} from '../../../../test/mocks/mockEntities'; +import { getRepositoryToken } from '@nestjs/typeorm'; +import { ServiceNotFoundException, ServiceValidationException } from '@app/common/exceptions/base.exception'; + +describe('ApplicationTagService', () => { + let service: ApplicationTagService; + let tagRepositoryMock: DeepMocked>; + let applicationRepositoryMock: DeepMocked>; + + let mockApplicationEntityWithoutTags: Application; + let mockApplicationEntityWithTags: Application; + let mockApplicationEntityWithDifferentTags: Application; + let mockTagEntity: Tag; + + beforeEach(async () => { + tagRepositoryMock = createMock(); + applicationRepositoryMock = createMock(); + + mockApplicationEntityWithoutTags = initApplicationMockEntity(); + mockApplicationEntityWithTags = initApplicationWithTagsMockEntity(); + mockApplicationEntityWithDifferentTags = initApplicationWithTagsMockEntity(); + mockApplicationEntityWithDifferentTags.tags[0].name = 'tag-name-2'; + mockApplicationEntityWithDifferentTags.tags[0].uuid = 'tag-uuid-2'; + mockTagEntity = initTagMockEntity(); + + const module: TestingModule = await Test.createTestingModule({ + providers: [ + ApplicationTagService, + { provide: getRepositoryToken(Application), useValue: applicationRepositoryMock }, + { provide: getRepositoryToken(Tag), useValue: tagRepositoryMock }, + ], + }).compile(); + + service = module.get(ApplicationTagService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); + + it('should add tag to the application if not existing', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithoutTags); + tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity); + applicationRepositoryMock.save.mockResolvedValue(mockApplicationEntityWithTags); + + await service.addTagToApplication('app_1', 'tag-name'); + expect(mockApplicationEntityWithoutTags.tags.length).toEqual(1); + expect(applicationRepositoryMock.save).toHaveBeenCalledTimes(1); + }); + + it('should raise an error if application is not found', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(null); + + await expect(service.addTagToApplication('app-1', 'tag-name')).rejects.toThrow(ServiceNotFoundException); + }); + + it('should throw an error if tag is not found', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithoutTags); + tagRepositoryMock.findOne.mockResolvedValue(null); + + await expect(service.addTagToApplication('app-1', 'tag-name')).rejects.toThrow(ServiceNotFoundException); + }); + + it('should raise an error if the application already has the tag', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithTags); + tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity); + + await expect(service.addTagToApplication('app-1', 'tag-name')).rejects.toThrow(ServiceValidationException); + }); + + it('should throw an error if the application does not have any tags when deleting', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithoutTags); + tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity); + + await expect(service.removeTagFromApplication('app-1', 'tag-name')).rejects.toThrow(ServiceValidationException); + }); + + it('should throw an error if the application does not have the tag requested when deleting', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithDifferentTags); + tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity); + + await expect(service.removeTagFromApplication('app-1', 'tag-name')).rejects.toThrow(ServiceValidationException); + }); + + it('should delete the tag from application if exists', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithTags); + tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity); + applicationRepositoryMock.save.mockResolvedValue(mockApplicationEntityWithoutTags); + + await service.removeTagFromApplication('app-1', 'tag-name'); + expect(mockApplicationEntityWithTags.tags.length).toEqual(0); + expect(applicationRepositoryMock.save).toHaveBeenCalledTimes(1); + }); + + it('should return application tags', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithTags); + tagRepositoryMock.findOne.mockResolvedValue(mockTagEntity); + + const result = await service.getApplicationTags('app-1'); + expect(result).toBeTruthy(); + expect(result.length).toEqual(1); + }); + + it('should return empty array if application does not have tags', async () => { + applicationRepositoryMock.findOne.mockResolvedValue(mockApplicationEntityWithoutTags); + + const result = await service.getApplicationTags('app-1'); + expect(result).toEqual([]); + expect(result.length).toEqual(0); + }); +}); diff --git a/services/apps/alcs/src/alcs/application/application-tag/application-tag.service.ts b/services/apps/alcs/src/alcs/application/application-tag/application-tag.service.ts new file mode 100644 index 000000000..3e9cc3963 --- /dev/null +++ b/services/apps/alcs/src/alcs/application/application-tag/application-tag.service.ts @@ -0,0 +1,81 @@ +import { Inject, Injectable } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Repository } from 'typeorm'; +import { Tag } from '../../tag/tag.entity'; +import { Application } from '../application.entity'; +import { ServiceNotFoundException, ServiceValidationException } from '@app/common/exceptions/base.exception'; + +@Injectable() +export class ApplicationTagService { + constructor( + @InjectRepository(Tag) private tagRepository: Repository, + @InjectRepository(Application) private applicationRepository: Repository, + ) {} + + async addTagToApplication(fileNumber: string, tagName: string) { + const application = await this.applicationRepository.findOne({ + where: { fileNumber: fileNumber }, + relations: ['tags'], + }); + if (!application) { + throw new ServiceNotFoundException(`Application not found with number ${fileNumber}`); + } + + const tag = await this.tagRepository.findOne({ where: { name: tagName } }); + if (!tag) { + throw new ServiceNotFoundException(`Tag not found with name ${tagName}`); + } + + if (!application.tags) { + application.tags = []; + } + + const tagExists = application.tags.some((t) => t.uuid === tag.uuid); + if (tagExists) { + throw new ServiceValidationException(`Tag ${tagName} already exists`); + } + + application.tags.push(tag); + return this.applicationRepository.save(application); + } + + async removeTagFromApplication(fileNumber: string, tagName: string) { + const application = await this.applicationRepository.findOne({ + where: { fileNumber: fileNumber }, + relations: ['tags'], + }); + if (!application) { + throw new ServiceNotFoundException(`Application not found with number ${fileNumber}`); + } + + const tag = await this.tagRepository.findOne({ where: { name: tagName } }); + if (!tag) { + throw new ServiceNotFoundException(`Tag not found with name ${tagName}`); + } + + if (!application.tags) { + application.tags = []; + } + + const tagExists = application.tags.some((t) => t.uuid === tag.uuid); + if (!tagExists) { + throw new ServiceValidationException(`Tag ${tagName} does not exist in the application`); + } + + application.tags = application.tags.filter((t) => t.uuid !== tag.uuid); + return this.applicationRepository.save(application); + } + + async getApplicationTags(fileNumber: string) { + const application = await this.applicationRepository.findOne({ + where: { fileNumber: fileNumber }, + relations: ['tags'], + }); + + if (!application) { + throw new ServiceNotFoundException(`Application not found with number ${fileNumber}`); + } + + return application.tags && application.tags.length > 0 ? application.tags : []; + } +} diff --git a/services/apps/alcs/src/alcs/application/application.entity.ts b/services/apps/alcs/src/alcs/application/application.entity.ts index fa83fd671..e21bf1fb5 100644 --- a/services/apps/alcs/src/alcs/application/application.entity.ts +++ b/services/apps/alcs/src/alcs/application/application.entity.ts @@ -6,6 +6,8 @@ import { Entity, Index, JoinColumn, + JoinTable, + ManyToMany, ManyToOne, OneToMany, OneToOne, @@ -23,10 +25,11 @@ import { ApplicationDecisionMeeting } from './application-decision-meeting/appli import { ApplicationDocument } from './application-document/application-document.entity'; import { ApplicationMeeting } from './application-meeting/application-meeting.entity'; import { ApplicationPaused } from './application-paused.entity'; +import { Tag } from '../tag/tag.entity'; +// import { ApplicationTag } from './application-tag/application-tag.entity'; @Entity({ - comment: - 'Base data for applications including the ID, key dates, and the date of the first decision', + comment: 'Base data for applications including the ID, key dates, and the date of the first decision', }) export class Application extends Base { constructor(data?: Partial) { @@ -266,8 +269,7 @@ export class Application extends Base { @AutoMap(() => String) @Column({ type: 'text', - comment: - 'Application Id that is applicable only to paper version applications from 70s - 80s', + comment: 'Application Id that is applicable only to paper version applications from 70s - 80s', nullable: true, }) legacyId?: string | null; @@ -277,10 +279,7 @@ export class Application extends Base { pauses: ApplicationPaused[]; @AutoMap() - @OneToMany( - () => ApplicationDecisionMeeting, - (appDecMeeting) => appDecMeeting.application, - ) + @OneToMany(() => ApplicationDecisionMeeting, (appDecMeeting) => appDecMeeting.application) decisionMeetings: ApplicationDecisionMeeting[]; @AutoMap() @@ -288,10 +287,7 @@ export class Application extends Base { applicationMeetings: ApplicationMeeting[]; @AutoMap() - @OneToMany( - () => ApplicationDocument, - (appDocument) => appDocument.application, - ) + @OneToMany(() => ApplicationDocument, (appDocument) => appDocument.application) documents: ApplicationDocument[]; @AutoMap() @@ -309,16 +305,15 @@ export class Application extends Base { cardUuid: string; @AutoMap() - @OneToMany( - () => ApplicationReconsideration, - (appRecon) => appRecon.application, - ) + @OneToMany(() => ApplicationReconsideration, (appRecon) => appRecon.application) reconsiderations: ApplicationReconsideration[]; @AutoMap(() => ApplicationSubmissionReview) - @OneToOne( - () => ApplicationSubmissionReview, - (appReview) => appReview.application, - ) + @OneToOne(() => ApplicationSubmissionReview, (appReview) => appReview.application) submittedApplicationReview?: ApplicationSubmissionReview; + + @AutoMap(() => [Tag]) + @ManyToMany(() => Tag, (tag) => tag.applications) + @JoinTable({ name: 'application_tag' }) + tags: Tag[]; } diff --git a/services/apps/alcs/src/alcs/application/application.module.ts b/services/apps/alcs/src/alcs/application/application.module.ts index 7af5d43e8..d610e59ef 100644 --- a/services/apps/alcs/src/alcs/application/application.module.ts +++ b/services/apps/alcs/src/alcs/application/application.module.ts @@ -45,6 +45,9 @@ import { ApplicationTimeTrackingService } from './application-time-tracking.serv import { ApplicationController } from './application.controller'; import { Application } from './application.entity'; import { ApplicationService } from './application.service'; +import { ApplicationTagService } from './application-tag/application-tag.service'; +import { ApplicationTagController } from './application-tag/application-tag.controller'; +import { TagModule } from '../tag/tag.module'; @Module({ imports: [ @@ -74,6 +77,7 @@ import { ApplicationService } from './application.service'; forwardRef(() => ApplicationSubmissionModule), ApplicationSubmissionStatusModule, LocalGovernmentModule, + TagModule, ], providers: [ ApplicationService, @@ -90,6 +94,7 @@ import { ApplicationService } from './application.service'; ApplicationSubmissionReviewService, ApplicationDecisionMeetingService, ApplicationSubmissionProfile, + ApplicationTagService, ], controllers: [ ApplicationController, @@ -99,6 +104,7 @@ import { ApplicationService } from './application.service'; ApplicationSubmissionController, ApplicationSubmissionReviewController, ApplicationParcelController, + ApplicationTagController, ], exports: [ ApplicationService, @@ -110,6 +116,7 @@ import { ApplicationService } from './application.service'; LocalGovernmentService, ApplicationDocumentService, ApplicationDecisionMeetingService, + ApplicationTagService, ], }) export class ApplicationModule {} diff --git a/services/apps/alcs/src/alcs/tag/tag.entity.ts b/services/apps/alcs/src/alcs/tag/tag.entity.ts index 88bda449b..80f1d2620 100644 --- a/services/apps/alcs/src/alcs/tag/tag.entity.ts +++ b/services/apps/alcs/src/alcs/tag/tag.entity.ts @@ -2,6 +2,7 @@ import { AutoMap } from 'automapper-classes'; import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Base } from '../../common/entities/base.entity'; import { TagCategory } from './tag-category/tag-category.entity'; +import { Application } from '../application/application.entity'; import { NoticeOfIntent } from '../notice-of-intent/notice-of-intent.entity'; @Entity({ comment: 'Tag.' }) @@ -30,6 +31,9 @@ export class Tag extends Base { }) category?: TagCategory | null; + @ManyToMany(() => Application, (application) => application.tags) + applications: Application[]; + @ManyToMany(() => NoticeOfIntent, (noticeOfIntent) => noticeOfIntent.tags) noticeOfIntents: NoticeOfIntent[]; } diff --git a/services/apps/alcs/src/providers/typeorm/migrations/1730319303783-add_application_tags.ts b/services/apps/alcs/src/providers/typeorm/migrations/1730319303783-add_application_tags.ts new file mode 100644 index 000000000..72f797fbc --- /dev/null +++ b/services/apps/alcs/src/providers/typeorm/migrations/1730319303783-add_application_tags.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddApplicationTags1730319303783 implements MigrationInterface { + name = 'AddApplicationTags1730319303783' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "alcs"."application_tag" ("application_uuid" uuid NOT NULL, "tag_uuid" uuid NOT NULL, CONSTRAINT "PK_0b7e45b13295c030c1bf552523b" PRIMARY KEY ("application_uuid", "tag_uuid"))`); + await queryRunner.query(`CREATE INDEX "IDX_b3eb1df7fc12b1f93b9b294a49" ON "alcs"."application_tag" ("application_uuid") `); + await queryRunner.query(`CREATE INDEX "IDX_9b7b9b172959a3cb5f9776f0ce" ON "alcs"."application_tag" ("tag_uuid") `); + await queryRunner.query(`ALTER TABLE "alcs"."application_tag" ADD CONSTRAINT "FK_b3eb1df7fc12b1f93b9b294a491" FOREIGN KEY ("application_uuid") REFERENCES "alcs"."application"("uuid") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "alcs"."application_tag" ADD CONSTRAINT "FK_9b7b9b172959a3cb5f9776f0ce3" FOREIGN KEY ("tag_uuid") REFERENCES "alcs"."tag"("uuid") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "alcs"."application_tag" DROP CONSTRAINT "FK_9b7b9b172959a3cb5f9776f0ce3"`); + await queryRunner.query(`ALTER TABLE "alcs"."application_tag" DROP CONSTRAINT "FK_b3eb1df7fc12b1f93b9b294a491"`); + await queryRunner.query(`DROP INDEX "alcs"."IDX_9b7b9b172959a3cb5f9776f0ce"`); + await queryRunner.query(`DROP INDEX "alcs"."IDX_b3eb1df7fc12b1f93b9b294a49"`); + await queryRunner.query(`DROP TABLE "alcs"."application_tag"`); + } + +} diff --git a/services/apps/alcs/test/mocks/mockEntities.ts b/services/apps/alcs/test/mocks/mockEntities.ts index 899457312..33077d062 100644 --- a/services/apps/alcs/test/mocks/mockEntities.ts +++ b/services/apps/alcs/test/mocks/mockEntities.ts @@ -54,10 +54,7 @@ const initCardSubtaskMockEntity = (card: Card, uuid?: string): CardSubtask => { return subtask; }; -const initCardGISSubtaskMockEntity = ( - card: Card, - uuid?: string, -): CardSubtask => { +const initCardGISSubtaskMockEntity = (card: Card, uuid?: string): CardSubtask => { const subtask = new CardSubtask(); subtask.assignee = initUserMockEntity(); subtask.uuid = uuid ?? '11111'; @@ -164,10 +161,7 @@ const initApplicationReconsiderationMockEntity = ( return reconsideration; }; -const initApplicationModificationMockEntity = ( - application?: Application, - card?: Card, -): ApplicationModification => { +const initApplicationModificationMockEntity = (application?: Application, card?: Card): ApplicationModification => { const app = application ?? initApplicationMockEntity(); const modification = new ApplicationModification({ application: app, @@ -208,10 +202,16 @@ const initApplicationMockEntity = (fileNumber?: string): Application => { auditUpdatedAt: new Date(1, 1, 1, 1, 1, 1, 1), } as ApplicationRegion; - applicationEntity.reconsiderations = [ - initApplicationReconsiderationMockEntity(applicationEntity), - ]; + applicationEntity.reconsiderations = [initApplicationReconsiderationMockEntity(applicationEntity)]; + + return applicationEntity; +}; +const initApplicationWithTagsMockEntity = (): Application => { + const applicationEntity = initApplicationMockEntity(); + const tagEntity = initTagMockEntity(); + applicationEntity.tags = []; + applicationEntity.tags.push(tagEntity); return applicationEntity; }; @@ -223,9 +223,7 @@ const initMockUserDto = (assignee?: User): UserDto => { userDto.identityProvider = userEntity.identityProvider; userDto.name = userEntity.name!; userDto.idirUserName = userEntity.idirUserName; - userDto.initials = - userEntity.givenName!.charAt(0).toUpperCase() + - userEntity.familyName.charAt(0).toUpperCase(); + userDto.initials = userEntity.givenName!.charAt(0).toUpperCase() + userEntity.familyName.charAt(0).toUpperCase(); userDto.bceidUserName = undefined; return userDto; @@ -236,9 +234,7 @@ const initMockAssigneeDto = (assignee?: User): AssigneeDto => { const assigneeDto = new AssigneeDto(); assigneeDto.uuid = userEntity.uuid; assigneeDto.name = userEntity.name; - assigneeDto.initials = - userEntity.givenName!.charAt(0).toUpperCase() + - userEntity.familyName.charAt(0).toUpperCase(); + assigneeDto.initials = userEntity.givenName!.charAt(0).toUpperCase() + userEntity.familyName.charAt(0).toUpperCase(); assigneeDto.mentionLabel = userEntity.givenName!.charAt(0).toUpperCase() + userEntity.givenName!.slice(1) + @@ -270,10 +266,7 @@ const initCommentMock = (author?: any): Comment => { return comment; }; -const initCommentMentionMock = ( - comment?: Comment, - user?: User, -): CommentMention => { +const initCommentMentionMock = (comment?: Comment, user?: User): CommentMention => { const mention = new CommentMention(); const commentEntity = comment ?? initCommentMock(); const userEntity = user ?? initUserMockEntity(); @@ -286,16 +279,12 @@ const initCommentMentionMock = ( return mention; }; -const initApplicationDecisionMeetingMock = ( - application?: Application, -): ApplicationDecisionMeeting => { +const initApplicationDecisionMeetingMock = (application?: Application): ApplicationDecisionMeeting => { const meeting = new ApplicationDecisionMeeting(); meeting.application = application ?? initApplicationMockEntity(); meeting.uuid = '11111111'; meeting.date = new Date(2022, 1, 1, 1, 1, 1, 1); - meeting.applicationUuid = application - ? application.uuid - : 'fake-application-uuid'; + meeting.applicationUuid = application ? application.uuid : 'fake-application-uuid'; return meeting; }; @@ -324,9 +313,7 @@ const initApplicationMeetingMock = ( const meeting = new ApplicationMeeting(); meeting.application = application ?? initApplicationMockEntity(); meeting.uuid = '11111111'; - meeting.applicationUuid = application - ? application.uuid - : 'fake-application-uuid'; + meeting.applicationUuid = application ? application.uuid : 'fake-application-uuid'; if (meetingType) { meeting.type = meetingType; } else { @@ -351,6 +338,7 @@ const initTagCategoryMockEntity = (): TagCategory => { const initTagMockEntity = (): Tag => { const tag = new Tag(); + tag.uuid = 'tag-uuid'; tag.name = 'tag-name'; tag.isActive = true; tag.category = initTagCategoryMockEntity(); @@ -380,4 +368,5 @@ export { initApplicationModificationMockEntity, initTagCategoryMockEntity, initTagMockEntity, + initApplicationWithTagsMockEntity, };