test(planner): verify mobile swap sheet triggers suggestion fetch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user