mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 03:11:49 +08:00
28 lines
768 B
Plaintext
28 lines
768 B
Plaintext
```js
|
|
// Form.stories.js
|
|
|
|
import { userEvent, within } from '@storybook/addon-interactions';
|
|
|
|
import LoginForm from './LoginForm.svelte';
|
|
|
|
export default {
|
|
component: LoginForm,
|
|
//👇 Marking the onSubmit with this configuration will log the event in the Actions panel
|
|
argTypes: { onSubmit: { action: true } },
|
|
};
|
|
|
|
export const FilledForm = {
|
|
play: async ({ args, canvasElement }) => {
|
|
// Starts querying the component from it's root element
|
|
const canvas = within(canvasElement);
|
|
|
|
await userEvent.type(canvas.getByTestId('email'), 'email');
|
|
await userEvent.type(canvas.getByTestId('password'), 'password');
|
|
await userEvent.click(canvas.getByRole('button'));
|
|
},
|
|
render: (args) => {
|
|
Component: LoginForm,
|
|
props: args,
|
|
},
|
|
};
|
|
``` |