fix(person): block submit while a life-date input is partial
A partial date (e.g. "14.03.") left the hidden ISO input empty, so saving the edit form silently cleared a stored date. PersonLifeDateField now delegates to the shared DateInput primitive (inline format error, calendar validation) and sets a custom validity while the error is present, so the browser blocks native submission for both person forms. A full clear stays submittable - that is the intentional clear path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { cleanup, render } from 'vitest-browser-svelte';
|
||||
import { page } from 'vitest/browser';
|
||||
import { page, userEvent } from 'vitest/browser';
|
||||
import PersonEditForm from './PersonEditForm.svelte';
|
||||
|
||||
afterEach(cleanup);
|
||||
@@ -219,4 +219,16 @@ describe('PersonEditForm', () => {
|
||||
const select = (await page.getByLabelText(/^generation$/i).element()) as HTMLSelectElement;
|
||||
expect(select.value).toBe('');
|
||||
});
|
||||
|
||||
// ─── partial-date guard (#812 review) ────────────────────────────────────────
|
||||
|
||||
it('blocks submission while a stored birth date is partially edited (no silent clear)', async () => {
|
||||
render(PersonEditForm, { props: { person: personPersonal } });
|
||||
|
||||
await userEvent.fill(page.getByLabelText(/^geburtsdatum$/i), '14.03.');
|
||||
|
||||
const birthInput = (await page.getByLabelText(/^geburtsdatum$/i).element()) as HTMLInputElement;
|
||||
expect(birthInput.checkValidity()).toBe(false);
|
||||
await expect.element(page.getByText(/Bitte im Format TT\.MM\.JJJJ/)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user