From 6dc29d767c1c42b4d4ffa9f61012fb05902cb135 Mon Sep 17 00:00:00 2001 From: Shayan Khorsandi Date: Thu, 12 Dec 2024 10:10:29 -0800 Subject: [PATCH 1/3] fix admin condition type code check on deleted items fix admin condition type codes not checking previously deleted items' codes when creating a new entity --- .../decision-condition-types.component.ts | 6 ++-- ...cation-decision-condition-types.service.ts | 10 +++++++ ...intent-decision-condition-types.service.ts | 17 +++++++++-- ...ecision-condition-types.controller.spec.ts | 30 +++++++++---------- ...ion-decision-condition-types.controller.ts | 6 ++++ ...n-decision-condition-types.service.spec.ts | 9 ++++++ ...cation-decision-condition-types.service.ts | 11 ++++++- ...ecision-condition-types.controller.spec.ts | 21 +++++++++---- ...ent-decision-condition-types.controller.ts | 6 ++++ ...intent-decision-condition-types.service.ts | 9 ++++++ 10 files changed, 98 insertions(+), 27 deletions(-) diff --git a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts index feb85a92a5..cbfc9c8f3e 100644 --- a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts +++ b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts @@ -29,6 +29,7 @@ export class DecisionConditionTypesComponent implements OnInit { destroy = new Subject(); decisionConditionTypeDtos: ApplicationDecisionConditionTypeDto[] | NoticeOfIntentDecisionConditionTypeDto[] = []; + decisionConditionTypeCodeDtos: ApplicationDecisionConditionTypeDto[] | NoticeOfIntentDecisionConditionTypeDto[] = []; displayedColumns: string[] = ['label', 'description', 'code', 'isActive', 'actions']; constructor( @@ -43,6 +44,7 @@ export class DecisionConditionTypesComponent implements OnInit { async fetch() { if (!this.service) return; this.decisionConditionTypeDtos = await this.service.fetch(); + this.decisionConditionTypeCodeDtos = await this.service.fetchCodes(); } async onCreate() { @@ -53,7 +55,7 @@ export class DecisionConditionTypesComponent implements OnInit { data: { service: this.service, conditionService: this.conditionService, - existingCodes: this.decisionConditionTypeDtos.map((dct) => dct.code), + existingCodes: this.decisionConditionTypeCodeDtos.map((dct) => dct.code), }, }); dialog.beforeClosed().subscribe(async (result) => { @@ -72,7 +74,7 @@ export class DecisionConditionTypesComponent implements OnInit { service: this.service, conditionService: this.conditionService, content: dto, - existingCodes: this.decisionConditionTypeDtos.map((dct) => dct.code), + existingCodes: this.decisionConditionTypeCodeDtos.map((dct) => dct.code), }, }); dialog.beforeClosed().subscribe(async (result) => { diff --git a/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts b/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts index f8e8d155cb..ccb931a592 100644 --- a/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts +++ b/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts @@ -26,6 +26,16 @@ export class ApplicationDecisionConditionTypesService { return []; } + async fetchCodes() { + try { + return await firstValueFrom(this.http.get(`${this.url}/codes`)); + } catch (err) { + console.error(err); + this.toastService.showErrorToast('Failed to fetch decision condition type codes'); + } + return []; + } + async create(createDto: ApplicationDecisionConditionTypeDto) { try { return await firstValueFrom(this.http.post(`${this.url}`, createDto)); diff --git a/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts b/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts index 3fdbb69ac3..7355e06421 100644 --- a/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts +++ b/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts @@ -11,7 +11,10 @@ import { NoticeOfIntentDecisionConditionTypeDto } from '../decision-v2/notice-of export class NoticeofIntentDecisionConditionTypesService { private url = `${environment.apiUrl}/noi-decision-condition-types`; - constructor(private http: HttpClient, private toastService: ToastService) {} + constructor( + private http: HttpClient, + private toastService: ToastService, + ) {} async fetch() { try { @@ -23,6 +26,16 @@ export class NoticeofIntentDecisionConditionTypesService { return []; } + async fetchCodes() { + try { + return await firstValueFrom(this.http.get(`${this.url}/codes`)); + } catch (err) { + console.error(err); + this.toastService.showErrorToast('Failed to fetch decision condition type codes'); + } + return []; + } + async create(createDto: NoticeOfIntentDecisionConditionTypeDto) { try { return await firstValueFrom(this.http.post(`${this.url}`, createDto)); @@ -36,7 +49,7 @@ export class NoticeofIntentDecisionConditionTypesService { async update(code: string, updateDto: NoticeOfIntentDecisionConditionTypeDto) { try { return await firstValueFrom( - this.http.patch(`${this.url}/${code}`, updateDto) + this.http.patch(`${this.url}/${code}`, updateDto), ); } catch (e) { this.toastService.showErrorToast('Failed to update decision condition type'); diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts index c405165089..5243f1def5 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts @@ -30,9 +30,7 @@ describe('ApplicationDecisionConditionTypesController', () => { imports: [ConfigModule], }).compile(); - controller = module.get( - ApplicationDecisionConditionTypesController, - ); + controller = module.get(ApplicationDecisionConditionTypesController); }); it('should be defined', () => { @@ -48,28 +46,28 @@ describe('ApplicationDecisionConditionTypesController', () => { expect(mockDecTypesService.fetch).toHaveBeenCalledTimes(1); }); + it('should call out to service when fetching decision condition type codes', async () => { + mockDecTypesService.fetchCodes.mockResolvedValue([]); + + const applicationDecisionConditionTypeCodes = await controller.fetchCodes(); + + expect(applicationDecisionConditionTypeCodes).toBeDefined(); + expect(mockDecTypesService.fetchCodes).toHaveBeenCalledTimes(1); + }); + it('should call out to service when updating decision condition type', async () => { - mockDecTypesService.update.mockResolvedValue( - new ApplicationDecisionConditionType(), - ); + mockDecTypesService.update.mockResolvedValue(new ApplicationDecisionConditionType()); - const applicationDecisionConditionType = await controller.update( - 'fake', - new ApplicationDecisionConditionType(), - ); + const applicationDecisionConditionType = await controller.update('fake', new ApplicationDecisionConditionType()); expect(applicationDecisionConditionType).toBeDefined(); expect(mockDecTypesService.update).toHaveBeenCalledTimes(1); }); it('should call out to service when creating decision condition type', async () => { - mockDecTypesService.create.mockResolvedValue( - new ApplicationDecisionConditionType(), - ); + mockDecTypesService.create.mockResolvedValue(new ApplicationDecisionConditionType()); - const applicationDecisionConditionType = await controller.create( - new ApplicationDecisionConditionType(), - ); + const applicationDecisionConditionType = await controller.create(new ApplicationDecisionConditionType()); expect(applicationDecisionConditionType).toBeDefined(); expect(mockDecTypesService.create).toHaveBeenCalledTimes(1); diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts index 154dca9226..677b75efa3 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts @@ -36,4 +36,10 @@ export class ApplicationDecisionConditionTypesController { async create(@Body() createDto: ApplicationDecisionConditionTypeDto) { return await this.applicationDecisionConditionTypesService.create(createDto); } + + @Get('/codes') + @UserRoles(AUTH_ROLE.ADMIN) + async fetchCodes() { + return await this.applicationDecisionConditionTypesService.fetchCodes(); + } } diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts index 286bb3977e..0430d8f7de 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts @@ -131,4 +131,13 @@ describe('ApplicationDecisionConditionTypesService', () => { expect(mockRepository.find).toBeCalledTimes(1); expect(result).toBeDefined(); }); + + it('should successfully fetch decision condition type code', async () => { + mockRepository.find.mockResolvedValue([type]); + + const result = await service.fetchCodes(); + + expect(mockRepository.find).toHaveBeenCalledTimes(1); + expect(result).toBeDefined(); + }); }); diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts index db91076282..9ffe848585 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts @@ -20,7 +20,7 @@ export class ApplicationDecisionConditionTypesService { private applicationDecisionConditionTypeRepository: Repository, ) {} - async fetch() { + async fetch(includeDeleted: boolean = false) { return await this.applicationDecisionConditionTypeRepository.find({ order: { label: 'ASC' }, select: { @@ -43,6 +43,15 @@ export class ApplicationDecisionConditionTypesService { }); } + async fetchCodes() { + return await this.applicationDecisionConditionTypeRepository.find({ + select: { + code: true, + }, + withDeleted: true, + }); + } + async getOneOrFail(code: string) { return await this.applicationDecisionConditionTypeRepository.findOneOrFail({ where: { code }, diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts index 179cd9405c..a88c5bddc0 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts @@ -42,27 +42,36 @@ describe('NoticeofIntentDecisionConditionTypesController', () => { it('should call out to service when fetching decision condition type', async () => { mockDecTypesService.fetch.mockResolvedValue([]); - const applicationDecisionConditionTypes = await controller.fetch(); + const noiDecisionConditionTypes = await controller.fetch(); - expect(applicationDecisionConditionTypes).toBeDefined(); + expect(noiDecisionConditionTypes).toBeDefined(); expect(mockDecTypesService.fetch).toHaveBeenCalledTimes(1); }); + it('should call out to service when fetching decision condition type codes', async () => { + mockDecTypesService.fetchCodes.mockResolvedValue([]); + + const noiDecisionConditionTypeCodes = await controller.fetchCodes(); + + expect(noiDecisionConditionTypeCodes).toBeDefined(); + expect(mockDecTypesService.fetchCodes).toHaveBeenCalledTimes(1); + }); + it('should call out to service when updating decision condition type', async () => { mockDecTypesService.update.mockResolvedValue(new NoticeOfIntentDecisionConditionType()); - const applicationDecisionConditionType = await controller.update('fake', new NoticeOfIntentDecisionConditionType()); + const noiDecisionConditionType = await controller.update('fake', new NoticeOfIntentDecisionConditionType()); - expect(applicationDecisionConditionType).toBeDefined(); + expect(noiDecisionConditionType).toBeDefined(); expect(mockDecTypesService.update).toHaveBeenCalledTimes(1); }); it('should call out to service when creating decision condition type', async () => { mockDecTypesService.create.mockResolvedValue(new NoticeOfIntentDecisionConditionType()); - const applicationDecisionConditionType = await controller.create(new NoticeOfIntentDecisionConditionType()); + const noiDecisionConditionType = await controller.create(new NoticeOfIntentDecisionConditionType()); - expect(applicationDecisionConditionType).toBeDefined(); + expect(noiDecisionConditionType).toBeDefined(); expect(mockDecTypesService.create).toHaveBeenCalledTimes(1); }); }); diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts index a46629db35..0aaef71b2f 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts @@ -36,4 +36,10 @@ export class NoticeofIntentDecisionConditionTypesController { async create(@Body() createDto: NoticeOfIntentDecisionConditionTypeDto) { return await this.noiDecisionConditionTypesService.create(createDto); } + + @Get('/codes') + @UserRoles(AUTH_ROLE.ADMIN) + async fetchCodes() { + return await this.noiDecisionConditionTypesService.fetchCodes(); + } } diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts index 22d216a2d4..58517b914f 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts @@ -41,6 +41,15 @@ export class NoticeofIntentDecisionConditionTypesService { }); } + async fetchCodes() { + return await this.noiDecisionConditionTypeRepository.find({ + select: { + code: true, + }, + withDeleted: true, + }); + } + async getOneOrFail(code: string) { return await this.noiDecisionConditionTypeRepository.findOneOrFail({ where: { code }, From 1d3f437936ef314d03c406edb39b700281bc1cca Mon Sep 17 00:00:00 2001 From: Shayan Khorsandi Date: Thu, 12 Dec 2024 11:07:04 -0800 Subject: [PATCH 2/3] rename functions and remove redundant DTO --- .../decision-condition-types.component.ts | 6 +++--- .../application-decision-condition-types.service.ts | 2 +- .../notice-of-intent-decision-condition-types.service.ts | 2 +- .../application-decision-condition-types.controller.spec.ts | 6 +++--- .../application-decision-condition-types.controller.ts | 4 ++-- .../application-decision-condition-types.service.spec.ts | 2 +- .../application-decision-condition-types.service.ts | 2 +- ...ce-of-intent-decision-condition-types.controller.spec.ts | 2 +- .../notice-of-intent-decision-condition-types.controller.ts | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts index cbfc9c8f3e..dbb1aad976 100644 --- a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts +++ b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts @@ -29,7 +29,7 @@ export class DecisionConditionTypesComponent implements OnInit { destroy = new Subject(); decisionConditionTypeDtos: ApplicationDecisionConditionTypeDto[] | NoticeOfIntentDecisionConditionTypeDto[] = []; - decisionConditionTypeCodeDtos: ApplicationDecisionConditionTypeDto[] | NoticeOfIntentDecisionConditionTypeDto[] = []; + decisionConditionTypeCodeDtos: string[] = []; displayedColumns: string[] = ['label', 'description', 'code', 'isActive', 'actions']; constructor( @@ -55,7 +55,7 @@ export class DecisionConditionTypesComponent implements OnInit { data: { service: this.service, conditionService: this.conditionService, - existingCodes: this.decisionConditionTypeCodeDtos.map((dct) => dct.code), + existingCodes: this.decisionConditionTypeCodeDtos, }, }); dialog.beforeClosed().subscribe(async (result) => { @@ -74,7 +74,7 @@ export class DecisionConditionTypesComponent implements OnInit { service: this.service, conditionService: this.conditionService, content: dto, - existingCodes: this.decisionConditionTypeCodeDtos.map((dct) => dct.code), + existingCodes: this.decisionConditionTypeCodeDtos, }, }); dialog.beforeClosed().subscribe(async (result) => { diff --git a/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts b/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts index ccb931a592..8022282c6d 100644 --- a/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts +++ b/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts @@ -28,7 +28,7 @@ export class ApplicationDecisionConditionTypesService { async fetchCodes() { try { - return await firstValueFrom(this.http.get(`${this.url}/codes`)); + return await firstValueFrom(this.http.get(`${this.url}/codes`)); } catch (err) { console.error(err); this.toastService.showErrorToast('Failed to fetch decision condition type codes'); diff --git a/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts b/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts index 7355e06421..27656cb81d 100644 --- a/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts +++ b/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts @@ -28,7 +28,7 @@ export class NoticeofIntentDecisionConditionTypesService { async fetchCodes() { try { - return await firstValueFrom(this.http.get(`${this.url}/codes`)); + return await firstValueFrom(this.http.get(`${this.url}/codes`)); } catch (err) { console.error(err); this.toastService.showErrorToast('Failed to fetch decision condition type codes'); diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts index 5243f1def5..40cbf99c64 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.spec.ts @@ -47,12 +47,12 @@ describe('ApplicationDecisionConditionTypesController', () => { }); it('should call out to service when fetching decision condition type codes', async () => { - mockDecTypesService.fetchCodes.mockResolvedValue([]); + mockDecTypesService.fetchCodesWithDeleted.mockResolvedValue([]); - const applicationDecisionConditionTypeCodes = await controller.fetchCodes(); + const applicationDecisionConditionTypeCodes = await controller.fetchCodesWithDeleted(); expect(applicationDecisionConditionTypeCodes).toBeDefined(); - expect(mockDecTypesService.fetchCodes).toHaveBeenCalledTimes(1); + expect(mockDecTypesService.fetchCodesWithDeleted).toHaveBeenCalledTimes(1); }); it('should call out to service when updating decision condition type', async () => { diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts index 677b75efa3..6b7fc23be9 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.controller.ts @@ -39,7 +39,7 @@ export class ApplicationDecisionConditionTypesController { @Get('/codes') @UserRoles(AUTH_ROLE.ADMIN) - async fetchCodes() { - return await this.applicationDecisionConditionTypesService.fetchCodes(); + async fetchCodesWithDeleted() { + return (await this.applicationDecisionConditionTypesService.fetchCodesWithDeleted()).map((adct) => adct.code); } } diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts index 0430d8f7de..48aee976ec 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.spec.ts @@ -135,7 +135,7 @@ describe('ApplicationDecisionConditionTypesService', () => { it('should successfully fetch decision condition type code', async () => { mockRepository.find.mockResolvedValue([type]); - const result = await service.fetchCodes(); + const result = await service.fetchCodesWithDeleted(); expect(mockRepository.find).toHaveBeenCalledTimes(1); expect(result).toBeDefined(); diff --git a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts index 9ffe848585..acfb8a1fa6 100644 --- a/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts +++ b/services/apps/alcs/src/alcs/admin/application-decision-condition-types/application-decision-condition-types.service.ts @@ -43,7 +43,7 @@ export class ApplicationDecisionConditionTypesService { }); } - async fetchCodes() { + async fetchCodesWithDeleted() { return await this.applicationDecisionConditionTypeRepository.find({ select: { code: true, diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts index a88c5bddc0..1d9b2da065 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts @@ -51,7 +51,7 @@ describe('NoticeofIntentDecisionConditionTypesController', () => { it('should call out to service when fetching decision condition type codes', async () => { mockDecTypesService.fetchCodes.mockResolvedValue([]); - const noiDecisionConditionTypeCodes = await controller.fetchCodes(); + const noiDecisionConditionTypeCodes = await controller.fetchCodesWithDeleted(); expect(noiDecisionConditionTypeCodes).toBeDefined(); expect(mockDecTypesService.fetchCodes).toHaveBeenCalledTimes(1); diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts index 0aaef71b2f..2c9ac0c405 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts @@ -39,7 +39,7 @@ export class NoticeofIntentDecisionConditionTypesController { @Get('/codes') @UserRoles(AUTH_ROLE.ADMIN) - async fetchCodes() { - return await this.noiDecisionConditionTypesService.fetchCodes(); + async fetchCodesWithDeleted() { + return (await this.noiDecisionConditionTypesService.fetchCodes()).map((ndct) => ndct.code); } } From dd290740765158e361df10b77e7bf76b456df5d4 Mon Sep 17 00:00:00 2001 From: Shayan Khorsandi Date: Thu, 12 Dec 2024 12:10:05 -0800 Subject: [PATCH 3/3] rename functions --- .../decision-condition-types.component.ts | 2 +- .../application-decision-condition-types.service.ts | 2 +- .../notice-of-intent-decision-condition-types.service.ts | 2 +- ...tice-of-intent-decision-condition-types.controller.spec.ts | 4 ++-- .../notice-of-intent-decision-condition-types.controller.ts | 2 +- .../notice-of-intent-decision-condition-types.service.ts | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts index dbb1aad976..e96bd6ebe3 100644 --- a/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts +++ b/alcs-frontend/src/app/features/admin/decision-condition-types/decision-condition-types.component.ts @@ -44,7 +44,7 @@ export class DecisionConditionTypesComponent implements OnInit { async fetch() { if (!this.service) return; this.decisionConditionTypeDtos = await this.service.fetch(); - this.decisionConditionTypeCodeDtos = await this.service.fetchCodes(); + this.decisionConditionTypeCodeDtos = await this.service.fetchCodesWithDeleted(); } async onCreate() { diff --git a/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts b/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts index 8022282c6d..50a5f854bc 100644 --- a/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts +++ b/alcs-frontend/src/app/services/application/application-decision-condition-types/application-decision-condition-types.service.ts @@ -26,7 +26,7 @@ export class ApplicationDecisionConditionTypesService { return []; } - async fetchCodes() { + async fetchCodesWithDeleted() { try { return await firstValueFrom(this.http.get(`${this.url}/codes`)); } catch (err) { diff --git a/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts b/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts index 27656cb81d..66d23e13e5 100644 --- a/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts +++ b/alcs-frontend/src/app/services/notice-of-intent/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts @@ -26,7 +26,7 @@ export class NoticeofIntentDecisionConditionTypesService { return []; } - async fetchCodes() { + async fetchCodesWithDeleted() { try { return await firstValueFrom(this.http.get(`${this.url}/codes`)); } catch (err) { diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts index 1d9b2da065..0bfa6d933c 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.spec.ts @@ -49,12 +49,12 @@ describe('NoticeofIntentDecisionConditionTypesController', () => { }); it('should call out to service when fetching decision condition type codes', async () => { - mockDecTypesService.fetchCodes.mockResolvedValue([]); + mockDecTypesService.fetchCodesWithDeleted.mockResolvedValue([]); const noiDecisionConditionTypeCodes = await controller.fetchCodesWithDeleted(); expect(noiDecisionConditionTypeCodes).toBeDefined(); - expect(mockDecTypesService.fetchCodes).toHaveBeenCalledTimes(1); + expect(mockDecTypesService.fetchCodesWithDeleted).toHaveBeenCalledTimes(1); }); it('should call out to service when updating decision condition type', async () => { diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts index 2c9ac0c405..f73a7e86ec 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.controller.ts @@ -40,6 +40,6 @@ export class NoticeofIntentDecisionConditionTypesController { @Get('/codes') @UserRoles(AUTH_ROLE.ADMIN) async fetchCodesWithDeleted() { - return (await this.noiDecisionConditionTypesService.fetchCodes()).map((ndct) => ndct.code); + return (await this.noiDecisionConditionTypesService.fetchCodesWithDeleted()).map((ndct) => ndct.code); } } diff --git a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts index 58517b914f..d94888aa56 100644 --- a/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts +++ b/services/apps/alcs/src/alcs/admin/notice-of-intent-decision-condition-types/notice-of-intent-decision-condition-types.service.ts @@ -41,7 +41,7 @@ export class NoticeofIntentDecisionConditionTypesService { }); } - async fetchCodes() { + async fetchCodesWithDeleted() { return await this.noiDecisionConditionTypeRepository.find({ select: { code: true,