mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
38 lines
1.0 KiB
Plaintext
38 lines
1.0 KiB
Plaintext
```md
|
|
<!-- LoginForm.stories.mdx -->
|
|
|
|
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
|
|
import { within, userEvent } from '@storybook/testing-library';
|
|
|
|
import { LoginForm } from './LoginForm.component';
|
|
|
|
<Meta title="Form" component={LoginForm} />
|
|
|
|
export const Template = (args) => ({ props: args });
|
|
|
|
<Canvas>
|
|
<Story name="Empty Form">
|
|
{Template.bind(())}
|
|
</Story>
|
|
|
|
<Story
|
|
name="Filled Form"
|
|
play={async ({ canvasElement }) => {
|
|
// Starts querying the component from its root element
|
|
const canvas = within(canvasElement);
|
|
|
|
await userEvent.type(canvas.getByTestId('email'), 'email@provider.com', {
|
|
delay: 100,
|
|
});
|
|
await userEvent.type(canvas.getByTestId('password'), 'a-random-password', {
|
|
delay: 100,
|
|
});
|
|
// See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
|
|
await userEvent.click(canvas.getByRole('button'));
|
|
}}>
|
|
{Template.bind({})}
|
|
</Story>
|
|
|
|
</Canvas>
|
|
``` |