refactor(timeline): drop EventForm's redundant type state
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 4m13s
CI / OCR Service Tests (pull_request) Successful in 27s
CI / Backend Unit Tests (pull_request) Successful in 5m1s
CI / fail2ban Regex (pull_request) Successful in 47s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m5s
SDD Gate / RTM Check (pull_request) Successful in 15s
SDD Gate / Contract Validate (pull_request) Successful in 24s
SDD Gate / Constitution Impact (pull_request) Successful in 19s
CI / Unit & Component Tests (push) Successful in 4m33s
CI / OCR Service Tests (push) Successful in 27s
CI / Backend Unit Tests (push) Successful in 5m11s
CI / fail2ban Regex (push) Successful in 48s
CI / Semgrep Security Scan (push) Successful in 25s
CI / Compose Bucket Idempotency (push) Successful in 1m12s
All checks were successful
CI / Unit & Component Tests (pull_request) Successful in 4m13s
CI / OCR Service Tests (pull_request) Successful in 27s
CI / Backend Unit Tests (pull_request) Successful in 5m1s
CI / fail2ban Regex (pull_request) Successful in 47s
CI / Semgrep Security Scan (pull_request) Successful in 22s
CI / Compose Bucket Idempotency (pull_request) Successful in 1m5s
SDD Gate / RTM Check (pull_request) Successful in 15s
SDD Gate / Contract Validate (pull_request) Successful in 24s
SDD Gate / Constitution Impact (pull_request) Successful in 19s
CI / Unit & Component Tests (push) Successful in 4m33s
CI / OCR Service Tests (push) Successful in 27s
CI / Backend Unit Tests (push) Successful in 5m11s
CI / fail2ban Regex (push) Successful in 48s
CI / Semgrep Security Scan (push) Successful in 25s
CI / Compose Bucket Idempotency (push) Successful in 1m12s
The submitted type comes from EventTypeSelect's own hidden input; EventForm's `type` $state was only read to seed `value=` and the onchange reassignment had no downstream reader. Inline the seed expression and pass markDirty directly, removing the second source of truth. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit was merged in pull request #832.
This commit is contained in:
@@ -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<string>(form?.type ?? event?.type ?? 'PERSONAL');
|
||||
let dateIso = $state(form?.eventDate ?? event?.eventDate ?? '');
|
||||
let precision = $state<DatePrecision>(
|
||||
(form?.precision as DatePrecision) ?? (event?.precision as DatePrecision) ?? 'DAY'
|
||||
@@ -212,10 +211,11 @@ function markDirty() {
|
||||
<span class="mb-1 block text-sm font-medium text-ink-2"
|
||||
>{m.event_editor_type_label()}</span
|
||||
>
|
||||
<EventTypeSelect value={type} name="type" onchange={(t) => {
|
||||
type = t;
|
||||
markDirty();
|
||||
}} />
|
||||
<EventTypeSelect
|
||||
value={form?.type ?? event?.type ?? 'PERSONAL'}
|
||||
name="type"
|
||||
onchange={markDirty}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-5 md:grid-cols-2">
|
||||
|
||||
@@ -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' }] });
|
||||
|
||||
Reference in New Issue
Block a user