Skip to content

Commit

Permalink
feat(cb2-13331): add smoke test k limit validation for decimals (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonT95 authored Oct 10, 2024
1 parent 3d8a0d0 commit 3541e59
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "cvs-app-vtm",
"version": "1.26",
"version": "1.27",
"description": "DVSA CVS Vehicle Testing Management Application",
"main": "index.js",
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ export const DeskBasedEmissionsSection: FormNode = {
name: 'smokeTestKLimitApplied',
label: 'Smoke test K limit applied',
type: FormNodeTypes.CONTROL,
validators: [{ name: ValidatorNames.MaxLength, args: 100 }],
editType: FormNodeEditTypes.NUMBER,
validators: [
{ name: ValidatorNames.Max, args: 9.999 },
{
name: ValidatorNames.CustomPattern,
args: ['^\\d*(\\.\\d{0,3})?$', 'must be less than or equal to 9.999'],
},
],
enableDecimals: true,
required: true,
value: null,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ export const EmissionsSection: FormNode = {
name: 'smokeTestKLimitApplied',
label: 'Smoke test K limit applied',
type: FormNodeTypes.CONTROL,
validators: [{ name: ValidatorNames.MaxLength, args: 100 }],
editType: FormNodeEditTypes.NUMBER,
validators: [
{ name: ValidatorNames.Max, args: 9.999 },
{
name: ValidatorNames.CustomPattern,
args: ['^\\d*(\\.\\d{0,3})?$', 'must be less than or equal to 9.999'],
},
],
asyncValidators: [
{ name: AsyncValidatorNames.RequiredIfNotResult, args: { testResult: ['fail', 'abandoned'] } },
],
enableDecimals: true,
required: true,
value: null,
},
Expand Down
10 changes: 10 additions & 0 deletions src/app/store/test-records/test-records.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { TypeOfTest } from '@models/test-results/typeOfTest.enum';
import { resultOfTestEnum } from '@models/test-types/test-type.model';
import {
TEST_TYPES_GROUP1_SPEC_TEST,
TEST_TYPES_GROUP2_DESK_BASED_TEST,
TEST_TYPES_GROUP5_SPEC_TEST,
TEST_TYPES_GROUP9_10_CENTRAL_DOCS,
TEST_TYPES_GROUP15_16,
} from '@models/testTypeId.enum';
import { EntityAdapter, EntityState, createEntityAdapter } from '@ngrx/entity';
import { createFeatureSelector, createReducer, on } from '@ngrx/store';
Expand Down Expand Up @@ -208,6 +210,14 @@ function cleanTestResultPayload(testResult: TestResultModel | undefined) {
testType.certificateNumber = '';
}

if (
(TEST_TYPES_GROUP2_DESK_BASED_TEST.includes(testType.testTypeId) ||
TEST_TYPES_GROUP15_16.includes(testType.testTypeId)) &&
testType.smokeTestKLimitApplied
) {
testType.smokeTestKLimitApplied = testType.smokeTestKLimitApplied.toString();
}

return testType;
});

Expand Down

0 comments on commit 3541e59

Please sign in to comment.