feat(recipes): display form error from \$page.form in RecipeForm

- Import page store and render role="alert" error banner
- Add mock for \$app/stores and \$app/forms in RecipeForm tests
- Add tests: error banner shown when form.error set, hidden when null

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 10:31:18 +02:00
parent 6505cb4251
commit e4d3008139
2 changed files with 30 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
type Category = { id: string; name: string; tagType?: string };
type EditRecipe = {
@@ -45,6 +47,11 @@
</script>
<form method="POST" {action}>
<!-- Error banner -->
{#if $page.form?.error}
<div role="alert">{$page.form.error}</div>
{/if}
<!-- Basic info -->
<label for="name">Name</label>
<input id="name" name="name" type="text" bind:value={name} required />