diff --git a/frontend/src/lib/planner/RecipePicker.svelte b/frontend/src/lib/planner/RecipePicker.svelte
index 1d2ffde..51940ac 100644
--- a/frontend/src/lib/planner/RecipePicker.svelte
+++ b/frontend/src/lib/planner/RecipePicker.svelte
@@ -8,24 +8,25 @@
interface Suggestion {
recipe: Recipe;
- simulatedScore: number;
+ scoreDelta: number;
+ hasConflict: boolean;
}
let {
planId,
date,
dateLabel,
- currentVarietyScore = 0,
suggestions = [],
allRecipes = [],
+ isLoading = false,
onpick
}: {
planId: string;
date: string;
dateLabel: string;
- currentVarietyScore?: number;
suggestions: Suggestion[];
allRecipes: Recipe[];
+ isLoading?: boolean;
onpick: (recipeId: string, recipeName: string) => void;
} = $props();
@@ -71,7 +72,27 @@
- {#if suggestions.length > 0}
+ {#if isLoading}
+
+ {#each [1, 2, 3] as i (i)}
+
+ {/each}
+
+ {:else if suggestions.length > 0}
@@ -79,7 +100,6 @@
{#each suggestions as suggestion (suggestion.recipe.id)}
- {@const delta = suggestion.simulatedScore - currentVarietyScore}
{@const meta = recipeMetadata(suggestion.recipe)}
{/if}
- {#if delta > 0}
+ {#if !suggestion.hasConflict}
- ↑ +{delta.toFixed(0)} Punkte
+ ↑ +{suggestion.scoreDelta.toFixed(0)} Punkte
{:else}
{
expect(screen.getByText('Hähnchen-Curry')).toBeTruthy();
});
- it('shows green badge for suggestions with positive delta', () => {
+ it('shows green badge when hasConflict is false', () => {
render(RecipePicker, { props: baseProps });
- // Lachsfilet: simulatedScore 9.5 - currentVarietyScore 7.5 = +2 → green badge
+ // Lachsfilet: hasConflict = false → green badge
const badge = screen.getByTestId('badge-s1');
expect(badge.getAttribute('data-type')).toBe('good');
});
- it('shows yellow badge for suggestions with zero or negative delta', () => {
+ it('shows yellow badge when hasConflict is true', () => {
render(RecipePicker, { props: baseProps });
- // Hähnchen-Curry: 6.0 - 7.5 = -1.5 → yellow badge
+ // Hähnchen-Curry: hasConflict = true → yellow badge
const badge = screen.getByTestId('badge-s2');
expect(badge.getAttribute('data-type')).toBe('warning');
});
@@ -98,4 +97,16 @@ describe('RecipePicker', () => {
await userEvent.type(input, 'xyznotfound');
expect(screen.getByText(/Keine Treffer/i)).toBeTruthy();
});
+
+ it('shows loading skeleton instead of Empfohlen section when isLoading is true', () => {
+ render(RecipePicker, { props: { ...baseProps, isLoading: true } });
+ expect(screen.getByTestId('suggestions-loading')).toBeTruthy();
+ expect(screen.queryByText(/Empfohlen/i)).toBeNull();
+ });
+
+ it('hides loading skeleton when isLoading is false and suggestions are present', () => {
+ render(RecipePicker, { props: { ...baseProps, isLoading: false } });
+ expect(screen.queryByTestId('suggestions-loading')).toBeNull();
+ expect(screen.getByText(/Empfohlen/i)).toBeTruthy();
+ });
});