Skip to content

Commit

Permalink
Merge pull request #968 from bcgov/feature/ALCS-1142
Browse files Browse the repository at this point in the history
More Bug Fixes
  • Loading branch information
dhaselhan authored Sep 14, 2023
2 parents d705fa1 + a766884 commit a48a784
Show file tree
Hide file tree
Showing 24 changed files with 125 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ <h6 class="card-type-label">Notice of Intent</h6>
<div class="left">
<h3 class="card-title">
<span class="margin-right">{{ cardTitle }}</span>
<app-application-type-pill [type]="noticeOfIntent.type"></app-application-type-pill>
<app-application-type-pill
*ngIf="noticeOfIntent.retroactive"
[type]="RETROACTIVE_TYPE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { BehaviorSubject } from 'rxjs';
import { ApplicationService } from '../../../../../services/application/application.service';
import { ApplicationDecisionV2Service } from '../../../../../services/application/decision/application-decision-v2/application-decision-v2.service';
import { NoticeOfIntentDecisionV2Service } from '../../../../../services/notice-of-intent/decision-v2/notice-of-intent-decision-v2.service';
import { NoticeOfIntentDecisionDto } from '../../../../../services/notice-of-intent/decision/notice-of-intent-decision.dto';
import { NoticeOfIntentService } from '../../../../../services/notice-of-intent/notice-of-intent.service';
import { NoticeOfIntentSubmissionStatusService } from '../../../../../services/notice-of-intent/notice-of-intent-submission-status/notice-of-intent-submission-status.service';
import { ReleaseDialogComponent } from './release-dialog.component';

