mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 16:01:06 +08:00
29 lines
877 B
Plaintext
29 lines
877 B
Plaintext
```js
|
|
// Form.stories.js
|
|
|
|
import { userEvent, within } from '@storybook/testing-library';
|
|
|
|
import LoginForm from './LoginForm.vue';
|
|
|
|
export default {
|
|
component: LoginForm,
|
|
};
|
|
|
|
export const FilledForm = {
|
|
play: async ({ args, canvasElement }) => {
|
|
// Starts querying the component from its root element
|
|
const canvas = within(canvasElement);
|
|
|
|
await userEvent.type(canvas.getByTestId('email'), 'email');
|
|
await userEvent.type(canvas.getByTestId('password'), 'password');
|
|
|
|
// See https://storybook.js.org/docs/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
|
|
await userEvent.click(canvas.getByRole('button'));
|
|
},
|
|
render: (args, { argTypes }) => ({
|
|
components: { LoginForm },
|
|
props: Object.keys(argTypes),
|
|
template: '<LoginForm @onSubmit="onSubmit" v-bind="$props"/>',
|
|
}),
|
|
};
|
|
``` |