Skip to content

Commit

Permalink
feat(cb2-15580): add ability to download VTP and VTG 12 documents for…
Browse files Browse the repository at this point in the history
… abandoned tests (#1693)

* feat(cb2-15580): add ability to download vtp and vtg 12 documents for abandoned tests

* feat(cb2-15580): use static test type ids as BE ids are wrong for now

* feat(cb2-15580): re-add cvs common package for vtg/vtp12 test type ids

---------

Co-authored-by: Thomas Evans <36958694+tomevs88@users.noreply.github.com>
  • Loading branch information
BrandonT95 and tomevs88 authored Dec 20, 2024
1 parent 280d6c2 commit 39ef0d9
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 11 deletions.
27 changes: 25 additions & 2 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ <h1 class="govuk-heading-l">
</div>

<!-- Recalls warning -->
<app-field-warning-message
*ngIf="(recalls | async)?.hasRecall"
<app-field-warning-message
*ngIf="(recalls | async)?.hasRecall"
warningMessage="This vehicle has an outstanding vehicle recall. Tell the presenter to contact their nearest dealership to arrange for a free repair.">
</app-field-warning-message>

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<h2 class="govuk-heading-m">Vehicle details</h2>
Expand Down Expand Up @@ -97,8 +97,8 @@ <h1 class="govuk-heading-l govuk-!-margin-bottom-2">
</div>

<!-- Recalls warning -->
<app-field-warning-message
*ngIf="(recalls | async)?.hasRecall"
<app-field-warning-message
*ngIf="(recalls | async)?.hasRecall"
warningMessage="This vehicle has an outstanding vehicle recall. Tell the presenter to contact their nearest dealership to arrange for a free repair.">
</app-field-warning-message>

Expand Down Expand Up @@ -212,6 +212,14 @@ <h3 class="govuk-heading-m">Vehicle overview</h3>
</app-test-certificate>
</dd>
</div>
<div *ngIf="shouldShowAbandonCert" class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ abandonCertDocName }} document</dt>
<dd id="test-vtg-vtp-document" class="govuk-summary-list__value">
<a class="link" appRetrieveDocument [params]="params" [fileName]="fileName">
Download
</a>
</dd>
</div>
</dl>
</ng-container>
</ng-container>
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'node_modules/govuk-frontend/govuk/all';

.test_result_header {
display: flex;
flex-flow: row wrap;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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<string, string> {
return new Map([['fileName', this.fileName]]);
}
}
4 changes: 4 additions & 0 deletions src/app/models/testTypeId.enum.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 39ef0d9

Please sign in to comment.