From c22fa9fa8c72ec8821934acc490c7f58e43dfe3c Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Thu, 12 Sep 2024 16:05:22 +0200 Subject: [PATCH] fix(SW-360): Added test ids to form fields --- components/Forms/Register/index.tsx | 1 + components/TempDesignSystem/Form/Checkbox/index.tsx | 1 + components/TempDesignSystem/Form/Country/index.tsx | 1 + components/TempDesignSystem/Form/Date/index.tsx | 13 ++++++++++--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/Forms/Register/index.tsx b/components/Forms/Register/index.tsx index 9494e59a7..28d10a4f6 100644 --- a/components/Forms/Register/index.tsx +++ b/components/Forms/Register/index.tsx @@ -146,6 +146,7 @@ export default function Form() { type="submit" intent="primary" disabled={methods.formState.isSubmitting} + data-testid="submit" > {intl.formatMessage({ id: "Sign up to Scandic Friends" })} diff --git a/components/TempDesignSystem/Form/Checkbox/index.tsx b/components/TempDesignSystem/Form/Checkbox/index.tsx index 339dff676..8b2885ebc 100644 --- a/components/TempDesignSystem/Form/Checkbox/index.tsx +++ b/components/TempDesignSystem/Form/Checkbox/index.tsx @@ -26,6 +26,7 @@ export default function Checkbox({ className={styles.container} isSelected={field.value} onChange={field.onChange} + data-testid={name} > {({ isSelected }) => ( <> diff --git a/components/TempDesignSystem/Form/Country/index.tsx b/components/TempDesignSystem/Form/Country/index.tsx index 9777a4a48..0a5406640 100644 --- a/components/TempDesignSystem/Form/Country/index.tsx +++ b/components/TempDesignSystem/Form/Country/index.tsx @@ -68,6 +68,7 @@ export default function CountrySelect({ onSelectionChange={handleChange} ref={field.ref} selectedKey={field.value} + data-testid={name} >
) @@ -135,7 +138,9 @@ export default function DateSelect({ name, registerOptions = {} }: DateProps) { placeholder="MM" required tabIndex={2} - value={segment.isPlaceholder ? undefined : segment.value} + defaultValue={ + segment.isPlaceholder ? undefined : segment.value + } /> ) @@ -151,7 +156,9 @@ export default function DateSelect({ name, registerOptions = {} }: DateProps) { placeholder="YYYY" required tabIndex={1} - value={segment.isPlaceholder ? undefined : segment.value} + defaultValue={ + segment.isPlaceholder ? undefined : segment.value + } /> )