test(planner): verify mobile swap sheet triggers suggestion fetch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 15:04:20 +02:00
parent 813ddf8214
commit 49ed75a989

View File

@@ -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();