diff --git a/frontend/src/lib/geschichte/JourneyEditor.svelte.spec.ts b/frontend/src/lib/geschichte/JourneyEditor.svelte.spec.ts index 32f2c048..7aa12599 100644 --- a/frontend/src/lib/geschichte/JourneyEditor.svelte.spec.ts +++ b/frontend/src/lib/geschichte/JourneyEditor.svelte.spec.ts @@ -310,6 +310,38 @@ describe('JourneyEditor — live announce region', () => { }); }); +describe('JourneyEditor — note patch body', () => { + it('sends {"note":null} when note textarea is cleared and blurred', async () => { + const items = [ + { id: 'i1', position: 0, document: docSummary('d1', 'Brief A'), note: 'old note' } + ]; + vi.stubGlobal( + 'fetch', + vi.fn().mockResolvedValue({ + ok: true, + json: vi + .fn() + .mockResolvedValue({ id: 'i1', position: 0, document: docSummary('d1', 'Brief A') }) + }) + ); + + render(JourneyEditor, defaultProps({ geschichte: makeGeschichte({ items }) })); + + const textarea = page.getByRole('textbox', { name: /Kuratoren-Notiz/ }); + await userEvent.clear(textarea); + await textarea.element().dispatchEvent(new FocusEvent('blur')); + await new Promise((r) => setTimeout(r, 50)); + + expect(globalThis.fetch).toHaveBeenCalledWith( + expect.stringContaining('/items/i1'), + expect.objectContaining({ + method: 'PATCH', + body: JSON.stringify({ note: null }) + }) + ); + }); +}); + describe('JourneyEditor — duplicate document aria-disabled', () => { it('already-added document appears as aria-disabled in picker', async () => { const items = [{ id: 'i1', position: 0, document: docSummary('d1', 'Brief von Karl') }];