From 01e0a2135c2d33a749840a09936e1034eebf3cb4 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Fri, 20 Oct 2023 15:54:22 +0200 Subject: [PATCH] :white_check_mark: [#571] Update stories * Added some pristine state stories & tests for hidden components * Updated zod story to use semantically correct component in favour of form-control div/styles to be deleted. --- src/formio/components/composite.stories.js | 19 +++++++++++++++++++ src/i18n-zod.stories.js | 8 +++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/formio/components/composite.stories.js b/src/formio/components/composite.stories.js index afaa57ca8..fb58b6a84 100644 --- a/src/formio/components/composite.stories.js +++ b/src/formio/components/composite.stories.js @@ -1,3 +1,4 @@ +import {expect} from '@storybook/jest'; import {userEvent, within} from '@storybook/testing-library'; import {withUtrechtDocument} from 'story-utils/decorators'; @@ -14,6 +15,7 @@ export default { type: 'textfield', key: 'textfield', label: 'Required text field', + description: 'Text field description', validate: { required: true, pattern: '^\\d+', @@ -38,6 +40,12 @@ export default { html: '

Some WYSIWYG content

', customClass: 'info', }, + { + type: 'textfield', + key: 'hiddenTextfield', + label: 'Hidden text field', + hidden: true, + }, { label: 'Submit', showValidations: false, @@ -57,6 +65,17 @@ export default { }, }; +export const Pristine = { + render: MultipleFormioComponents, + + play: async ({canvasElement}) => { + const canvas = within(canvasElement); + + expect(canvas.queryByText('Required text field')).toBeVisible(); + expect(canvas.queryByText('Hidden text field')).not.toBeInTheDocument(); + }, +}; + export const WithValidationErrors = { render: args => (
e.preventDefault()}> diff --git a/src/i18n-zod.stories.js b/src/i18n-zod.stories.js index d1902388f..099e3b1f7 100644 --- a/src/i18n-zod.stories.js +++ b/src/i18n-zod.stories.js @@ -1,4 +1,5 @@ import {userEvent, within} from '@storybook/testing-library'; +import {ButtonGroup} from '@utrecht/component-library-react'; import {Form, Formik} from 'formik'; import {useIntl} from 'react-intl'; import {z} from 'zod'; @@ -102,14 +103,11 @@ const AccessibleErrorsExample = ({onSubmit}) => { -
+ -
+ );