Skip to content

Commit

Permalink
feat(RELEASE-123): merge holding branch back into develop (#1490)
Browse files Browse the repository at this point in the history
* feat(cb2-10241): update adr notes to use custom component (#1446)

* feat/CB2-11250 - Edit button on additional examiner notes takes you to blank page (#1447)

* feat(cb2-10241): update adr notes to use custom component

* feat(cb2-11250): format table

* feat(cb2-11250): set up router link

* feat(cb2-11250): blank page link working

* feat(cb2-11250): revert unnecessary changes

* feat(cb2-11250): amend routing function

* feat(cb2-11250): fix linting and add unit test

* feat(cb2-11250): fix linting and add unit test

* feat(cb2-11250): update link design

* feat(cb2-11250): fix button link styling

---------

Co-authored-by: Brandon Thomas-Davies <87308252+BrandonT95@users.noreply.github.com>

* feat(CB2-9916): Add warning to cherished transfer (#1451)

* feat(cb2-9916): added cherised transfer warning message for psv and hgv

* feat(cb2-9916): fix linting

* feat(cb2-10032): add pagination to adr examiner notes (#1450)

* feat(cb2-10032): add pagination to adr examiner notes

* feat(cb2-10032): add pagination to notes amend view

* feat(cb2-11103): createdAtDate for adr examiner notes now save as full iso date string (#1452)

* feat(cb2-11103): ability to submit and show date and time for adr notes creation

* feat(cb2-11103): fix unit test

* feat(cb2-11103): fix other unit test

* feat/CB2-10033 - Additional Examiner Note (#1448)

* feat(cb2-10241): update adr notes to use custom component

* feat(cb2-11250): format table

* feat(cb2-11250): set up router link

* feat(cb2-11250): blank page link working

* feat(cb2-11250): revert unnecessary changes

* feat(cb2-11250): amend routing function

* feat(cb2-11250): fix linting and add unit test

* feat(cb2-11250): fix linting and add unit test

* feat(cb2-11250): update link design

* feat(cb2-11250): fix button link styling

* feat(cb2-10033): basic setup and grabbed selected note from record

* feat(cb2-10033): stash for mobbing

* feat(cb2-10033): hook form up to display note which is to be edited

* feat(cb2-10033): set up model binding to component

* feat(cb2-10033): use correct directive and basic form validation

* feat(cb2-10033): amend routing title for notifiable alteration

* feat(cb2-10033): remove validation as requirements confirmed not needed

* feat(cb2-10033): implement state management solution

* feat(cb2-10033): fix display for summary screen

* feat(cb2-10033): refactor state and data handling approach

* feat(cb2-10033): reducer tests

* feat(cb2-10033): basic unit testing draft

* feat(cb2-10033): unit testing

* feat(cb2-10033): linting fix

* feat(cb2-10033): fix review screen

* feat(cb2-10033): git stash for mobbing

* feat(cb2-10033): add logic to hide collapse function and fix missing acs

* feat(cb2-10033): move title from component to templates

* feat(cb2-10033): acordion issues solved

---------

Co-authored-by: Brandon Thomas-Davies <87308252+BrandonT95@users.noreply.github.com>
Co-authored-by: Tom Evans <thomas.evans@dvsa.gov.uk>
Co-authored-by: Thomas Evans <36958694+tomevs88@users.noreply.github.com>

* feat(cb2-10033): upped char count to 151 (#1453)

Co-authored-by: Tom Evans <thomas.evans@dvsa.gov.uk>

* feat(cb2-10033): upped char count to 150

* feat(cb2-10033): upped char count to 150

* feat(cb2-10033): upped char count to 15 again

* feat(cb2-10033): css removed

* fix(cb2-11103): re-add missing timestamp from adr notes view (#1460)

* feat(cb2-10286): add hint text to 3 month extension (#1462)

* feat(cb2-10973): feature flags changed to show IVA flow in all envs (#1465)

Co-authored-by: Tom Evans <thomas.evans@dvsa.gov.uk>

* feat(cb2-10125): make adr guidance notes a checkbox group (#1466)

* feat(cb2-11546): make 'make' required for HGVs and TRLs which carry dangerous goods (#1461)

* fix(cb2-11546): make vehicle make required when carrying dangerous goods

* feat(cb2-11546): only make applicable for HGVs and LGVs

* feat(cb2-10286): add new certificate required field (#1463)

* feat(cb2-10286): add new certificate required field

* feat(cb2-9747): default checkbox to false so it will correctly display no text in read mode

* feat/CB2-10740 - Mark if a vehicle is used for international journeys on VTM (#1467)

* feat(cb2-10740): hook up template and values correctly to type definition

* feat(cb2-10740): lint fix

---------

Co-authored-by: pbardy2000 <146740183+pbardy2000@users.noreply.github.com>

* fix(cb2-9747): fix failing unit test (#1468)

* fix(cb2-9747): create mocked date to fix failing unit test (#1469)

* feat(cb2-11185): ensure correct text-wrapping. (#1473)

* fix(cb2-11185): break text to avoid long strings causing the page to overflow horizontally

* fix(cb2-11185): break long strings to overflow, but not mid-word unless necessary

* fix(cb2-11185): fix linting

* fix(cb2-10419): change casing in select defect (#1474)

* fix(cb2-11302): correct spelling of accessor to assessor (#1475)

* fix(cb2-10562): prevent submitting a psv with one axle (#1480)

* fix(cb2-11069): reset error message when new data is provided (#1479)

* fix(cb2-11068): allow unset as form node width so it never hides option text (#1478)

* fix(CB2-11243): prevent SR field in tyres component being cut-off on large screens (#1477)

* fix(cb2-11068): allow unset as form node width so it never hides option text

* fix(cb2-11243): set width to unset to select autoscales to text

* fix(CB2-11453): prevent download .zip file in seperate window (as this may be blocked) (#1476)

* fix(cb2-11453): do not download link via external tab

* fix(cb2-11453): fix unit test

* feat(cb2-11930): ensure certificate number is sent to backend if it exists on MVSA IVA tests (#1482)

* feat(cb2-11930): ensure certificate number is sent to backend if its exists on MVSA IVA tests

* feat(cb2-11930): fix linting issue

* fix(cb2-11908): remove duplicate label from additional examiner notes history (#1483)

* feat(cb2-12056): test codes moved (#1487)

Co-authored-by: Tom Evans <thomas.evans@dvsa.gov.uk>

---------

Co-authored-by: Thomas Crawley <thomas.crawley@dvsa.gov.uk>
Co-authored-by: Tom Evans <thomas.evans@dvsa.gov.uk>
Co-authored-by: Thomas Evans <36958694+tomevs88@users.noreply.github.com>
Co-authored-by: pbardy2000 <146740183+pbardy2000@users.noreply.github.com>
  • Loading branch information
5 people authored May 8, 2024
1 parent 59655f3 commit df1c0ae
Show file tree
Hide file tree
Showing 57 changed files with 1,143 additions and 388 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@angular/router": "^17.2.1",
"@azure/msal-angular": "^3.0.13",
"@azure/msal-browser": "^3.10.0",
"@dvsa/cvs-type-definitions": "^6.1.0",
"@dvsa/cvs-type-definitions": "^6.3.0",
"@ngrx/effects": "^17.1.0",
"@ngrx/entity": "^17.1.0",
"@ngrx/router-store": "^17.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<div *ngIf="techRecord">
<app-field-warning-message
*ngIf="showWarning"
[warningMessage]="
'Cherished transfers will update the VRM on the most recent test record for HGVs and PSVs, where an annual test certificate has been generated'
"
></app-field-warning-message>
<h2 class="govuk-heading-l">{{ makeAndModel }}</h2>

<dl class="govuk-summary-list">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
ComponentFixture, fakeAsync, TestBed,
} from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { ActivatedRoute, ActivatedRouteSnapshot, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
Expand Down Expand Up @@ -31,6 +29,7 @@ const mockTechRecordService = {
validateVrmDoesNotExist: jest.fn(),
validateVrmForCherishedTransfer: jest.fn(),
checkVrmNotActive: jest.fn(),
getVehicleTypeWithSmallTrl: jest.fn(),
};

const mockDynamicFormService = {
Expand Down Expand Up @@ -170,4 +169,34 @@ describe('TechRecordChangeVrmComponent', () => {
);
});
});

describe('showWarning', () => {
it('should return true if the vehicle type is a psv', () => {
component.techRecord = { techRecord_vehicleType: 'psv' } as VehiclesOtherThan<'trl'>;
mockTechRecordService.getVehicleTypeWithSmallTrl.mockReturnValue('psv');

expect(component.showWarning).toBe(true);
});

it('should return true if the vehicle type is a hgv', () => {
component.techRecord = { techRecord_vehicleType: 'hgv' } as VehiclesOtherThan<'trl'>;
mockTechRecordService.getVehicleTypeWithSmallTrl.mockReturnValue('hgv');

expect(component.showWarning).toBe(true);
});

it('should return false if the vehicle type is not a psv or hgv', () => {
component.techRecord = { techRecord_vehicleType: 'lgv' } as VehiclesOtherThan<'trl'>;
mockTechRecordService.getVehicleTypeWithSmallTrl.mockReturnValue('lgv');

expect(component.showWarning).toBe(false);
});

it('should default to false if the vehicle type is not present', () => {
component.techRecord = undefined;
mockTechRecordService.getVehicleTypeWithSmallTrl.mockReturnValue(undefined);

expect(component.showWarning).toBe(false);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,11 @@ export class AmendVrmComponent implements OnDestroy, OnInit {
}
return true;
}

get showWarning(): boolean {
if (this.vehicleType) {
return this.vehicleType === 'psv' || this.vehicleType === 'hgv';
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div *ngIf="currentTechRecord">
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<dl class="govuk-summary-list">
<h1 class="govuk-heading-l">Edit Additional Examiner Note</h1>
<div class="parent-div">
<td class="govuk-heading-s">Date</td>
<td class="table-value">{{ examinerNoteObj.createdAtDate | date: 'dd/MM/yyyy' | defaultNullOrEmpty }}</td>
<td class="govuk-heading-s">Created by</td>
<td class="table-value">{{ examinerNoteObj.lastUpdatedBy }}</td>
</div>
<div class="govuk-summary-list__row">
<form [formGroup]="form">
<app-text-area
#examinerNote
formControlName="additionalExaminerNote"
name="AdditionalExaminerNote"
[width]="width.L"
(ngModelChange)="ngOnChanges(examinerNote.value)"
>
</app-text-area>
</form>
</div>
</dl>
</div>
</div>
<app-button-group>
<app-button id="submit-examiner-note" (clicked)="handleSubmit()">Save</app-button>
<app-button id="cancel-amend-examiner-note" design="link" data-module="govuk-button" (clicked)="navigateBack()">Cancel</app-button>
</app-button-group>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.parent-div {
display: flex;
flex-direction: row;
}
.table-value {
margin-left: 1%;
margin-right: 1%;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DynamicFormsModule } from '@forms/dynamic-forms.module';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { TechnicalRecordService } from '@services/technical-record/technical-record.service';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { initialAppState } from '@store/index';
import { ActivatedRoute, Router } from '@angular/router';
import { of } from 'rxjs';
import { GlobalErrorService } from '@core/components/global-error/global-error.service';
import { TechRecordEditAdditionalExaminerNoteComponent } from './tech-record-edit-additional-examiner-note.component';

const mockTechRecordService = {
techRecord$: jest.fn(),
};
describe('TechRecordEditAdditionalExaminerNoteComponent', () => {
let fixture: ComponentFixture<TechRecordEditAdditionalExaminerNoteComponent>;
let component: TechRecordEditAdditionalExaminerNoteComponent;
let router: Router;
let errorService: GlobalErrorService;
let route: ActivatedRoute;
let store: MockStore;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TechRecordEditAdditionalExaminerNoteComponent],
imports: [DynamicFormsModule, FormsModule, ReactiveFormsModule, RouterTestingModule],
providers: [
{ provide: TechnicalRecordService, useValue: mockTechRecordService },
provideMockStore({ initialState: initialAppState }),
{ provide: ActivatedRoute, useValue: { params: of([{ id: 1 }]) } },
],
}).compileComponents();
fixture = TestBed.createComponent(TechRecordEditAdditionalExaminerNoteComponent);
component = fixture.componentInstance;
router = TestBed.inject(Router);
errorService = TestBed.inject(GlobalErrorService);
route = TestBed.inject(ActivatedRoute);
store = TestBed.inject(MockStore);
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('ngOnInit', () => {
it('should call all initialisation functions', () => {
const examinerNoteSpy = jest.spyOn(component, 'getExaminerNote').mockReturnValue();
const techRecordSpy = jest.spyOn(component, 'getTechRecord').mockReturnValue();
const formSpy = jest.spyOn(component, 'setupForm').mockReturnValue();
component.ngOnInit();
expect(examinerNoteSpy).toHaveBeenCalled();
expect(formSpy).toHaveBeenCalled();
expect(techRecordSpy).toHaveBeenCalled();
});
});
describe('navigateBack', () => {
it('should clear all errors', () => {
jest.spyOn(router, 'navigate').mockImplementation();

const clearErrorsSpy = jest.spyOn(errorService, 'clearErrors');

component.navigateBack();

expect(clearErrorsSpy).toHaveBeenCalledTimes(1);
});

it('should navigate back to the previous page', () => {
const navigateSpy = jest.spyOn(router, 'navigate').mockImplementation(() => Promise.resolve(true));

component.navigateBack();

expect(navigateSpy).toHaveBeenCalledWith(['../../'], { relativeTo: route });
});
});
describe('handleSubmit', () => {
it('should not dispatch an action if the notes are the same', () => {
const storeSpy = jest.spyOn(store, 'dispatch');
const navigateBackSpy = jest.spyOn(component, 'navigateBack').mockReturnValue();
component.originalExaminerNote = 'foobar';
component.editedExaminerNote = 'foobar';
component.handleSubmit();
expect(storeSpy).not.toHaveBeenCalled();
expect(navigateBackSpy).toHaveBeenCalled();
});

it('should dispatch an action if the notes are not the same', () => {
const storeSpy = jest.spyOn(store, 'dispatch');
const navigateBackSpy = jest.spyOn(component, 'navigateBack').mockReturnValue();
component.originalExaminerNote = 'foo';
component.editedExaminerNote = 'bar';
component.handleSubmit();
expect(storeSpy).toHaveBeenCalled();
expect(navigateBackSpy).toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { TechnicalRecordService } from '@services/technical-record/technical-record.service';
import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-vehicle-type';
import { ReplaySubject, take, takeUntil } from 'rxjs';
import { GlobalErrorService } from '@core/components/global-error/global-error.service';
import {
CustomFormControl,
FormNodeEditTypes,
FormNodeTypes,
FormNodeWidth,
} from '@forms/services/dynamic-form.types';
import { FormGroup, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { State } from '@store/index';
import { updateExistingADRAdditionalExaminerNote } from '@store/technical-records';
import { AdditionalExaminerNotes } from '@dvsa/cvs-type-definitions/types/v3/tech-record/get/hgv/complete';

@Component({
selector: 'tech-record-edit-additional-examiner-note',
templateUrl: './tech-record-edit-additional-examiner-note.component.html',
styleUrls: ['./tech-record-edit-additional-examiner-note.component.scss'],
})
export class TechRecordEditAdditionalExaminerNoteComponent implements OnInit {
currentTechRecord!: TechRecordType<'hgv' | 'trl' | 'lgv'>;
examinerNoteIndex!: number;
editedExaminerNote: string = '';
originalExaminerNote: string = '';
examinerNoteObj!: AdditionalExaminerNotes;
destroy$ = new ReplaySubject<boolean>(1);
form!: FormGroup;
formControl!: CustomFormControl;

constructor(
private router: Router,
private route: ActivatedRoute,
private technicalRecordService: TechnicalRecordService,
private globalErrorService: GlobalErrorService,
private store: Store<State>,
) { }

ngOnInit() {
this.getTechRecord();
this.getExaminerNote();
this.setupForm();
}

getTechRecord() {
this.technicalRecordService.techRecord$.pipe(takeUntil(this.destroy$)).subscribe((currentTechRecord) => {
this.currentTechRecord = currentTechRecord as TechRecordType<'hgv' | 'lgv' | 'trl'>;
});
}

getExaminerNote() {
this.route.params.pipe(take(1)).subscribe((params) => {
this.examinerNoteIndex = params['examinerNoteIndex'];
});
const additionalExaminerNotes = this.currentTechRecord?.techRecord_adrDetails_additionalExaminerNotes;
if (additionalExaminerNotes) {
const examinerNote = additionalExaminerNotes[this.examinerNoteIndex].note;
if (examinerNote) {
this.examinerNoteObj = additionalExaminerNotes[this.examinerNoteIndex];
this.originalExaminerNote = examinerNote;
this.editedExaminerNote = examinerNote;
}
}
}

setupForm() {
this.formControl = new CustomFormControl({
name: 'additionalExaminerNote', type: FormNodeTypes.CONTROL,
}, '', [Validators.required]);
this.form = new FormGroup({
additionalExaminerNote: this.formControl,
});
this.formControl.patchValue(this.editedExaminerNote);
}

navigateBack() {
this.globalErrorService.clearErrors();
void this.router.navigate(['../../'], { relativeTo: this.route });
}

handleSubmit(): void {
if (this.originalExaminerNote !== this.editedExaminerNote) {
this.store.dispatch(
updateExistingADRAdditionalExaminerNote({
examinerNoteIndex: this.examinerNoteIndex,
additionalExaminerNote: this.editedExaminerNote,
}),
);
}
this.navigateBack();
}

ngOnChanges(examinerNote: string) {
this.editedExaminerNote = examinerNote;
}

get editTypes(): typeof FormNodeEditTypes {
return FormNodeEditTypes;
}

get width(): typeof FormNodeWidth {
return FormNodeWidth;
}

}
Loading

0 comments on commit df1c0ae

Please sign in to comment.