@@ -1,5 +1,22 @@
|
||||
import LoginPage from './LoginPage.vue';
|
||||
import { expect, userEvent, within } from '@storybook/test';
|
||||
|
||||
export default { title: 'Pages/LoginPage', component: LoginPage };
|
||||
export const Empty = {};
|
||||
export const Loading = { parameters: { docs: { description: { story: 'Submit state is exercised through the live form.' } } } };
|
||||
|
||||
export const ErrorFocus = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const originalFetch = window.fetch;
|
||||
window.fetch = async () => new Response(JSON.stringify({ error: { message: 'Invalid credentials.' } }), { status: 401, headers: { 'content-type': 'application/json' } });
|
||||
try {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByLabelText('Email'), 'seller@example.com');
|
||||
await userEvent.type(canvas.getByLabelText('Password'), 'wrong-password');
|
||||
await userEvent.click(canvas.getByRole('button', { name: 'Sign in' }));
|
||||
await expect(canvas.getByRole('alert')).toHaveFocus();
|
||||
} finally {
|
||||
window.fetch = originalFetch;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user