describe('ReleaseDialogComponent', () => {
let component: ReleaseDialogComponent;
let fixture: ComponentFixture<ReleaseDialogComponent>;
let mockNOIService: DeepMocked<NoticeOfIntentService>;
let mockNOISubmissionStatusService: DeepMocked<NoticeOfIntentSubmissionStatusService>;
let mockNOIDecisionV2Service: DeepMocked<NoticeOfIntentDecisionV2Service>;

beforeEach(async () => {
mockNOIService = createMock();
mockNOISubmissionStatusService = createMock();
mockNOIDecisionV2Service = createMock();
mockNOIDecisionV2Service.$decision = new BehaviorSubject<NoticeOfIntentDecisionDto | undefined>(undefined);

await TestBed.configureTestingModule({
declarations: [ReleaseDialogComponent],
providers: [
{
provide: NoticeOfIntentService,
useValue: mockNOIService,
provide: NoticeOfIntentSubmissionStatusService,
useValue: mockNOISubmissionStatusService,
},
{
provide: NoticeOfIntentDecisionV2Service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Subject, takeUntil } from 'rxjs';
import { NoticeOfIntentDecisionV2Service } from '../../../../../services/notice-of-intent/decision-v2/notice-of-intent-decision-v2.service';
import { NoticeOfIntentService } from '../../../../../services/notice-of-intent/notice-of-intent.service';
import { NoticeOfIntentSubmissionStatusService } from '../../../../../services/notice-of-intent/notice-of-intent-submission-status/notice-of-intent-submission-status.service';
import { NOI_SUBMISSION_STATUS } from '../../../../../services/notice-of-intent/notice-of-intent.dto';
import { ApplicationPill } from '../../../../../shared/application-type-pill/application-type-pill.component';

@Component({
Expand All @@ -16,33 +17,35 @@ export class ReleaseDialogComponent implements OnInit, OnDestroy {
wasReleased = false;

constructor(
private noticeOfIntentService: NoticeOfIntentService,
private noticeOfIntentSubmissionStatusService: NoticeOfIntentSubmissionStatusService,
private decisionService: NoticeOfIntentDecisionV2Service,
public matDialogRef: MatDialogRef<ReleaseDialogComponent>,
@Inject(MAT_DIALOG_DATA) data: any
) {}

ngOnInit(): void {
// this.applicationService.$applicationStatuses.pipe(takeUntil(this.$destroy)).subscribe((statuses) => {
// if (statuses) {
// const releasedStatus = statuses.find((status) => status.code === SUBMISSION_STATUS.ALC_DECISION);
// if (releasedStatus) {
// this.mappedType = {
// label: releasedStatus.label,
// backgroundColor: releasedStatus.alcsBackgroundColor,
// borderColor: releasedStatus.alcsBackgroundColor,
// textColor: releasedStatus.alcsColor,
// shortLabel: releasedStatus.label,
// };
// }
// }
// });

this.decisionService.$decision.pipe(takeUntil(this.$destroy)).subscribe((decision) => {
if (decision) {
this.wasReleased = decision.wasReleased;
}
});
this.loadStatuses();
}

private async loadStatuses() {
const statuses = await this.noticeOfIntentSubmissionStatusService.listStatuses();
if (statuses) {
const releasedStatus = statuses.find((status) => status.code === NOI_SUBMISSION_STATUS.ALC_DECISION);
if (releasedStatus) {
this.mappedType = {
label: releasedStatus.label,
backgroundColor: releasedStatus.alcsBackgroundColor,
borderColor: releasedStatus.alcsBackgroundColor,
textColor: releasedStatus.alcsColor,
shortLabel: releasedStatus.label,
};
}
}
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<div class="layout">
<div class="application">
<app-details-header
*ngIf='noticeOfIntent'
heading="Notice of Intent"
[application]="noticeOfIntent"
[reconsiderations]="[]"
[modifications]="modifications"
[types]='[noticeOfIntent.type]'
days="Calendar Days"
[showStatus]="true"
[submissionStatusService]="noticeOfIntentStatusService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NoticeOfIntentDetailService } from '../../services/notice-of-intent/not
import { NoticeOfIntentModificationDto } from '../../services/notice-of-intent/notice-of-intent-modification/notice-of-intent-modification.dto';
import { NoticeOfIntentModificationService } from '../../services/notice-of-intent/notice-of-intent-modification/notice-of-intent-modification.service';
import { NoticeOfIntentSubmissionStatusService } from '../../services/notice-of-intent/notice-of-intent-submission-status/notice-of-intent-submission-status.service';
import { NOI_SUBMISSION_STATUS, NoticeOfIntentDto } from '../../services/notice-of-intent/notice-of-intent.dto';
import { NoticeOfIntentDto } from '../../services/notice-of-intent/notice-of-intent.dto';
import { SYSTEM_SOURCE_TYPES } from '../../shared/dto/system-source.types.dto';
import { ApplicantInfoComponent } from './applicant-info/applicant-info.component';
import { decisionChildRoutes, DecisionModule } from './decision/decision.module';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<div class="layout">
<div class="application">
<app-details-header
*ngIf="notification"
heading="Notification"
[application]="notification"
[types]="[notification.type]"
days="Calendar Days"
[showStatus]="true"
[submissionStatusService]="notificationSubmissionStatusService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ describe('NoticeOfIntentSubmissionStatusService', () => {
expect(service).toBeTruthy();
});

it('should call get for list all statuses', async () => {
mockHttpClient.get.mockReturnValue(
of([
{
code: 'fake',
},
])
);

const res = await service.listStatuses();

expect(mockHttpClient.get).toHaveBeenCalledTimes(1);
expect(res.length).toEqual(1);
expect(res[0].code).toEqual('fake');
});

it('should fetch statuses by fileNumber', async () => {
mockHttpClient.get.mockReturnValue(
of([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Injectable } from '@angular/core';
import { firstValueFrom } from 'rxjs';
import { environment } from '../../../../environments/environment';
import { ToastService } from '../../toast/toast.service';
import { NoticeOfIntentSubmissionToSubmissionStatusDto } from './notice-of-intent-submission-status.dto';
import {
NoticeOfIntentStatusDto,
NoticeOfIntentSubmissionToSubmissionStatusDto,
} from './notice-of-intent-submission-status.dto';

@Injectable({
providedIn: 'root',
Expand All @@ -13,6 +16,15 @@ export class NoticeOfIntentSubmissionStatusService {

constructor(private http: HttpClient, private toastService: ToastService) {}

async listStatuses(): Promise<NoticeOfIntentStatusDto[]> {
try {
return await firstValueFrom(this.http.get<NoticeOfIntentStatusDto[]>(`${this.baseUrl}`));
} catch (e) {
this.toastService.showErrorToast('Failed to fetch NOI Statuses');
throw e;
}
}

async fetchSubmissionStatusesByFileNumber(
fileNumber: string,
showErrorToast = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class DetailsHeaderComponent {
destroy = new Subject<void>();

@Input() heading = 'Title Here';
@Input() types: ApplicationTypeDto[] = [];
@Input() days = 'Calendar Days';
@Input() showStatus = false;
@Input() submissionStatusService?:
Expand All @@ -42,6 +41,7 @@ export class DetailsHeaderComponent {
legacyId?: string;

_application: ApplicationDto | CommissionerApplicationDto | NoticeOfIntentDto | NotificationDto | undefined;
types: ApplicationTypeDto[] = [];
timeTrackable?: TimeTrackable;

@Input() set application(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h2>Additional Proposal Information</h2>
[value]="element.type"
placeholder="Please select"
[formControlName]="i + '-type'"
(valueChange)="onChangeStructureType()"
(valueChange)="onChangeStructureType(i, $event)"
>
<mat-option *ngFor="let type of STRUCTURE_TYPES" [value]="type">
{{ type }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ export class AdditionalInformationComponent extends FilesStepComponent implement
}
}

onChangeStructureType() {
onChangeStructureType(index: number, value: STRUCTURE_TYPES) {
this.proposedStructures[index].type = value;
this.prepareStructureSpecificTextInputs();
this.form.markAsDirty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ <h3>ALC Review and Decision</h3>
<div *ngIf="noiSubmission.status.code === NOI_SUBMISSION_STATUS.IN_PROGRESS" class="warning">
This section will update after the Notice of Intent is submitted to the ALC.
</div>
<div
*ngIf="
noiSubmission.status.code === NOI_SUBMISSION_STATUS.SUBMITTED_TO_ALC ||
noiSubmission.status.code === NOI_SUBMISSION_STATUS.ALC_DECISION
"
>
<div *ngIf="noiSubmission.status.code !== NOI_SUBMISSION_STATUS.IN_PROGRESS">
<app-decisions [fileNumber]="noiSubmission.fileNumber"></app-decisions>
<app-submission-documents [$noiDocuments]="$noiDocuments"></app-submission-documents>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ <h2>Government</h2>
will need to contact the ALC directly: &nbsp;<a href="mailto:ALC.Portal@gov.bc.ca">ALC.Portal@gov.bc.ca</a
>&nbsp;/&nbsp;<a href="tel:236-468-3342">236-468-3342</a>
</app-warning-banner>
<app-warning-banner *ngIf="selectedOwnGovernment" class="full-row">
You're logged in with a Business BCeID that is associated with the government selected above. You will have the
opportunity to complete the local or first nation government review form immediately after this application is
submitted.
</app-warning-banner>
<p>
Please Note: If your Local or First Nation Government is not listed, please contact the ALC directly.
<a href="mailto:ALC.Portal@gov.bc.ca">ALC.Portal@gov.bc.ca</a> / <a href="tel:236-468-3342">236-468-3342</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class SelectGovernmentComponent extends StepComponent implements OnInit,

localGovernment = new FormControl<string | any>('', [Validators.required]);
showWarning = false;
selectedOwnGovernment = false;
selectGovernmentUuid = '';
localGovernments: LocalGovernmentDto[] = [];
filteredLocalGovernments!: Observable<LocalGovernmentDto[]>;
Expand Down Expand Up @@ -71,8 +70,6 @@ export class SelectGovernmentComponent extends StepComponent implements OnInit,
} else {
this.localGovernment.setErrors({ invalid: localGovernment.hasGuid });
}

this.selectedOwnGovernment = localGovernment.matchesUserGuid;
}
}
}
Expand Down Expand Up @@ -138,7 +135,6 @@ export class SelectGovernmentComponent extends StepComponent implements OnInit,
if (!lg.hasGuid) {
this.localGovernment.setErrors({ invalid: true });
}
this.selectedOwnGovernment = lg.matchesUserGuid;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ describe('NoticeOfIntentSubmissionStatusController', () => {
expect(controller).toBeDefined();
});

it('should call the service for list statuses', async () => {
mockNoticeOfIntentSubmissionStatusService.listStatuses.mockResolvedValue(
[],
);

await controller.listStatuses();
expect(
mockNoticeOfIntentSubmissionStatusService.listStatuses,
).toHaveBeenCalledTimes(1);
});

it('should call service to get statuses by file number', async () => {
const fakeFileNumber = 'fake';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { InjectMapper } from '@automapper/nestjs';
import { Controller, Get, Param } from '@nestjs/common';
import { ANY_AUTH_ROLE } from '../../../common/authorization/roles';
import { UserRoles } from '../../../common/authorization/roles.decorator';
import { NoticeOfIntentSubmissionToSubmissionStatusDto } from './notice-of-intent-status.dto';
import { NoticeOfIntentSubmissionStatusType } from './notice-of-intent-status-type.entity';
import {
NoticeOfIntentStatusDto,
NoticeOfIntentSubmissionToSubmissionStatusDto,
} from './notice-of-intent-status.dto';
import { NoticeOfIntentSubmissionToSubmissionStatus } from './notice-of-intent-status.entity';
import { NoticeOfIntentSubmissionStatusService } from './notice-of-intent-submission-status.service';

Expand All @@ -15,6 +19,18 @@ export class NoticeOfIntentSubmissionStatusController {
@InjectMapper() private mapper: Mapper,
) {}

@Get('')
async listStatuses() {
const statuses =
await this.noticeOfIntentSubmissionStatusService.listStatuses();

return this.mapper.mapArrayAsync(
statuses,
NoticeOfIntentSubmissionStatusType,
NoticeOfIntentStatusDto,
);
}

@Get('/:fileNumber')
async getStatusesByFileNumber(@Param('fileNumber') fileNumber) {
const statuses =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ describe('NoticeOfIntentSubmissionStatusService', () => {
expect(service).toBeDefined();
});

it('should load all statuses from the repo', async () => {
mockSubmissionStatusTypeRepository.find.mockResolvedValue([]);

await service.listStatuses();
expect(mockSubmissionStatusTypeRepository.find).toHaveBeenCalledTimes(1);
});

it('should successfully set initial statuses', async () => {
mockSubmissionStatusTypeRepository.find.mockResolvedValue([
new NoticeOfIntentSubmissionStatusType({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export class NoticeOfIntentSubmissionStatusService {
private noticeOfIntentSubmissionRepository: Repository<NoticeOfIntentSubmission>,
) {}

async listStatuses() {
return this.submissionStatusTypeRepository.find();
}

async setInitialStatuses(submissionUuid: string, persist = true) {
const statuses = await this.submissionStatusTypeRepository.find();
const newStatuses: NoticeOfIntentSubmissionToSubmissionStatus[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
import { UserRoles } from '../../common/authorization/roles.decorator';
import { formatIncomingDate } from '../../utils/incoming-date.formatter';
import { BoardService } from '../board/board.service';
import { NOTIFICATION_STATUS } from '../notification/notification-submission-status/notification-status.dto';
import { UpdateNotificationDto } from '../notification/notification.dto';
import { NOI_SUBMISSION_STATUS } from './notice-of-intent-submission-status/notice-of-intent-status.dto';
import { NoticeOfIntentSubmissionStatusService } from './notice-of-intent-submission-status/notice-of-intent-submission-status.service';
import { NoticeOfIntentSubtype } from './notice-of-intent-subtype.entity';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class NoticeOfIntentSubmissionDraftService {
noticeOfIntentSubmissionUuid: savedSubmission.uuid,
},
savedSubmission,
user,
);
ownerUuidMap.set(owner.uuid, savedOwner.uuid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class NoticeOfIntentOwnerController {
const owner = await this.ownerService.create(
createDto,
noticeOfIntentSubmission,
req.user.entity,
);

return this.mapper.mapAsync(
Expand Down Expand Up @@ -189,6 +190,7 @@ export class NoticeOfIntentOwnerController {
noticeOfIntentSubmissionUuid: data.noticeOfIntentSubmissionUuid,
},
applicationSubmission,
req.user.entity,
);
await this.ownerService.setPrimaryContact(
applicationSubmission.uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe('NoticeOfIntentOwnerService', () => {
typeCode: '',
},
new NoticeOfIntentSubmission(),
new User(),
);

expect(mockRepo.save).toHaveBeenCalledTimes(1);
Expand Down
Loading

0 comments on commit a48a784

Please sign in to comment.