From d4720c712d99b51d3d6062b1f5bc281a82d70b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Sun, 28 Apr 2024 08:21:18 -0300 Subject: [PATCH] test(FormBuilder): check whether disabled is being respected --- .../FormBuilder/fields/CheckboxField.tsx | 2 + .../FormBuilder/fields/TextAreaField.tsx | 2 + .../fields/selects/SelectField.tsx | 80 +++++++++---------- src/components/FormBuilder/isFieldDisabled.ts | 12 +++ .../FormBuilder/CheckboxField.test.tsx | 12 +++ .../FormBuilder/DatePickerInput.test.tsx | 7 ++ .../components/FormBuilder/FormField.test.tsx | 14 ++++ .../FormBuilder/HiddenField.test.tsx | 11 +++ .../FormBuilder/InputField.test.tsx | 28 ++++--- .../FormBuilder/SwitchField.test.tsx | 6 ++ .../FormBuilder/TextAreaField.test.tsx | 5 ++ tests/helpers/renderFormField.tsx | 11 +-- tsconfig.json | 1 - 13 files changed, 133 insertions(+), 58 deletions(-) create mode 100644 src/components/FormBuilder/isFieldDisabled.ts diff --git a/src/components/FormBuilder/fields/CheckboxField.tsx b/src/components/FormBuilder/fields/CheckboxField.tsx index f7eb022..d1ad1d0 100644 --- a/src/components/FormBuilder/fields/CheckboxField.tsx +++ b/src/components/FormBuilder/fields/CheckboxField.tsx @@ -9,6 +9,7 @@ import { } from "#/components/ui/Form"; import { BaseField, withConditional } from "../fields"; +import isFieldDisabled from "../isFieldDisabled"; export interface CheckboxFieldProps extends BaseField { type: "checkbox"; @@ -31,6 +32,7 @@ export const CheckboxField = withConditional(
diff --git a/src/components/FormBuilder/fields/TextAreaField.tsx b/src/components/FormBuilder/fields/TextAreaField.tsx index 3ed0b6b..532ee02 100644 --- a/src/components/FormBuilder/fields/TextAreaField.tsx +++ b/src/components/FormBuilder/fields/TextAreaField.tsx @@ -11,6 +11,7 @@ import { import { Textarea } from "#/components/ui/Textarea"; import { BaseField, withConditional } from "../fields"; +import isFieldDisabled from "../isFieldDisabled"; export interface TextAreaFieldProps extends BaseField { length?: { @@ -47,6 +48,7 @@ export const TextAreaField = withConditional( {field.description}