Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CB2-14255): Error being thrown in cert-gen when TRL make is null #196

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/certificate/commands/MakeAndModelCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class MakeAndModelCommand extends BasePayloadCommand {
const isValidForTrn = this.testResultService.isValidForTrn(vehicleType, makeAndModel);
if (isValidForTrn) {
return await this.trailerRepository.getTrailerRegistrationObject(testResult.vin, makeAndModel.Make);
} else {
console.error('Vehicle is not valid for Trn.');
Daniel-Searle marked this conversation as resolved.
Show resolved Hide resolved
}

return undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/test-result/TestResultService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class TestResultService {
* @returns returns if the condition is satisfied else false
*/
public isValidForTrn(vehicleType: string, makeAndModel: IMakeAndModel): boolean {
return makeAndModel && vehicleType === VEHICLE_TYPES.TRL;
return makeAndModel && !!makeAndModel.Make && vehicleType === VEHICLE_TYPES.TRL;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/queue-event-fail.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"messageId": "g48c54a0-7027-4e37-b7e8-c8d231511c680",
"receiptHandle": "AQEBJcBvTRZ1W2LSaUJ0g0ELXlqA8WCL4zJxO63wu0YOVhx44xxxPhsnc+/Q9+1vOPYO+3HupEjXzGRSvfPY5rEEJkgCJe4/RQ+q2kU5LsmJEr1qE/CTdIYe5X/75XeMQ523KKpdNsD9tRhyvEpPpSu50byGbz7J0JyR6lu1E6Q4YuB4QNm+ev1obPMLdEt8RhgvIi/NfEfQf0L1r3TPi3wLho1R61PllPm27He8/1CjCnMyWBzgX+DCjJ7vyRXObMZ/MbhMBKbYpeTcejsKpYX//PPr1yvldp1YPC0wPKp+iqmWxoDDeHXbo8xYRFXDA8rnY5RfkwxxffH7o534vYn8FCZEtqybQuo7pumu6Ah9PsC05tP38syU71ltasljGIA35BgCdSO+9r5rTaBnbO9++Q==",
"body": "{\"testerStaffId\":\"1\",\"testStartTimestamp\":\"2019-02-26T14:50:44.279Z\",\"odometerReadingUnits\":\"kilometres\",\"testEndTimestamp\":\"2019-02-26T15:02:10.761Z\",\"testStatus\":\"submitted\",\"testTypes\":{\"testNumber\":\"W01A00310\",\"prohibitionIssued\":false,\"testCode\":\"ffv2\",\"lastUpdatedAt\":\"2019-02-26T15:29:39.537Z\",\"testAnniversaryDate\":\"2019-12-26T15:29:40.032Z\",\"numberOfSeatbeltsFitted\":2,\"testTypeEndTimestamp\":\"2019-02-26T15:02:37.392Z\",\"lastSeatbeltInstallationCheckDate\":\"2019-02-26\",\"createdAt\":\"2019-02-26T15:29:39.537Z\",\"testExpiryDate\":\"2020-02-25T15:29:40.032Z\",\"testTypeId\":\"1\",\"testTypeStartTimestamp\":\"2019-02-26T14:51:54.180Z\",\"certificateNumber\":\"321\",\"seatbeltInstallationCheckDate\":true,\"testTypeName\":\"Annual test\",\"defects\":[{\"deficiencyCategory\":\"dangerous\",\"deficiencyText\":\"not working correctly and obviously affects steering control.\",\"prs\":false,\"additionalInformation\":{\"notes\":\"Asdasd\",\"location\":{\"axleNumber\":7,\"horizontal\":\"inner\",\"lateral\":\"offside\"}},\"deficiencyRef\":\"54.1.a.ii\",\"itemNumber\":1,\"stdForProhibition\":false,\"deficiencySubId\":\"ii\",\"deficiencyId\":\"a\",\"imDescription\":\"Steering\",\"itemDescription\":\"Power steering:\",\"imNumber\":54},{\"deficiencyCategory\":\"minor\",\"deficiencyText\":\"reservoir is below minimum level.\",\"prs\":false,\"additionalInformation\":{\"location\":{\"axleNumber\":7,\"horizontal\":\"outer\",\"lateral\":\"nearside\"}},\"deficiencyRef\":\"54.1.d.i\",\"itemNumber\":1,\"stdForProhibition\":false,\"deficiencySubId\":\"i\",\"deficiencyId\":\"d\",\"imDescription\":\"Steering\",\"itemDescription\":\"Power steering:\",\"imNumber\":54},{\"deficiencyCategory\":\"advisory\",\"deficiencyText\":\"null\",\"prs\":false,\"additionalInformation\":{\"notes\":\"Dasdasdccc\",\"location\":{}},\"deficiencyRef\":\"5.1\",\"itemNumber\":1,\"stdForProhibition\":false,\"deficiencySubId\":null,\"deficiencyId\":null,\"imDescription\":\"Exhaust Emissions\",\"itemDescription\":\"Compression Ignition Engines Statutory Smoke Meter Test:\",\"imNumber\":5}],\"name\":\"Annual test\",\"testResult\":\"fail\"},\"vehicleClass\":{\"code\":\"t\",\"description\":\"trailer\"},\"testResultId\":\"1\",\"vehicleSize\":\"small\",\"vin\":\"T12876765\",\"testStationName\":\"Abshire-Kub\",\"vehicleId\":\"C456789\",\"countryOfRegistration\":\"gb\",\"vehicleType\":\"trl\",\"preparerId\":\"AK4434\",\"preparerName\":\"Durrell Vehicles Limited\",\"odometerReading\":12312,\"vehicleConfiguration\":\"rigid\",\"testStationType\":\"gvts\",\"testerName\":\"CVS Dev1\",\"vrm\":\"C456789\",\"testStationPNumber\":\"09-4129632\",\"numberOfSeats\":50,\"testerEmailAddress\":\"cvs.dev1@dvsagov.onmicrosoft.com\",\"euVehicleCategory\":\"m1\",\"order\":{\"current\":2,\"total\":2}}",
"body": "{\"testerStaffId\":\"1\",\"testStartTimestamp\":\"2019-02-26T14:50:44.279Z\",\"odometerReadingUnits\":\"kilometres\",\"testEndTimestamp\":\"2019-02-26T15:02:10.761Z\",\"testStatus\":\"submitted\",\"testTypes\":{\"testNumber\":\"W01A00310\",\"prohibitionIssued\":false,\"testCode\":\"ffv2\",\"lastUpdatedAt\":\"2019-02-26T15:29:39.537Z\",\"testAnniversaryDate\":\"2019-12-26T15:29:40.032Z\",\"numberOfSeatbeltsFitted\":2,\"testTypeEndTimestamp\":\"2019-02-26T15:02:37.392Z\",\"lastSeatbeltInstallationCheckDate\":\"2019-02-26\",\"createdAt\":\"2019-02-26T15:29:39.537Z\",\"testExpiryDate\":\"2020-02-25T15:29:40.032Z\",\"testTypeId\":\"1\",\"testTypeStartTimestamp\":\"2019-02-26T14:51:54.180Z\",\"certificateNumber\":\"321\",\"seatbeltInstallationCheckDate\":true,\"testTypeName\":\"Annual test\",\"defects\":[{\"deficiencyCategory\":\"dangerous\",\"deficiencyText\":\"not working correctly and obviously affects steering control.\",\"prs\":false,\"additionalInformation\":{\"notes\":\"Asdasd\",\"location\":{\"axleNumber\":7,\"horizontal\":\"inner\",\"lateral\":\"offside\"}},\"deficiencyRef\":\"54.1.a.ii\",\"itemNumber\":1,\"stdForProhibition\":false,\"deficiencySubId\":\"ii\",\"deficiencyId\":\"a\",\"imDescription\":\"Steering\",\"itemDescription\":\"Power steering:\",\"imNumber\":54},{\"deficiencyCategory\":\"minor\",\"deficiencyText\":\"reservoir is below minimum level.\",\"prs\":false,\"additionalInformation\":{\"location\":{\"axleNumber\":7,\"horizontal\":\"outer\",\"lateral\":\"nearside\"}},\"deficiencyRef\":\"54.1.d.i\",\"itemNumber\":1,\"stdForProhibition\":false,\"deficiencySubId\":\"i\",\"deficiencyId\":\"d\",\"imDescription\":\"Steering\",\"itemDescription\":\"Power steering:\",\"imNumber\":54},{\"deficiencyCategory\":\"advisory\",\"deficiencyText\":\"null\",\"prs\":false,\"additionalInformation\":{\"notes\":\"Dasdasdccc\",\"location\":{}},\"deficiencyRef\":\"5.1\",\"itemNumber\":1,\"stdForProhibition\":false,\"deficiencySubId\":null,\"deficiencyId\":null,\"imDescription\":\"Exhaust Emissions\",\"itemDescription\":\"Compression Ignition Engines Statutory Smoke Meter Test:\",\"imNumber\":5}],\"name\":\"Annual test\",\"testResult\":\"fail\"},\"vehicleClass\":{\"code\":\"t\",\"description\":\"trailer\"},\"testResultId\":\"1\",\"vehicleSize\":\"small\",\"vin\":\"T12876765\",\"testStationName\":\"Abshire-Kub\",\"vehicleId\":\"C456789\",\"countryOfRegistration\":\"gb\",\"vehicleType\":\"trl\",\"preparerId\":\"AK4434\",\"preparerName\":\"Durrell Vehicles Limited\",\"odometerReading\":12312,\"vehicleConfiguration\":\"rigid\",\"testStationType\":\"gvts\",\"testerName\":\"CVS Dev1\",\"vrm\":\"C456789\", \"make\": \"STANLEY\",\"testStationPNumber\":\"09-4129632\",\"numberOfSeats\":50,\"testerEmailAddress\":\"cvs.dev1@dvsagov.onmicrosoft.com\",\"euVehicleCategory\":\"m1\",\"order\":{\"current\":2,\"total\":2}}",
"messageAttributes": {},
"md5OfBody": "9586727cbc9f3312542387099b60982c",
"eventSource": "aws:sqs",
Expand Down
15 changes: 8 additions & 7 deletions tests/unit/certGen.unitTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6194,7 +6194,7 @@ describe("cert-gen", () => {
});

context("and lambda-to-lambda calls were unsuccessful", () => {
it("should return a VTG5A payload without bodyMake, bodyModel and odometer history", async () => {
it("should return a VTG5A payload without bodyModel and odometer history", async () => {
const expectedResult: any = {
Watermark: "NOT VALID",
DATA: {
Expand All @@ -6212,6 +6212,7 @@ describe("cert-gen", () => {
CountryOfRegistrationCode: "gb",
VehicleEuClassification: "M1",
RawVIN: "T12876765",
Make: "STANLEY",
ExpiryDate: "25.02.2020",
EarliestDateOfTheNextTest: "01.11.2019",
SeatBeltTested: "Yes",
Expand All @@ -6229,7 +6230,6 @@ describe("cert-gen", () => {
// @ts-ignore
delete techRecordResponseRwtMock.techRecord_model;
// @ts-ignore
delete techRecordResponseRwtMock.techRecord_make;
callGetTechRecordSpy.mockResolvedValue(techRecordResponseRwtMock as any);

// Make the functions return undefined
Expand Down Expand Up @@ -6555,7 +6555,7 @@ describe("cert-gen", () => {
});

context("and lambda-to-lambda calls were unsuccessful", () => {
it("should return a PRS payload without bodyMake, bodyModel and odometer history", async () => {
it("should return a PRS payload without, bodyModel and odometer history", async () => {
const expectedResult: any = {
Watermark: "NOT VALID",
DATA: {
Expand All @@ -6578,6 +6578,7 @@ describe("cert-gen", () => {
SeatBeltTested: "Yes",
SeatBeltPreviousCheckDate: "26.02.2019",
SeatBeltNumber: 2,
Make: "STANLEY",
},
FAIL_DATA: {
TestNumber: "W01A00310",
Expand All @@ -6600,6 +6601,7 @@ describe("cert-gen", () => {
SeatBeltPreviousCheckDate: "26.02.2019",
SeatBeltNumber: 2,
PRSDefects: ["1.1.a A registration plate: missing. Front."],
Make: "STANLEY"
},
Signature: {
ImageType: "png",
Expand All @@ -6611,8 +6613,6 @@ describe("cert-gen", () => {

const techRecordResponseRwtMock = cloneDeep(techRecordsRwt);
// @ts-ignore
delete techRecordResponseRwtMock.techRecord_make;
// @ts-ignore
delete techRecordResponseRwtMock.techRecord_model;
callGetTechRecordSpy.mockResolvedValue(techRecordResponseRwtMock as any);

Expand Down Expand Up @@ -6830,6 +6830,7 @@ describe("cert-gen", () => {
SeatBeltTested: "Yes",
SeatBeltPreviousCheckDate: "26.02.2019",
SeatBeltNumber: 2,
"Make": "STANLEY",
DangerousDefects: [
"54.1.a.ii Power steering: not working correctly and obviously affects steering control. Axles: 7. Inner Offside. Asdasd",
],
Expand All @@ -6850,7 +6851,7 @@ describe("cert-gen", () => {

const techRecordResponseRwtMock = cloneDeep(techRecordsRwt);
// @ts-ignore
delete techRecordResponseRwtMock.techRecord_make;
// delete techRecordResponseRwtMock.techRecord_make;
Daniel-Searle marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore
delete techRecordResponseRwtMock.techRecord_model;
callGetTechRecordSpy.mockResolvedValue(techRecordResponseRwtMock as any);
Expand Down Expand Up @@ -7315,7 +7316,7 @@ describe("cert-gen", () => {
"inspectionTypes": [
"normal",
"basic"
],
],
"prs": false,
"refCalculation": "1.1",
"requiredStandard": "The exhaust must be securely mounted",
Expand Down
Loading