mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
bafb74f872
Putting a multi-day tour on a day through any of the usual ways put the whole tour on that one day. Now the way it goes on is a choice: the whole tour on this day, or stage 1 on this day and each next stage on the next day of the trip. The day menu of the tour lists and the detail's "Add to day" ask in the same menu, as a second step after the day; a tour dragged onto a day, or added from a place where no menu asked, gets a small dialog on the desktop and a card on the phone. Only the trip's days are used: when fewer days are left than stages, the menu says up to which stage fits and the rest stay without a day. A stage already on a day moves to its new day, the whole tour comes off the days it was on, and a stage the route no longer has comes off too. The writes run in order through the store, the repo and the mutation queue, so they work offline, and one undo takes the spread back, the whole tour onto its day again. The plan lives in stageSpread.ts, the writes and the question in useTourDayChoice, which every way onto a day now passes through on both the desktop and the phone.
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
// FE-TOUR-STAGE-SPREAD-022 to FE-TOUR-STAGE-SPREAD-023: on the phone, a multi-day tour put on a day
|
|
// asks the same two ways as the desktop, whole or a stage a day from it on (MDT-02).
|
|
import { fireEvent } from '@testing-library/react';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import type { TourDayQuestion } from '../../../../src/components/Tours/stages/stageSpread';
|
|
import MTourDayChoiceSheet from '../../../../src/mobile/screens/trip/sheets/MTourDayChoiceSheet';
|
|
import { render, screen } from '../../../helpers/render';
|
|
|
|
const question: TourDayQuestion = {
|
|
placeId: 81,
|
|
dayId: 4,
|
|
day: 2,
|
|
name: 'Hut to hut',
|
|
count: 3,
|
|
fit: 3,
|
|
wholeFree: true,
|
|
};
|
|
|
|
describe('MTourDayChoiceSheet', () => {
|
|
it('FE-TOUR-STAGE-SPREAD-022: names the day and the tour, and answers with the way chosen', () => {
|
|
const onAnswer = vi.fn();
|
|
render(<MTourDayChoiceSheet question={question} onAnswer={onAnswer} />);
|
|
expect(screen.getByText('Day 2: Hut to hut')).toBeInTheDocument();
|
|
expect(screen.getByText('3 stages')).toBeInTheDocument();
|
|
expect(screen.getByText('Stage 1 on this day, each next stage on the day after.')).toBeInTheDocument();
|
|
fireEvent.click(screen.getByTestId('m-tour-day-choice-whole'));
|
|
expect(onAnswer).toHaveBeenLastCalledWith('whole');
|
|
fireEvent.click(screen.getByTestId('m-tour-day-choice-stages'));
|
|
expect(onAnswer).toHaveBeenLastCalledWith('stages');
|
|
fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
|
|
expect(onAnswer).toHaveBeenLastCalledWith(null);
|
|
});
|
|
|
|
it('FE-TOUR-STAGE-SPREAD-023: a day that holds the tour offers only the stages', () => {
|
|
render(<MTourDayChoiceSheet question={{ ...question, wholeFree: false }} onAnswer={vi.fn()} />);
|
|
expect(screen.getByTestId('m-tour-day-choice-whole')).toBeDisabled();
|
|
expect(screen.getByTestId('m-tour-day-choice-stages')).toBeEnabled();
|
|
});
|
|
});
|