Skip to content

Commit

Permalink
✅ [#571] Update stories
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
sergei-maertens committed Oct 20, 2023
1 parent 2c488ea commit 01e0a21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 19 additions & 0 deletions src/formio/components/composite.stories.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {expect} from '@storybook/jest';
import {userEvent, within} from '@storybook/testing-library';

import {withUtrechtDocument} from 'story-utils/decorators';
Expand All @@ -14,6 +15,7 @@ export default {
type: 'textfield',
key: 'textfield',
label: 'Required text field',
description: 'Text field description',
validate: {
required: true,
pattern: '^\\d+',
Expand All @@ -38,6 +40,12 @@ export default {
html: '<p>Some WYSIWYG content</p>',
customClass: 'info',
},
{
type: 'textfield',
key: 'hiddenTextfield',
label: 'Hidden text field',
hidden: true,
},
{
label: 'Submit',
showValidations: false,
Expand All @@ -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 => (
<form onSubmit={e => e.preventDefault()}>
Expand Down
8 changes: 3 additions & 5 deletions src/i18n-zod.stories.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -102,14 +103,11 @@ const AccessibleErrorsExample = ({onSubmit}) => {
<Form>
<TextField name="name" label={labels.name} />
<EmailField name="email" label={labels.email} />
<div
className="openforms-form-control"
style={{display: 'flex', justifyContent: 'flex-end'}}
>
<ButtonGroup style={{justifyContent: 'flex-end'}}>
<Button type="submit" variant="primary">
Submit
</Button>
</div>
</ButtonGroup>
</Form>
</Formik>
);
Expand Down

0 comments on commit 01e0a21

Please sign in to comment.