fix(planner): bookings a collaborator moves on a day take their new slots in every open list

reservation:positions was on the ignored list, while the stop order the same
reorder sends was applied, so in other tabs and for other members the bookings
sat between the wrong stops until a reload. The event now writes the slots the
way the mover's own list did, for the day it names (day_id from REST, dayId
from the MCP tool) or as the global slot without one, and caches them offline.

A booking handed back by an edit or a reservation:updated event without day
slots keeps the ones it had, in the store and in the offline cache.

Refs #2631
This commit is contained in:
Maurice
2026-10-12 12:33:19 +02:00
parent 12f08e3646
commit 93173b1573
7 changed files with 136 additions and 8 deletions
@@ -97,4 +97,63 @@ describe('remoteEventHandler > reservations', () => {
});
expect(useTripStore.getState().reservations[0].travelers).toBeUndefined();
});
// #2631: a collaborator moving a booking on a day sends only the new slots. Ignored,
// their stops arrived in the new order and the bookings stayed between the old ones.
it('FE-WSEVT-RESERV-009: reservation:positions with day_id writes the slot for that day', () => {
useTripStore.setState({
reservations: [buildReservation({ id: 1, day_positions: { 7: 0.5 } }), buildReservation({ id: 2 })],
});
useTripStore.getState().handleRemoteEvent({
type: 'reservation:positions',
positions: [{ id: 1, day_plan_position: 2.5 }],
day_id: 8,
});
const [moved, other] = useTripStore.getState().reservations;
expect(moved.day_positions).toEqual({ 7: 0.5, 8: 2.5 });
expect(moved.day_plan_position).toBe(2.5);
expect(other.day_positions).toBeUndefined();
});
it('FE-WSEVT-RESERV-010: reservation:positions from the MCP tool names the day dayId', () => {
useTripStore.setState({ reservations: [buildReservation({ id: 1 })] });
useTripStore.getState().handleRemoteEvent({
type: 'reservation:positions',
positions: [{ id: 1, day_plan_position: 3 }],
dayId: 4,
});
expect(useTripStore.getState().reservations[0].day_positions).toEqual({ 4: 3 });
});
it('FE-WSEVT-RESERV-011: reservation:positions without a day moves the global slot only', () => {
useTripStore.setState({ reservations: [buildReservation({ id: 1, day_positions: { 4: 1 } })] });
useTripStore.getState().handleRemoteEvent({
type: 'reservation:positions',
positions: [{ id: 1, day_plan_position: 6.5 }, { id: 1 }],
day_id: undefined,
});
const [r] = useTripStore.getState().reservations;
expect(r.day_plan_position).toBe(6.5);
expect(r.day_positions).toEqual({ 4: 1 });
});
it('FE-WSEVT-RESERV-012: reservation:updated without day slots keeps the ones the booking had', () => {
useTripStore.setState({ reservations: [buildReservation({ id: 1, day_positions: { 4: 1.5 } })] });
useTripStore.getState().handleRemoteEvent({
type: 'reservation:updated',
reservation: buildReservation({ id: 1, title: 'Train (rebooked)' }),
});
const [r] = useTripStore.getState().reservations;
expect(r.title).toBe('Train (rebooked)');
expect(r.day_positions).toEqual({ 4: 1.5 });
});
it('FE-WSEVT-RESERV-013: reservation:updated with day slots takes them, null included', () => {
useTripStore.setState({ reservations: [buildReservation({ id: 1, day_positions: { 4: 1.5 } })] });
useTripStore.getState().handleRemoteEvent({
type: 'reservation:updated',
reservation: buildReservation({ id: 1, day_positions: null }),
});
expect(useTripStore.getState().reservations[0].day_positions).toBeNull();
});
});