diff --git a/package-lock.json b/package-lock.json index 75373565ce..836f41298a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cvs-app-vtm", - "version": "1.29", + "version": "1.30", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cvs-app-vtm", - "version": "1.29", + "version": "1.30", "license": "MIT", "dependencies": { "@angular/animations": "^18.2.7", @@ -53,6 +53,7 @@ "@commitlint/config-conventional": "^18.6.2", "@compodoc/compodoc": "^1.1.23", "@dvsa/biome-config": "0.2.0", + "@dvsa/cvs-microservice-common": "1.3.1", "@ngrx/schematics": "^18.0.2", "@sentry/cli": "^2.32.2", "@types/jest": "^29.5.12", @@ -4488,6 +4489,16 @@ "dev": true, "license": "ISC" }, + "node_modules/@dvsa/cvs-microservice-common": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@dvsa/cvs-microservice-common/-/cvs-microservice-common-1.3.1.tgz", + "integrity": "sha512-dxXWTXd4hHzuJINv6kBzDTPLtk/iG+vj3EcU2d7Fo5PUtWRBOPU1gLVn1Pl5bMGOJ5sHYLnWkFMcoUv7UgBsoA==", + "dev": true, + "dependencies": { + "class-transformer": "^0.5.1", + "dayjs": "^1.11.13" + } + }, "node_modules/@dvsa/cvs-type-definitions": { "version": "7.8.0", "resolved": "https://registry.npmjs.org/@dvsa/cvs-type-definitions/-/cvs-type-definitions-7.8.0.tgz", @@ -9788,6 +9799,12 @@ "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==", "dev": true }, + "node_modules/class-transformer": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "dev": true + }, "node_modules/clean-css": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz", @@ -10823,6 +10840,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dayjs": { + "version": "1.11.13", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz", + "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==", + "dev": true + }, "node_modules/debug": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", diff --git a/package.json b/package.json index 9933ccf9b0..4b5ae9706f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cvs-app-vtm", - "version": "1.29", + "version": "1.30", "description": "DVSA CVS Vehicle Testing Management Application", "main": "index.js", "engines": { @@ -75,6 +75,7 @@ "@commitlint/config-conventional": "^18.6.2", "@compodoc/compodoc": "^1.1.23", "@dvsa/biome-config": "0.2.0", + "@dvsa/cvs-microservice-common": "1.3.1", "@ngrx/schematics": "^18.0.2", "@sentry/cli": "^2.32.2", "@types/jest": "^29.5.12", diff --git a/src/app/features/test-records/components/vehicle-header/__tests__/vehicle-header.component.spec.ts b/src/app/features/test-records/components/vehicle-header/__tests__/vehicle-header.component.spec.ts index d188089987..d59afa1d74 100644 --- a/src/app/features/test-records/components/vehicle-header/__tests__/vehicle-header.component.spec.ts +++ b/src/app/features/test-records/components/vehicle-header/__tests__/vehicle-header.component.spec.ts @@ -1,7 +1,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { TestType } from '@models/test-types/test-type.model'; +import { TestType, resultOfTestEnum } from '@models/test-types/test-type.model'; import { V3TechRecordModel, VehicleConfigurations, VehicleTypes } from '@models/vehicle-tech-record.model'; import { provideMockStore } from '@ngrx/store/testing'; import { HttpService } from '@services/http/http.service'; @@ -109,4 +109,20 @@ describe('VehicleHeaderComponent', () => { expect(component.isADRTest).toBe(false); }); }); + + describe('shouldShowAbandonCert', () => { + it('should return true if the VTG/VTP12 document should show', () => { + jest.spyOn(component, 'resultOfTest', 'get').mockReturnValue(resultOfTestEnum.abandoned); + jest.spyOn(component, 'test', 'get').mockReturnValue({ testTypeId: '3' } as TestType); + jest.spyOn(component, 'vehicleTypes', 'get').mockReturnValue('psv' as unknown as typeof VehicleTypes); + expect(component.shouldShowAbandonCert).toBe(true); + }); + + it('should return false if the VTG/VTP12 document should show', () => { + jest.spyOn(component, 'resultOfTest', 'get').mockReturnValue(resultOfTestEnum.abandoned); + jest.spyOn(component, 'test', 'get').mockReturnValue({ testTypeId: '193' } as TestType); + jest.spyOn(component, 'vehicleTypes', 'get').mockReturnValue('psv' as unknown as typeof VehicleTypes); + expect(component.shouldShowAbandonCert).toBe(false); + }); + }); }); diff --git a/src/app/features/test-records/components/vehicle-header/vehicle-header.component.html b/src/app/features/test-records/components/vehicle-header/vehicle-header.component.html index 2690ce269b..2d87c6bae8 100644 --- a/src/app/features/test-records/components/vehicle-header/vehicle-header.component.html +++ b/src/app/features/test-records/components/vehicle-header/vehicle-header.component.html @@ -21,11 +21,11 @@

- - +

Vehicle details

@@ -97,8 +97,8 @@

- @@ -212,6 +212,14 @@

Vehicle overview

