-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [#571] Set up interaction test for validation styling
* Validation error styling for a utrecht-form-field and utrecht-form-fieldset * Content component customClass styling
- Loading branch information
1 parent
156ebad
commit 2c488ea
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
}, | ||
}; |