mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-20 22:01:45 +00:00
chore: apply prettier on the entire project
This commit is contained in:
@@ -1,23 +1,31 @@
|
||||
// FE-COMP-PLACEFORM-001 to FE-COMP-PLACEFORM-036
|
||||
import { render, screen, waitFor, fireEvent, within } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
import { buildAssignment, buildCategory, buildPlace, buildTrip, buildUser } from '../../../tests/helpers/factories';
|
||||
import { server } from '../../../tests/helpers/msw/server';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
import { usePermissionsStore } from '../../store/permissionsStore';
|
||||
import { fireEvent, render, screen, waitFor, within } from '../../../tests/helpers/render';
|
||||
import { resetAllStores, seedStore } from '../../../tests/helpers/store';
|
||||
import { buildUser, buildTrip, buildPlace, buildCategory, buildAssignment } from '../../../tests/helpers/factories';
|
||||
import { useAuthStore } from '../../store/authStore';
|
||||
import { usePermissionsStore } from '../../store/permissionsStore';
|
||||
import { useTripStore } from '../../store/tripStore';
|
||||
import PlaceFormModal from './PlaceFormModal';
|
||||
|
||||
// Mock CustomTimePicker so we get a simple text input instead of the portal-heavy UI
|
||||
vi.mock('../shared/CustomTimePicker', () => ({
|
||||
default: ({ value, onChange, placeholder }: { value: string; onChange: (v: string) => void; placeholder?: string }) => (
|
||||
default: ({
|
||||
value,
|
||||
onChange,
|
||||
placeholder,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
placeholder?: string;
|
||||
}) => (
|
||||
<input
|
||||
data-testid="time-picker"
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={e => onChange(e.target.value)}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
placeholder={placeholder ?? '00:00'}
|
||||
/>
|
||||
),
|
||||
@@ -146,7 +154,7 @@ describe('PlaceFormModal', () => {
|
||||
{...defaultProps}
|
||||
place={null}
|
||||
prefillCoords={{ lat: 48.8566, lng: 2.3522, name: 'Paris', address: 'Paris, France' }}
|
||||
/>,
|
||||
/>
|
||||
);
|
||||
expect(screen.getByDisplayValue('48.8566')).toBeInTheDocument();
|
||||
expect(screen.getByDisplayValue('Paris')).toBeInTheDocument();
|
||||
@@ -169,8 +177,8 @@ describe('PlaceFormModal', () => {
|
||||
http.post('/api/maps/search', () =>
|
||||
HttpResponse.json({
|
||||
places: [{ name: 'Eiffel Tower', address: 'Paris', lat: '48.8584', lng: '2.2945' }],
|
||||
}),
|
||||
),
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
render(<PlaceFormModal {...defaultProps} />);
|
||||
@@ -191,8 +199,8 @@ describe('PlaceFormModal', () => {
|
||||
http.post('/api/maps/search', () =>
|
||||
HttpResponse.json({
|
||||
places: [{ name: 'Eiffel Tower', address: 'Paris', lat: '48.8584', lng: '2.2945' }],
|
||||
}),
|
||||
),
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
render(<PlaceFormModal {...defaultProps} />);
|
||||
@@ -209,8 +217,8 @@ describe('PlaceFormModal', () => {
|
||||
http.post('/api/maps/search', () =>
|
||||
HttpResponse.json({
|
||||
places: [{ name: 'Eiffel Tower', address: 'Paris', lat: '48.8584', lng: '2.2945' }],
|
||||
}),
|
||||
),
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
render(<PlaceFormModal {...defaultProps} />);
|
||||
@@ -230,9 +238,7 @@ describe('PlaceFormModal', () => {
|
||||
window.__addToast = addToast;
|
||||
|
||||
const user = userEvent.setup();
|
||||
server.use(
|
||||
http.post('/api/maps/search', () => HttpResponse.json({ error: 'fail' }, { status: 500 })),
|
||||
);
|
||||
server.use(http.post('/api/maps/search', () => HttpResponse.json({ error: 'fail' }, { status: 500 })));
|
||||
|
||||
render(<PlaceFormModal {...defaultProps} />);
|
||||
const searchInput = screen.getByPlaceholderText('Search places...');
|
||||
@@ -240,11 +246,7 @@ describe('PlaceFormModal', () => {
|
||||
await user.keyboard('{Enter}');
|
||||
|
||||
await waitFor(() => {
|
||||
expect(addToast).toHaveBeenCalledWith(
|
||||
expect.stringMatching(/search failed/i),
|
||||
'error',
|
||||
undefined,
|
||||
);
|
||||
expect(addToast).toHaveBeenCalledWith(expect.stringMatching(/search failed/i), 'error', undefined);
|
||||
});
|
||||
|
||||
delete window.__addToast;
|
||||
@@ -320,7 +322,7 @@ describe('PlaceFormModal', () => {
|
||||
place={currentPlace}
|
||||
assignmentId={10}
|
||||
dayAssignments={[currentAssignment, otherAssignment]}
|
||||
/>,
|
||||
/>
|
||||
);
|
||||
|
||||
// English translation: 'places.timeCollision' = 'Time overlap with:'
|
||||
|
||||
Reference in New Issue
Block a user