Enforce task limits and update event form
This commit is contained in:
@@ -60,8 +60,8 @@ vi.mock('../components/Primitives', () => ({
|
||||
|
||||
vi.mock('../components/FormControls', () => ({
|
||||
MobileField: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
MobileDateTimeInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => (
|
||||
<input type="datetime-local" {...props} />
|
||||
MobileDateInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => (
|
||||
<input type="date" {...props} />
|
||||
),
|
||||
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
|
||||
MobileSelect: ({ children, ...props }: { children: React.ReactNode }) => <select {...props}>{children}</select>,
|
||||
@@ -116,7 +116,7 @@ vi.mock('../../context/EventContext', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
import { getEvent, getEventTypes } from '../../api';
|
||||
import { createEvent, getEvent, getEventTypes } from '../../api';
|
||||
import MobileEventFormPage from '../EventFormPage';
|
||||
|
||||
describe('MobileEventFormPage', () => {
|
||||
@@ -124,16 +124,21 @@ describe('MobileEventFormPage', () => {
|
||||
paramsState.slug = undefined;
|
||||
});
|
||||
|
||||
it('renders a save draft button when creating a new event', async () => {
|
||||
it('renders a create button when creating a new event', async () => {
|
||||
paramsState.slug = undefined;
|
||||
vi.mocked(createEvent).mockResolvedValueOnce({
|
||||
event: { id: 1, slug: 'new-event' },
|
||||
} as any);
|
||||
await act(async () => {
|
||||
render(<MobileEventFormPage />);
|
||||
});
|
||||
|
||||
const saveDraft = screen.getByText('eventForm.actions.saveDraft');
|
||||
fireEvent.click(saveDraft);
|
||||
const buttons = screen.getAllByText('eventForm.actions.create');
|
||||
await act(async () => {
|
||||
fireEvent.click(buttons[0]);
|
||||
});
|
||||
|
||||
expect(backMock).toHaveBeenCalled();
|
||||
expect(createEvent).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('defaults event type to wedding when available', async () => {
|
||||
@@ -167,7 +172,7 @@ describe('MobileEventFormPage', () => {
|
||||
|
||||
render(<MobileEventFormPage />);
|
||||
|
||||
const dateInput = await screen.findByDisplayValue('2020-01-01T10:00');
|
||||
const dateInput = await screen.findByDisplayValue('2020-01-01');
|
||||
expect(dateInput).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user