-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19402 from storybookjs/fix/small-improvements
Build: Improve template stories
- Loading branch information
Showing
13 changed files
with
66 additions
and
44 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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
/* eslint-disable storybook/await-interactions */ | ||
/* eslint-disable storybook/use-storybook-testing-library */ | ||
// @TODO: use addon-interactions and remove the rule disable above | ||
import { ComponentStoryObj, ComponentMeta } from '@storybook/react'; | ||
|
@@ -15,21 +14,18 @@ export default { | |
}, | ||
} as ComponentMeta<typeof AccountForm>; | ||
|
||
// export const Standard = (args: any) => <AccountForm {...args} />; | ||
// Standard.args = { passwordVerification: false }; | ||
// Standard.play = () => userEvent.type(screen.getByTestId('email'), '[email protected]'); | ||
type Story = ComponentStoryObj<typeof AccountForm>; | ||
|
||
export const Standard: ComponentStoryObj<typeof AccountForm> = { | ||
// render: (args: AccountFormProps) => <AccountForm {...args} />, | ||
export const Standard: Story = { | ||
args: { passwordVerification: false }, | ||
}; | ||
|
||
export const StandardEmailFilled = { | ||
export const StandardEmailFilled: Story = { | ||
...Standard, | ||
play: () => userEvent.type(screen.getByTestId('email'), '[email protected]'), | ||
}; | ||
|
||
export const StandardEmailFailed = { | ||
export const StandardEmailFailed: Story = { | ||
...Standard, | ||
play: async () => { | ||
await userEvent.type(screen.getByTestId('email'), '[email protected]@com'); | ||
|
@@ -38,21 +34,21 @@ export const StandardEmailFailed = { | |
}, | ||
}; | ||
|
||
export const StandardPasswordFailed = { | ||
export const StandardPasswordFailed: Story = { | ||
...Standard, | ||
play: async () => { | ||
await StandardEmailFilled.play(); | ||
play: async (context) => { | ||
await StandardEmailFilled.play(context); | ||
await userEvent.type(screen.getByTestId('password1'), 'asdf'); | ||
await userEvent.click(screen.getByTestId('submit')); | ||
}, | ||
}; | ||
|
||
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); | ||
|
||
export const StandardFailHover = { | ||
export const StandardFailHover: Story = { | ||
...StandardPasswordFailed, | ||
play: async () => { | ||
await StandardPasswordFailed.play(); | ||
play: async (context) => { | ||
await StandardPasswordFailed.play(context); | ||
await sleep(100); | ||
await userEvent.hover(screen.getByTestId('password-error-info')); | ||
}, | ||
|
@@ -62,29 +58,29 @@ export const Verification: ComponentStoryObj<typeof AccountForm> = { | |
args: { passwordVerification: true }, | ||
}; | ||
|
||
export const VerificationPasssword1 = { | ||
export const VerificationPasssword1: Story = { | ||
...Verification, | ||
play: async () => { | ||
await StandardEmailFilled.play(); | ||
play: async (context) => { | ||
await StandardEmailFilled.play(context); | ||
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf'); | ||
await userEvent.click(screen.getByTestId('submit')); | ||
}, | ||
}; | ||
|
||
export const VerificationPasswordMismatch = { | ||
export const VerificationPasswordMismatch: Story = { | ||
...Verification, | ||
play: async () => { | ||
await StandardEmailFilled.play(); | ||
play: async (context) => { | ||
await StandardEmailFilled.play(context); | ||
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf'); | ||
await userEvent.type(screen.getByTestId('password2'), 'asdf1234'); | ||
await userEvent.click(screen.getByTestId('submit')); | ||
}, | ||
}; | ||
|
||
export const VerificationSuccess = { | ||
export const VerificationSuccess: Story = { | ||
...Verification, | ||
play: async () => { | ||
await StandardEmailFilled.play(); | ||
play: async (context) => { | ||
await StandardEmailFilled.play(context); | ||
await sleep(1000); | ||
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf', { delay: 50 }); | ||
await sleep(1000); | ||
|
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
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
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
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