diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/index.ts b/services/ui-src/src/measures/2023/shared/globalValidations/index.ts index 3381a22ba8..1f94abfdbe 100644 --- a/services/ui-src/src/measures/2023/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2023/shared/globalValidations/index.ts @@ -13,7 +13,7 @@ export * from "shared/globalValidations/validateDateRangeRadioButtonCompletion"; export * from "./validateDualPopInformation"; export * from "./validateEqualCategoryDenominators"; export * from "shared/globalValidations/validateEqualQualifierDenominators"; -export * from "./validateFfsRadioButtonCompletion"; +export * from "shared/globalValidations/validateFfsRadioButtonCompletion"; export * from "./validateRateNotZero"; export * from "./validateRateZero"; export * from "shared/globalValidations/validateNumeratorsLessThanDenominators"; diff --git a/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx b/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx index b96fbd0309..15017a7f65 100644 --- a/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2023/shared/util/validationsMock.tsx @@ -8,7 +8,7 @@ import * as validateBothDatesInRange from "shared/globalValidations/validateBoth import * as validateDualPopInformation from "measures/2023/shared/globalValidations/validateDualPopInformation"; import * as validateEqualCategoryDenominators from "measures/2023/shared/globalValidations/validateEqualCategoryDenominators"; import * as validateEqualQualifierDenominators from "shared/globalValidations/validateEqualQualifierDenominators"; -import * as validateFfsRadioButtonCompletion from "measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion"; +import * as validateFfsRadioButtonCompletion from "shared/globalValidations/validateFfsRadioButtonCompletion"; import * as validateRateNotZero from "measures/2023/shared/globalValidations/validateRateNotZero"; import * as validateRateZero from "measures/2023/shared/globalValidations/validateRateZero"; import * as validateNumeratorsLessThanDenominators from "shared/globalValidations/validateNumeratorsLessThanDenominators"; diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/index.ts b/services/ui-src/src/measures/2024/shared/globalValidations/index.ts index 9ebc576fec..36cc92039c 100644 --- a/services/ui-src/src/measures/2024/shared/globalValidations/index.ts +++ b/services/ui-src/src/measures/2024/shared/globalValidations/index.ts @@ -14,7 +14,7 @@ export * from "shared/globalValidations/validateDateRangeRadioButtonCompletion"; export * from "./validateDualPopInformation"; export * from "./validateEqualCategoryDenominators"; export * from "shared/globalValidations/validateEqualQualifierDenominators"; -export * from "./validateFfsRadioButtonCompletion"; +export * from "shared/globalValidations/validateFfsRadioButtonCompletion"; export * from "./validateRateNotZero"; export * from "./validateRateZero"; export * from "shared/globalValidations/validateNumeratorsLessThanDenominators"; diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts b/services/ui-src/src/measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts deleted file mode 100644 index bbad461994..0000000000 --- a/services/ui-src/src/measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { testFormData } from "../testHelpers/_testFormData"; -import * as DC from "dataConstants"; -import { validateFfsRadioButtonCompletion } from "."; - -describe("validateFfsRadioButtonCompletion", () => { - let formData: any; - let errorArray: FormError[]; - - const _check_errors = (data: any, numErrors: number) => { - errorArray = [...validateFfsRadioButtonCompletion(data)]; - expect(errorArray.length).toBe(numErrors); - }; - - beforeEach(() => { - formData = JSON.parse(JSON.stringify(testFormData)); // reset data - errorArray = []; - }); - - it("When no Delivery System nested question is checked a validation warning shows", () => { - formData[DC.DELIVERY_SYS_REPRESENTATION_DENOMINATOR] = [DC.FFS]; - formData[DC.DELIVERY_SYS_FFS] = undefined; - _check_errors(formData, 1); - }); - - it("When a Delivery System nested question is checked no validation warning shows", () => { - formData[DC.DELIVERY_SYS_REPRESENTATION_DENOMINATOR] = [DC.FFS]; - formData[DC.DELIVERY_SYS_FFS] = "yes"; - _check_errors(formData, 0); - }); - - it("Error message text should match default errorMessage", () => { - formData[DC.DELIVERY_SYS_REPRESENTATION_DENOMINATOR] = [DC.FFS]; - formData[DC.DELIVERY_SYS_FFS] = undefined; - errorArray = [...validateFfsRadioButtonCompletion(formData)]; - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe( - "You must indicate if the measure-eligible population is included" - ); - }); - - it("Error message text should match provided errorMessage", () => { - formData[DC.DELIVERY_SYS_REPRESENTATION_DENOMINATOR] = [DC.FFS]; - formData[DC.DELIVERY_SYS_FFS] = undefined; - const errorMessage = "Another one bites the dust."; - errorArray = [...validateFfsRadioButtonCompletion(formData, errorMessage)]; - expect(errorArray.length).toBe(1); - expect(errorArray[0].errorMessage).toBe(errorMessage); - }); -}); diff --git a/services/ui-src/src/measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts b/services/ui-src/src/measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts deleted file mode 100644 index a656576fdb..0000000000 --- a/services/ui-src/src/measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import * as Types from "shared/types"; -import * as DC from "dataConstants"; - -export const validateFfsRadioButtonCompletion = ( - data: Types.DefinitionOfPopulation, - errorMessage?: string -) => { - const errorArray: FormError[] = []; - - // map the delivery systems to their respective nested selections - const deliverySystemsMap = { - [DC.FFS]: DC.DELIVERY_SYS_FFS, - [DC.ICM]: DC.DELIVERY_SYS_ICM, - [DC.PCCM]: DC.DELIVERY_SYS_PCCM, - [DC.MCO_PIHP]: DC.DELIVERY_SYS_MCO_PIHP, - [DC.OTHER]: DC.DELIVERY_SYS_OTHER, - }; - - const selectedDeliverySystems = data.DeliverySysRepresentationDenominator; - if (selectedDeliverySystems) { - selectedDeliverySystems.forEach((system) => { - Object.entries(data).forEach((selection) => { - // check if user has actually checked the nested radio button selection - if (selection[0] === deliverySystemsMap[system] && !selection[1]) { - errorArray.push({ - errorLocation: "Delivery Systems", - errorMessage: - errorMessage ?? - "You must indicate if the measure-eligible population is included", - }); - } - }); - }); - } - - return errorArray; -}; diff --git a/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx b/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx index eb4ebce901..1fee268f9c 100644 --- a/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx +++ b/services/ui-src/src/measures/2024/shared/util/validationsMock.tsx @@ -8,7 +8,7 @@ import * as validateBothDatesInRange from "shared/globalValidations/validateBoth import * as validateDualPopInformation from "measures/2024/shared/globalValidations/validateDualPopInformation"; import * as validateEqualCategoryDenominators from "measures/2024/shared/globalValidations/validateEqualCategoryDenominators"; import * as validateEqualQualifierDenominators from "shared/globalValidations/validateEqualQualifierDenominators"; -import * as validateFfsRadioButtonCompletion from "measures/2024/shared/globalValidations/validateFfsRadioButtonCompletion"; +import * as validateFfsRadioButtonCompletion from "shared/globalValidations/validateFfsRadioButtonCompletion"; import * as validateRateNotZero from "measures/2024/shared/globalValidations/validateRateNotZero"; import * as validateRateZero from "measures/2024/shared/globalValidations/validateRateZero"; import * as validateNumeratorsLessThanDenominators from "shared/globalValidations/validateNumeratorsLessThanDenominators"; diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts b/services/ui-src/src/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts similarity index 94% rename from services/ui-src/src/measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts rename to services/ui-src/src/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts index bbad461994..8c763860f3 100644 --- a/services/ui-src/src/measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts +++ b/services/ui-src/src/shared/globalValidations/validateFfsRadioButtonCompletion/index.test.ts @@ -1,4 +1,4 @@ -import { testFormData } from "../testHelpers/_testFormData"; +import { testFormData } from "measures/2024/shared/globalValidations/testHelpers/_testFormData"; import * as DC from "dataConstants"; import { validateFfsRadioButtonCompletion } from "."; diff --git a/services/ui-src/src/measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts b/services/ui-src/src/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts similarity index 100% rename from services/ui-src/src/measures/2023/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts rename to services/ui-src/src/shared/globalValidations/validateFfsRadioButtonCompletion/index.ts