diff --git a/frontend/src/lib/timeline/EventForm.svelte b/frontend/src/lib/timeline/EventForm.svelte index 9cf675d1..36c9296f 100644 --- a/frontend/src/lib/timeline/EventForm.svelte +++ b/frontend/src/lib/timeline/EventForm.svelte @@ -61,7 +61,6 @@ let { // won't update the form — the two dedicated routes always remount, which is fine. let title = $state(form?.title ?? event?.title ?? ''); let description = $state(form?.description ?? event?.description ?? ''); -let type = $state(form?.type ?? event?.type ?? 'PERSONAL'); let dateIso = $state(form?.eventDate ?? event?.eventDate ?? ''); let precision = $state( (form?.precision as DatePrecision) ?? (event?.precision as DatePrecision) ?? 'DAY' @@ -212,10 +211,11 @@ function markDirty() { {m.event_editor_type_label()} - { - type = t; - markDirty(); - }} /> +
diff --git a/frontend/src/lib/timeline/EventForm.svelte.spec.ts b/frontend/src/lib/timeline/EventForm.svelte.spec.ts index 2962df86..d083bda9 100644 --- a/frontend/src/lib/timeline/EventForm.svelte.spec.ts +++ b/frontend/src/lib/timeline/EventForm.svelte.spec.ts @@ -62,6 +62,20 @@ describe('EventForm — date precision RANGE reveal (headline AC, REQ-008/009)', }); }); +describe('EventForm — type seeding (review #8 refactor fence)', () => { + it('seeds the type selector from the event so the submitted type is correct', async () => { + renderForm({ event: makeEvent({ type: 'HISTORICAL' }) }); + const hidden = document.querySelector('input[type="hidden"][name="type"]') as HTMLInputElement; + expect(hidden.value).toBe('HISTORICAL'); + }); + + it('prefers the fail-payload type over the seeded event', async () => { + renderForm({ event: makeEvent({ type: 'PERSONAL' }), form: { type: 'HISTORICAL' } }); + const hidden = document.querySelector('input[type="hidden"][name="type"]') as HTMLInputElement; + expect(hidden.value).toBe('HISTORICAL'); + }); +}); + describe('EventForm — picker preselect (REQ-014)', () => { it('preselects a person when initialPersons is provided', async () => { renderForm({ initialPersons: [{ id: 'p1', displayName: 'Anna Müller' }] });