diff --git a/frontend/src/routes/geschichten/new/JourneyCreate.svelte b/frontend/src/routes/geschichten/new/JourneyCreate.svelte index cedd7d8b..a2702978 100644 --- a/frontend/src/routes/geschichten/new/JourneyCreate.svelte +++ b/frontend/src/routes/geschichten/new/JourneyCreate.svelte @@ -38,6 +38,9 @@ async function handleSubmit(e: SubmitEvent) { } const created = await res.json(); goto(`/geschichten/${created.id}/edit`); + } catch (e) { + console.error('JourneyCreate submit failed', e); + errorMessage = getErrorMessage(undefined); } finally { submitting = false; } diff --git a/frontend/src/routes/geschichten/new/JourneyCreate.svelte.spec.ts b/frontend/src/routes/geschichten/new/JourneyCreate.svelte.spec.ts index 30ee0549..15c47da9 100644 --- a/frontend/src/routes/geschichten/new/JourneyCreate.svelte.spec.ts +++ b/frontend/src/routes/geschichten/new/JourneyCreate.svelte.spec.ts @@ -62,6 +62,22 @@ describe('JourneyCreate — failure path', () => { }); }); + it('shows an error alert when the network request rejects (no crash)', async () => { + vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new TypeError('network down'))); + const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}); + + render(JourneyCreate, {}); + + await userEvent.fill( + page.getByRole('textbox', { name: m.journey_title_aria_label() }), + 'Meine Lesereise' + ); + await userEvent.click(page.getByRole('button', { name: m.journey_create_submit() })); + + await expect.element(page.getByRole('alert')).toBeInTheDocument(); + consoleError.mockRestore(); + }); + it('has an accessible label on the title input', async () => { vi.stubGlobal('fetch', vi.fn()); render(JourneyCreate, {});