Skip to content

Commit

Permalink
[#65] Additionnal feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Dec 1, 2023
1 parent 235737e commit 8de305e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/components/ComponentConfiguration.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ export const Address: Story = {
},
builderInfo: {
title: 'Address Field',
icon: 'gome',
icon: 'home',
group: 'basic',
weight: 10,
schema: {},
Expand Down
54 changes: 21 additions & 33 deletions src/components/formio/fieldset.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from '@storybook/jest';
import {Meta, StoryFn, StoryObj} from '@storybook/react';
import {Meta, StoryObj} from '@storybook/react';
import {within} from '@storybook/testing-library';

import {withFormik} from '@/sb-decorators';
Expand All @@ -12,58 +12,46 @@ export default {
decorators: [withFormik],
parameters: {
modal: {noModal: true},
// https://github.com/bbbtech/storybook-formik/issues/51#issuecomment-1136668271
docs: {
inlineStories: false,
iframeHeight: 150,
},
},
args: {
type: 'textfield',
children: '<any children />',
},
} as Meta<typeof Fieldset>;

type Story = StoryObj<typeof Fieldset>;

const Template: StoryFn<typeof Fieldset> = args => (
<Fieldset {...args}>
<div>{args.children || '<any children />'}</div>
</Fieldset>
);

export const WithoutLabel: Story = {
render: Template,

args: {
label: '',
},
};

export const WithToolTip: Story = {
render: Template,

args: {
label: 'With tooltip',
tooltip: 'Hiya!',
},
};

export const WithErrors: Story = Template.bind([]);
WithErrors.parameters = {
formik: {
initialValues: {someField: ''},
initialErrors: {someField: 'Some error'},
export const WithErrors: Story = {
parameters: {
formik: {
initialValues: {someField: ''},
initialErrors: {someField: 'Some error'},
},
},
args: {
label: 'Errors must be displayed',
children: <input type="text" />,
field: 'someField',
},
argTypes: {
children: {table: {disable: true}},
},

play: async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.queryByText('Some error')).toBeInTheDocument();
},
};
WithErrors.args = {
label: 'Errors must be displayed',
children: <input type="text" />,
field: 'someField',
};
WithErrors.argTypes = {
children: {table: {disable: true}},
};
WithErrors.play = async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.queryByText('Some error')).toBeInTheDocument();
};

0 comments on commit 8de305e

Please sign in to comment.