Skip to content

Commit

Permalink
✅ [#571] Set up interaction test for validation styling
Browse files Browse the repository at this point in the history
* Validation error styling for a utrecht-form-field and utrecht-form-fieldset
* Content component customClass styling
  • Loading branch information
sergei-maertens committed Oct 20, 2023
1 parent 156ebad commit 2c488ea
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/formio/components/composite.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import {userEvent, within} from '@storybook/testing-library';

import {withUtrechtDocument} from 'story-utils/decorators';
import {sleep} from 'utils';

import {MultipleFormioComponents} from './story-util';

export default {
title: 'Form.io components / Composite',
decorators: [withUtrechtDocument],
args: {
components: [
{
type: 'textfield',
key: 'textfield',
label: 'Required text field',
validate: {
required: true,
pattern: '^\\d+',
},
},
{
type: 'radio',
key: 'radio',
label: 'Required radio',
validate: {
required: true,
},
values: [
{value: 'a', label: 'Option A'},
{value: 'b', label: 'Option B'},
],
},
{
type: 'content',
key: 'content',
label: 'Content',
html: '<p>Some WYSIWYG content</p>',
customClass: 'info',
},
{
label: 'Submit',
showValidations: false,
key: 'submit1',
type: 'button',
input: true,
},
],
evalContext: {},
},
argTypes: {
components: {table: {disable: true}},
evalContext: {table: {disable: true}},
},
parameters: {
controls: {sort: 'requiredFirst'},
},
};

export const WithValidationErrors = {
render: args => (
<form onSubmit={e => e.preventDefault()}>
<MultipleFormioComponents {...args} />
</form>
),

play: async ({canvasElement}) => {
const canvas = within(canvasElement);

// just form.io things...
await sleep(100);

await userEvent.click(canvas.getByRole('button'));
},
};

0 comments on commit 2c488ea

Please sign in to comment.