Fix demo task readiness and gate event creation
This commit is contained in:
@@ -63,11 +63,13 @@ vi.mock('../hooks/useBackNavigation', () => ({
|
||||
}));
|
||||
|
||||
const selectEventMock = vi.fn();
|
||||
const refetchMock = vi.fn();
|
||||
|
||||
vi.mock('../../context/EventContext', () => ({
|
||||
useEventContext: () => ({
|
||||
activeEvent: fixtures.event,
|
||||
selectEvent: selectEventMock,
|
||||
refetch: refetchMock,
|
||||
}),
|
||||
}));
|
||||
|
||||
@@ -245,7 +247,12 @@ vi.mock('../components/FormControls', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('../components/Sheet', () => ({
|
||||
MobileSheet: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
MobileSheet: ({ children, footer }: { children: React.ReactNode; footer?: React.ReactNode }) => (
|
||||
<div>
|
||||
{children}
|
||||
{footer}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
vi.mock('../components/Tag', () => ({
|
||||
@@ -336,4 +343,23 @@ describe('MobileEventTasksPage', () => {
|
||||
expect(screen.queryByLabelText('Add')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('refetches events after creating a task', async () => {
|
||||
refetchMock.mockClear();
|
||||
(api.createTask as unknown as { mockResolvedValueOnce: (value: any) => void }).mockResolvedValueOnce({ id: 99 });
|
||||
|
||||
render(<MobileEventTasksPage />);
|
||||
|
||||
expect(await screen.findByText('Photo tasks for guests')).toBeInTheDocument();
|
||||
|
||||
fireEvent.change(screen.getByPlaceholderText('z.B. Erstes Gruppenfoto'), {
|
||||
target: { value: 'New Task' },
|
||||
});
|
||||
|
||||
fireEvent.click(screen.getAllByRole('button', { name: 'Fotoaufgabe speichern' })[0]);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(refetchMock).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user