test: cover login error focus
Quality / test (push) Canceled after 0s

This commit is contained in:
2026-09-11 12:14:11 -04:00
parent 38406f7c60
commit 0f04ef45fe
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -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;
}
},
};