diff --git a/frontend/src/routes/(app)/planner/page.test.ts b/frontend/src/routes/(app)/planner/page.test.ts index fb2d181..674d96b 100644 --- a/frontend/src/routes/(app)/planner/page.test.ts +++ b/frontend/src/routes/(app)/planner/page.test.ts @@ -93,6 +93,26 @@ describe('+page.svelte — $effect suggestion fetch', () => { }); }); +describe('+page.svelte — swap sheet suggestion fetch', () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + + it('opening mobile swap sheet triggers fetch with planId and date', async () => { + vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ json: () => Promise.resolve({ suggestions: [] }) })); + + render(Page, { props: { data: mockDataWithSlot } }); + + // Open action sheet, then swap sheet + await userEvent.click(screen.getByTestId('day-meal-card')); + await userEvent.click(await screen.findByRole('button', { name: /Gericht tauschen/i })); + + await waitFor(() => expect(fetch).toHaveBeenCalledTimes(1)); + expect((fetch as any).mock.calls[0][0]).toContain(`planId=${PLAN_ID}`); + expect((fetch as any).mock.calls[0][0]).toContain(`date=${DATE}`); + }); +}); + describe('+page.svelte — remove meal', () => { afterEach(() => { vi.restoreAllMocks();