refactor(planner): split the tour day time growth out of four size-capped files

The place form's time section moves into PlaceFormTimeSection, its tour test
into PlaceFormModal.tour.test.tsx over a shared tests/helpers/placeForm setup,
the page hook hands the place form its close, day plan and tour, and the day
plan's surface classes and tones move into dayPlanSurfaces. The size baseline
drops to the new counts.
This commit is contained in:
Maurice
2026-10-20 22:02:48 +02:00
parent e6002444a1
commit 786df612fd
10 changed files with 268 additions and 152 deletions
@@ -0,0 +1,51 @@
// FE-PLANNER-PLACEFORM-125: the place form of a tour (TIME-02)
import type { TourListItem } from '@trek/shared';
import { buildAssignment, buildPlace } from '../../../tests/helpers/factories';
import { placeFormProps, seedPlaceFormStores } from '../../../tests/helpers/placeForm';
import { render, screen } from '../../../tests/helpers/render';
import { resetAllStores } from '../../../tests/helpers/store';
import PlaceFormModal from './PlaceFormModal';
// CustomTimePicker as a plain text input, see TimePickerStub.
vi.mock('../shared/CustomTimePicker', async () => ({
default: (await import('../../../tests/helpers/placeForm')).TimePickerStub,
}));
beforeEach(() => {
resetAllStores();
seedPlaceFormStores();
});
describe('PlaceFormModal for a tour', () => {
it('FE-PLANNER-PLACEFORM-125: a tour with a start and no end says below its times the end it works out to (TIME-02)', () => {
const place = buildPlace({ id: 7, name: 'Ridge', place_time: '09:00', end_time: null });
const assignment = buildAssignment({ id: 42, day_id: 3, place });
const tour: TourListItem = {
place_id: 7,
name: 'Ridge',
tour_type: 'hike',
distance: 8,
elevation_gain: 300,
elevation_loss: 300,
duration: 150,
planned_duration_minutes: null,
break_additional_minutes: 30,
difficulty: null,
wanderer_ref: null,
match_confidence: 1,
max_hiking_difficulty: 2,
planned: true,
caution: false,
};
const { unmount } = render(
<PlaceFormModal {...placeFormProps} place={place} assignmentId={42} dayAssignments={[assignment]} tour={tour} />
);
expect(screen.getByTestId('tour-day-end-hint')).toHaveTextContent(
'Left empty, the end is worked out: 12:00, the start plus the tour time of 3 h.'
);
unmount();
render(<PlaceFormModal {...placeFormProps} place={place} assignmentId={42} dayAssignments={[assignment]} />);
expect(screen.queryByTestId('tour-day-end-hint')).not.toBeInTheDocument();
});
});