diff --git a/frontend/src/lib/components/AddRelationshipForm.svelte.spec.ts b/frontend/src/lib/components/AddRelationshipForm.svelte.spec.ts index 5dec75e3..9ddfd8a2 100644 --- a/frontend/src/lib/components/AddRelationshipForm.svelte.spec.ts +++ b/frontend/src/lib/components/AddRelationshipForm.svelte.spec.ts @@ -37,4 +37,20 @@ describe('AddRelationshipForm', () => { document.querySelector('button')!.click(); await expect.element(page.getByRole('button', { name: /^Hinzufügen$/i })).toBeDisabled(); }); + + it('shows year-range error when toYear is before fromYear', async () => { + render(AddRelationshipForm, { personId: 'person-1' }); + document.querySelector('button')!.click(); + await expect.element(page.getByRole('combobox')).toBeInTheDocument(); + + const fromInput = document.querySelector('input[name="fromYear"]')!; + fromInput.value = '1935'; + fromInput.dispatchEvent(new InputEvent('input', { bubbles: true })); + + const toInput = document.querySelector('input[name="toYear"]')!; + toInput.value = '1920'; + toInput.dispatchEvent(new InputEvent('input', { bubbles: true })); + + await expect.element(page.getByRole('alert')).toBeVisible(); + }); });