+
+
{{ abandonCertDocName }} document
+
+ + Download + +
+
diff --git a/src/app/features/test-records/components/vehicle-header/vehicle-header.component.scss b/src/app/features/test-records/components/vehicle-header/vehicle-header.component.scss index 1f37ce1ee0..3b972e5cae 100644 --- a/src/app/features/test-records/components/vehicle-header/vehicle-header.component.scss +++ b/src/app/features/test-records/components/vehicle-header/vehicle-header.component.scss @@ -1,3 +1,5 @@ +@import 'node_modules/govuk-frontend/govuk/all'; + .test_result_header { display: flex; flex-flow: row wrap; @@ -62,6 +64,32 @@ padding: 10px 0; } +.text { + background-color: transparent; + border: none; + box-shadow: none; + font-family: GDS Transport, arial, sans-serif; + font-size: 19px; + font-weight: 400; + padding: 0; +} + +.link { + @extend .text; + color: $govuk-brand-colour; + text-decoration: underline; + text-decoration-thickness: max(1px, 0.0625rem); + text-underline-offset: 0.1em; + cursor: pointer; + + &:hover { + background-color: transparent; + color: govuk-colour('dark-blue', $legacy: 'light-blue'); + text-decoration: underline; + text-decoration-thickness: max(3px, 0.1875rem, 0.12em); + } +} + @media (min-width: 40.0625em) { .govuk-summary-list__row { display: flex; diff --git a/src/app/features/test-records/components/vehicle-header/vehicle-header.component.ts b/src/app/features/test-records/components/vehicle-header/vehicle-header.component.ts index de49aa7434..c8c2662c15 100644 --- a/src/app/features/test-records/components/vehicle-header/vehicle-header.component.ts +++ b/src/app/features/test-records/components/vehicle-header/vehicle-header.component.ts @@ -1,19 +1,19 @@ import { TestRecordsService } from '@/src/app/services/test-records/test-records.service'; import { ChangeDetectionStrategy, Component, Input, inject } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; +import { TagType, TagTypes } from '@components/tag/tag.component'; import { RecallsSchema } from '@dvsa/cvs-type-definitions/types/v1/recalls'; import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-vehicle-type'; import { ReferenceDataResourceType } from '@models/reference-data.model'; import { TestResultStatus } from '@models/test-results/test-result-status.enum'; import { TestResultModel } from '@models/test-results/test-result.model'; import { TestType, resultOfTestEnum } from '@models/test-types/test-type.model'; -import { TEST_TYPES_GROUP7 } from '@models/testTypeId.enum'; +import { TEST_TYPES_GROUP7, TEST_TYPES_VTP_VTG_12 } from '@models/testTypeId.enum'; import { V3TechRecordModel, VehicleTypes } from '@models/vehicle-tech-record.model'; import { Store } from '@ngrx/store'; import { techRecord } from '@store/technical-records'; import { selectAllTestTypes } from '@store/test-types/test-types.selectors'; import { Observable, map } from 'rxjs'; -import { TagType, TagTypes } from '../../../../components/tag/tag.component'; @Component({ selector: 'app-vehicle-header', @@ -118,4 +118,27 @@ export class VehicleHeaderComponent { get isADRTest(): boolean { return TEST_TYPES_GROUP7.includes(this.test?.testTypeId as string) || false; } + + get shouldShowAbandonCert() { + return ( + this.resultOfTest === resultOfTestEnum.abandoned && + (this.testResult?.vehicleType === this.vehicleTypes.HGV || + this.testResult?.vehicleType === this.vehicleTypes.PSV || + this.testResult?.vehicleType === this.vehicleTypes.TRL) && + TEST_TYPES_VTP_VTG_12.includes(this.test?.testTypeId as string) + ); + } + + get abandonCertDocName(): string { + return `VT${this.testResult?.vehicleType === this.vehicleTypes.PSV ? 'P' : 'G'}12`; + } + + get fileName(): string { + const prefix = this.abandonCertDocName; + return `${prefix}_${this.testNumber}`; + } + + get params(): Map { + return new Map([['fileName', this.fileName]]); + } } diff --git a/src/app/models/testTypeId.enum.ts b/src/app/models/testTypeId.enum.ts index ed32c23911..6059f2fed0 100644 --- a/src/app/models/testTypeId.enum.ts +++ b/src/app/models/testTypeId.enum.ts @@ -1,3 +1,4 @@ +import { VTG_VTP_12_TEST } from '@dvsa/cvs-microservice-common/classes/testTypes/Constants'; // Copied from the backend-lambda https://github.com/dvsa/cvs-svc-test-results/blob/3c1ffe344282b5ce918c151a56144b51cbd1c929/src/assets/Enums.ts#L219 // CVSB-10300 - the following constants are based on the grouping of the test-types in the excel @@ -224,6 +225,9 @@ export const TEST_TYPES_GROUP4_DESK_BASED_TEST: string[] = [ ]; export const TEST_TYPES_GROUP5_DESK_BASED_TEST: string[] = ['439', '441', '442', '449']; +// Test Type IDs that generate VTP12/VTG12 documentation on test abandonment +export const TEST_TYPES_VTP_VTG_12 = [...VTG_VTP_12_TEST.IDS]; + export const TEST_TYPES = { testTypesGroup1: TEST_TYPES_GROUP1, testTypesGroup2: TEST_TYPES_GROUP2,