Files
TREK/client/src/components/Planner/DayPlanSidebar.multiDayMove.test.ts
T
Maurice 31859651d7 feat(help): rewrite the help center for v5 with a Tours section, new pictures in every language, and fix the tour planner bugs it surfaced
Every help screen checked against the v5 redesign. Tours is documented for
the first time, as a screen of its own with twelve screens under it, and
notifications get help of their own. All pictures are taken again on a
realistic demo trip, with short loops where a still cannot show the motion.
The English is plain and every language is written naturally rather than
word for word.

The switcher shows two levels at most, a screen's overview lists its
sub-screens as cards above its guides, each wiki page is linked once, and
the help sidebar is wider.

Fixes found along the way: Save to Collection keeps a tour's route, a track
dropped on the places column opens the Tours import, tour Share on desktop,
the unsaved tour draft lives on the account, a route click no longer adds
an end point, Trip places leaves the trip's tours out, Escape closes a
stage's day menu, confirms before destructive deletes, DWD warnings sharing
one id kept apart, a booking's date moves with it, and smaller fixes across
notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and
the admin screens.
2026-10-22 22:29:35 +02:00

87 lines
3.2 KiB
TypeScript

// FE-PLANNER-DAYPLAN-117/118: where a booking lands when one of its rows is dropped on another
// day. FE-PLANNER-DAYPLAN-116 in DayPlanSidebar.test.tsx still drives the same move through a
// real drag and drop, so the wiring stays covered there.
import { describe, expect, it } from 'vitest';
import { buildDay, buildReservation } from '../../../tests/helpers/factories';
import { computeMultiDayMove, computeMultiDayMoveIds, getDayOrder } from './DayPlanSidebar.multiDayMove';
const fourDays = () =>
[9, 10, 11, 12].map((id, i) => buildDay({ id, day_number: i + 1, date: `2025-06-0${i + 1}`, title: `Day ${i + 1}` }));
const longFlight = () =>
buildReservation({
id: 400,
type: 'flight',
title: 'Long flight',
day_id: 10,
end_day_id: 12,
reservation_time: '2025-06-02T10:00:00',
});
describe('computeMultiDayMove', () => {
it('FE-PLANNER-DAYPLAN-117: dragging a span end before its start collapses it, otherwise it just shortens', () => {
const days = fourDays();
// The end stays after the start, so only the end day changes and the start time stays put.
expect(computeMultiDayMove(days, longFlight(), 11, 'end')).toEqual({ day_id: 10, end_day_id: 11 });
// Day 1 sits before the start, so the booking collapses onto it and its time follows.
expect(computeMultiDayMove(days, longFlight(), 9, 'end')).toEqual({
day_id: 9,
end_day_id: 9,
reservation_time: '2025-06-01T10:00:00',
});
});
it('FE-PLANNER-DAYPLAN-118: a single-day booking dragged to another day moves wholesale', () => {
const days = [
buildDay({ id: 10, date: '2025-06-01', title: 'Day 1' }),
buildDay({ id: 11, date: '2025-06-02', title: 'Day 2' }),
];
const train = buildReservation({
id: 401,
type: 'train',
title: 'Regional train',
day_id: 10,
reservation_time: '2025-06-01T10:00:00',
});
expect(computeMultiDayMove(days, train, 11, 'single')).toEqual({
day_id: 11,
end_day_id: 11,
reservation_time: '2025-06-02T10:00:00',
});
});
it('moves the end time with the end day and leaves a time without a date alone', () => {
const days = fourDays();
const stay = buildReservation({
id: 402,
day_id: 10,
end_day_id: 11,
reservation_time: '10:00',
reservation_end_time: '2025-06-03T09:00:00',
});
expect(computeMultiDayMove(days, stay, 12, 'end')).toEqual({
day_id: 10,
end_day_id: 12,
reservation_end_time: '2025-06-04T09:00:00',
});
expect(computeMultiDayMove(days, stay, 9, 'start')).toEqual({ day_id: 9, end_day_id: 11 });
});
it('dragging a span start past its end collapses the booking onto the target day', () => {
expect(computeMultiDayMoveIds(fourDays(), { ...longFlight(), day_id: 9, end_day_id: 10 }, 12, 'start')).toEqual({
day_id: 12,
end_day_id: 12,
});
});
});
describe('getDayOrder', () => {
it('reads the day number and falls back to the position in the list', () => {
const days = fourDays();
expect(getDayOrder(days, days[2])).toBe(3);
const unnumbered = { ...days[1], day_number: undefined };
expect(getDayOrder([days[0], unnumbered], unnumbered)).toBe(1);
});
});