test(11-02): add failing tests for auto-scroll to first error on validation failure

- Add scrollIntoView mock (vi.fn()) in beforeEach to both test files
- Add POLISH-04 test in BackendSelectionStep: scrolls to remote-name on empty submit
- Add POLISH-04 test in RemoteConfigStep: scrolls to first errored field on empty submit
This commit is contained in:
2026-04-01 13:29:48 +02:00
parent 9af58bc970
commit 8b7daa860c
2 changed files with 43 additions and 2 deletions
@@ -1,7 +1,8 @@
// @vitest-environment jsdom
// Covers WIZD-01: card grid renders Azure Blob, Amazon S3, S3-Compatible (Azure first)
// Covers WIZD-04: remote name field validates alphanumeric/dash/underscore
import { describe, it, expect } from 'vitest';
// Covers POLISH-04: auto-scroll to first errored field on validation failure
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { WizardProvider } from '../../store/context';
@@ -16,6 +17,10 @@ function renderStep() {
}
describe('BackendSelectionStep', () => {
beforeEach(() => {
Element.prototype.scrollIntoView = vi.fn();
});
describe('WIZD-01: backend card grid', () => {
it('renders Azure Blob Storage card', () => {
renderStep();
@@ -138,4 +143,19 @@ describe('BackendSelectionStep', () => {
});
});
});
describe('POLISH-04: auto-scroll to first error', () => {
it('scrolls to remote-name field when submitted with empty name', async () => {
const user = userEvent.setup();
renderStep();
const nameInput = screen.getByRole('textbox');
await user.clear(nameInput);
// Submit via Next button with empty name to trigger validation failure
const nextButton = screen.getByRole('button', { name: /next/i });
await user.click(nextButton);
await waitFor(() => {
expect(Element.prototype.scrollIntoView).toHaveBeenCalled();
});
});
});
});