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-11930): force cert number to be set on amended specialist tests #405

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions src/handlers/VehicleTestController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export class VehicleTestController implements IVehicleTestController {
}
// map testTypes back after validation
payload.testTypes = testTypes;
payload.testTypes.forEach(x=>{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would probably be better to do. this for loop above where the assigning payload.testTypes to testTypes to keep all of the processing together

if(VehicleTestController.isSpecialistTestWithoutCertificateNumber(x)
&& x.testResult !== enums.TEST_RESULT.ABANDONED){
x.certificateNumber = x.testNumber;
}
})

newTestResult = await this.mapOldTestResultToNew(
systemNumber,
Expand Down
31 changes: 31 additions & 0 deletions tests/unit/updateTestResults.unitTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,37 @@ describe('updateTestResults', () => {
});
});

context('A failed IVA Test Record with required standards', () => {
it('has its certifcate number set to the test number', async () => {
setupTestTypes((x) => {
x.testTypeId = '125';
x.requiredStandards = [
{
sectionNumber: '01',
sectionDescription: 'Noise',
rsNumber: 1,
requiredStandard: 'This is the new required standard on the test',
refCalculation: '1.1',
additionalInfo: true,
inspectionTypes: ['basic', 'normal'],
prs: false,
},
];
x.testTypeClassification = 'IVA With Certificate';
x.testCode = 'cel';
x.testNumber = 'testNumber';
return x;
});

const returnedRecord = await testResultsService.updateTestResult(
testToUpdate.systemNumber,
testToUpdate,
msUserDetails,
);
expect(returnedRecord.testTypes[0].certificateNumber).toBe('testNumber');
});
});

context('A failed IVA Test Record without required standards', () => {
it('cannot be updated without required standards present', async () => {
setupTestTypes((x) => delete x.requiredStandards);
Expand Down
Loading