mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(bookings): client test failures after map overlay refactor
- Make useEndpointPane tolerant when map mock lacks getPane/createPane - Add useMapEvents to react-leaflet mock in MapView.test - Rewrite RESMODAL-042 to use the new AirportSelect flow (airline and flight number only; airport codes are now saved as endpoints, not metadata)
This commit is contained in:
@@ -32,6 +32,7 @@ vi.mock('react-leaflet', () => ({
|
|||||||
off: vi.fn(),
|
off: vi.fn(),
|
||||||
panBy: vi.fn(),
|
panBy: vi.fn(),
|
||||||
}),
|
}),
|
||||||
|
useMapEvents: () => ({}),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
vi.mock('react-leaflet-cluster', () => ({
|
vi.mock('react-leaflet-cluster', () => ({
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const TYPE_META: Record<TransportType, { color: string; icon: typeof Plane; geod
|
|||||||
function useEndpointPane() {
|
function useEndpointPane() {
|
||||||
const map = useMap()
|
const map = useMap()
|
||||||
useMemo(() => {
|
useMemo(() => {
|
||||||
|
if (typeof map?.getPane !== 'function' || typeof map?.createPane !== 'function') return
|
||||||
if (!map.getPane(ENDPOINT_PANE)) {
|
if (!map.getPane(ENDPOINT_PANE)) {
|
||||||
const pane = map.createPane(ENDPOINT_PANE)
|
const pane = map.createPane(ENDPOINT_PANE)
|
||||||
pane.style.zIndex = '650'
|
pane.style.zIndex = '650'
|
||||||
|
|||||||
@@ -575,16 +575,14 @@ describe('ReservationModal', () => {
|
|||||||
expect(screen.queryByPlaceholderText('0.00')).not.toBeInTheDocument();
|
expect(screen.queryByPlaceholderText('0.00')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('FE-PLANNER-RESMODAL-042: flight type metadata saved with airline and airports', async () => {
|
it('FE-PLANNER-RESMODAL-042: flight type metadata saved with airline and flight number', async () => {
|
||||||
const onSave = vi.fn().mockResolvedValue(undefined);
|
const onSave = vi.fn().mockResolvedValue(undefined);
|
||||||
render(<ReservationModal {...defaultProps} onSave={onSave} />);
|
render(<ReservationModal {...defaultProps} onSave={onSave} />);
|
||||||
|
|
||||||
await userEvent.click(screen.getByRole('button', { name: /Flight/i }));
|
await userEvent.click(screen.getByRole('button', { name: /Flight/i }));
|
||||||
await userEvent.type(screen.getByPlaceholderText(/e\.g\. Lufthansa/i), 'AF 447');
|
await userEvent.type(screen.getByPlaceholderText(/e\.g\. Lufthansa/i), 'AF 447 CDG → JFK');
|
||||||
await userEvent.type(screen.getByPlaceholderText('Lufthansa'), 'Air France');
|
await userEvent.type(screen.getByPlaceholderText('Lufthansa'), 'Air France');
|
||||||
await userEvent.type(screen.getByPlaceholderText('LH 123'), 'AF 447');
|
await userEvent.type(screen.getByPlaceholderText('LH 123'), 'AF 447');
|
||||||
await userEvent.type(screen.getByPlaceholderText('FRA'), 'CDG');
|
|
||||||
await userEvent.type(screen.getByPlaceholderText('NRT'), 'JFK');
|
|
||||||
|
|
||||||
await userEvent.click(screen.getByRole('button', { name: /^Add$/i }));
|
await userEvent.click(screen.getByRole('button', { name: /^Add$/i }));
|
||||||
|
|
||||||
@@ -595,8 +593,6 @@ describe('ReservationModal', () => {
|
|||||||
metadata: expect.objectContaining({
|
metadata: expect.objectContaining({
|
||||||
airline: 'Air France',
|
airline: 'Air France',
|
||||||
flight_number: 'AF 447',
|
flight_number: 'AF 447',
|
||||||
departure_airport: 'CDG',
|
|
||||||
arrival_airport: 'JFK',
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user