Skip to content

Commit 6a9d846

Browse files
authored
2393 Property Intake QA Fixes (#2469)
* fix: addressed QA fixes in property component * chore: fix failing test * fix: removed auto save of property draft on refresh * chore: removed timeout
1 parent 489113a commit 6a9d846

File tree

3 files changed

+267
-51
lines changed

3 files changed

+267
-51
lines changed

alcs-frontend/src/app/features/compliance-and-enforcement/property/property.component.html

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@ <h3>Property</h3>
1515

1616
<div class="government-region-fields">
1717
<mat-form-field appearance="outline">
18-
<mat-label>Local or First Nation Government</mat-label>
19-
<mat-select formControlName="localGovernmentUuid" (selectionChange)="onLocalGovernmentChange($event)">
20-
<mat-option *ngFor="let lg of filteredLocalGovernments" [value]="lg.uuid">
18+
<mat-label>Local or First Nation Government*</mat-label>
19+
<input
20+
matInput
21+
type="text"
22+
[formControl]="localGovernmentControl"
23+
[matAutocomplete]="auto"
24+
placeholder="Type government name"
25+
(blur)="onLocalGovernmentBlur()"
26+
/>
27+
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="onLocalGovernmentChange($event)">
28+
<mat-option *ngFor="let lg of filteredLocalGovernments | async" [value]="lg.uuid">
2129
{{ lg.name }}
2230
</mat-option>
23-
</mat-select>
31+
</mat-autocomplete>
32+
<mat-error *ngIf="localGovernmentControl.hasError('required') && localGovernmentControl.touched">
33+
Local or First Nation Government is required
34+
</mat-error>
2435
</mat-form-field>
2536

2637
<mat-form-field appearance="outline">
@@ -37,17 +48,29 @@ <h3>Property</h3>
3748
<div class="coordinate-field">
3849
<mat-form-field appearance="outline">
3950
<mat-label>Latitude</mat-label>
40-
<input type="number" matInput formControlName="latitude" step="0.000001" />
51+
<input type="number" matInput formControlName="latitude" step="0.00001" placeholder="e.g. 49.55555" />
52+
<mat-error *ngIf="form.get('latitude')?.hasError('required')">Latitude is required</mat-error>
53+
<mat-error *ngIf="form.get('latitude')?.hasError('min')">Latitude must be at least 48</mat-error>
54+
<mat-error *ngIf="form.get('latitude')?.hasError('max')">Latitude must be at most 61</mat-error>
55+
<mat-error *ngIf="form.get('latitude')?.hasError('decimalPlaces')">
56+
Latitude must have exactly 5 decimal places (e.g. 49.55555)
57+
</mat-error>
4158
</mat-form-field>
4259
<div class="coordinate-help">Valid Range is 48 to 61. Example: 49.55555</div>
4360
</div>
4461

4562
<div class="coordinate-field">
4663
<mat-form-field appearance="outline">
4764
<mat-label>Longitude</mat-label>
48-
<input type="number" matInput formControlName="longitude" step="0.000001" />
65+
<input type="number" matInput formControlName="longitude" step="0.00001" placeholder="e.g. -130.55555" />
66+
<mat-error *ngIf="form.get('longitude')?.hasError('required')">Longitude is required</mat-error>
67+
<mat-error *ngIf="form.get('longitude')?.hasError('min')">Longitude must be at least -140</mat-error>
68+
<mat-error *ngIf="form.get('longitude')?.hasError('max')">Longitude must be at most -113</mat-error>
69+
<mat-error *ngIf="form.get('longitude')?.hasError('decimalPlaces')">
70+
Longitude must have exactly 5 decimal places (e.g. -130.55555)
71+
</mat-error>
4972
</mat-form-field>
50-
<div class="coordinate-help">Valid Range is -140 to -113. Example: -153.44444</div>
73+
<div class="coordinate-help">Valid Range is -140 to -113. Example: -130.55555</div>
5174
</div>
5275
</div>
5376

@@ -84,12 +107,12 @@ <h3>Property</h3>
84107
<div class="area-fields">
85108
<mat-form-field appearance="outline">
86109
<mat-label>Area (ha)</mat-label>
87-
<input type="number" matInput formControlName="areaHectares" step="0.01" min="0" />
110+
<input type="number" matInput formControlName="areaHectares" step="0.01" min="0" placeholder="e.g. 10.50" />
88111
</mat-form-field>
89112

90113
<mat-form-field appearance="outline">
91114
<mat-label>% within ALR</mat-label>
92-
<input type="number" matInput formControlName="alrPercentage" step="0.1" min="0" max="100" />
115+
<input type="number" matInput formControlName="alrPercentage" step="0.1" min="0" max="100" placeholder="e.g. 75.5" />
93116
<span matTextSuffix>%</span>
94117
</mat-form-field>
95118
</div>

alcs-frontend/src/app/features/compliance-and-enforcement/property/property.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
3+
import { MatAutocompleteModule } from '@angular/material/autocomplete';
34
import { MatButtonToggleModule } from '@angular/material/button-toggle';
45
import { MatFormFieldModule } from '@angular/material/form-field';
56
import { MatInputModule } from '@angular/material/input';
67
import { MatSelectModule } from '@angular/material/select';
78
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
89
import { HttpClientTestingModule } from '@angular/common/http/testing';
910
import { createMock, DeepMocked } from '@golevelup/ts-jest';
11+
import { BehaviorSubject } from 'rxjs';
1012
import { ApplicationLocalGovernmentService } from '../../../services/application/application-local-government/application-local-government.service';
13+
import { ApplicationService } from '../../../services/application/application.service';
14+
import { ApplicationRegionDto } from '../../../services/application/application-code.dto';
1115
import { PropertyComponent } from './property.component';
1216

1317
describe('PropertyComponent', () => {
1418
let component: PropertyComponent;
1519
let fixture: ComponentFixture<PropertyComponent>;
1620
let mockLocalGovernmentService: DeepMocked<ApplicationLocalGovernmentService>;
21+
let mockApplicationService: DeepMocked<ApplicationService>;
1722

1823
beforeEach(async () => {
1924
mockLocalGovernmentService = createMock();
2025
mockLocalGovernmentService.list.mockResolvedValue([]);
26+
mockApplicationService = createMock();
27+
mockApplicationService.$applicationRegions = new BehaviorSubject<ApplicationRegionDto[]>([]);
2128

2229
await TestBed.configureTestingModule({
2330
declarations: [PropertyComponent],
@@ -27,11 +34,13 @@ describe('PropertyComponent', () => {
2734
MatInputModule,
2835
MatSelectModule,
2936
MatButtonToggleModule,
37+
MatAutocompleteModule,
3038
NoopAnimationsModule,
3139
HttpClientTestingModule,
3240
],
3341
providers: [
3442
{ provide: ApplicationLocalGovernmentService, useValue: mockLocalGovernmentService },
43+
{ provide: ApplicationService, useValue: mockApplicationService },
3544
],
3645
}).compileComponents();
3746

0 commit comments

Comments
 (0)