From 46a2fd2bbbf3edc43e33e24e74539ebdeff67878 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 28 Nov 2026 00:33:27 +0100 Subject: [PATCH] fix(mobile): place a timed stop moved to another day among every stored row of that day The slot is counted over the stored rows, booked nights and hidden service stops included, as the desktop move does, so the stop no longer lands ahead of them. --- .../screens/trip/sheets/MPlaceSheet.tsx | 2 +- .../unit/mobile/trip/MPlaceSheet.test.tsx | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx index a7cf1ed2e..1c6df3821 100644 --- a/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx +++ b/client/src/mobile/screens/trip/sheets/MPlaceSheet.tsx @@ -99,7 +99,7 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) { // Lands where its time belongs on the new day, as a move on the desktop does; // without a time it goes to the end. const moveToDay = ({ assignment, fromDayId }: { assignment: Assignment; fromDayId: number }, toDayId: number) => { - const slot = timedSlot(planner.assignments[String(toDayId)] || [], planner.tripAccommodations, assignment.place?.place_time) ?? undefined + const slot = timedSlot(planner.storedAssignments[String(toDayId)] || [], planner.tripAccommodations, assignment.place?.place_time) ?? undefined planner.handleMoveToDay(assignment.id, fromDayId, toDayId, slot) .catch((err: unknown) => planner.toast.error(err instanceof Error ? err.message : t('common.unknownError'))) } diff --git a/client/tests/unit/mobile/trip/MPlaceSheet.test.tsx b/client/tests/unit/mobile/trip/MPlaceSheet.test.tsx index 8fc28f228..6112679f7 100644 --- a/client/tests/unit/mobile/trip/MPlaceSheet.test.tsx +++ b/client/tests/unit/mobile/trip/MPlaceSheet.test.tsx @@ -13,7 +13,7 @@ import type { Assignment, Category, Day, Place, TripFile, TripMember } from '../ import { resetAllStores, seedStore } from '../../../helpers/store' import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render' -// FE-MOB-PLSH-001 to FE-MOB-PLSH-033 +// FE-MOB-PLSH-001 to FE-MOB-PLSH-036 vi.mock('../../../../src/utils/fileDownload', () => ({ openFile: vi.fn() })) // The gallery says "no pictures" through the shared toast, the sheet's own writes through planner.toast. @@ -95,6 +95,7 @@ function makePlanner(overrides: Record = {}) { days: DAYS, categories: CATEGORIES, assignments: { '2': [dayAssignment(11, 2)] }, + storedAssignments: { '2': [dayAssignment(11, 2)] }, files: FILES, canUploadFiles: true, selectedPlace: PLACE, @@ -270,6 +271,22 @@ describe('MPlaceSheet', () => { expect(screen.queryByText('May 1')).not.toBeInTheDocument() }) + it('FE-MOB-PLSH-036: a timed stop moved to another day takes its slot among the stored rows, hidden ones included', () => { + const handleMoveToDay = vi.fn().mockResolvedValue(undefined) + const timed = { ...dayAssignment(11, 2), place: { ...dayAssignment(11, 2).place, place_time: '10:00' } } as Assignment + const lodging = { id: 30, day_id: 3, place_id: 300, order_index: 0, accommodation_id: 7, place: { id: 300, name: 'Hotel' } } as unknown as Assignment + const early = { id: 31, day_id: 3, place_id: 301, order_index: 1, place: { id: 301, name: 'Cafe', place_time: '09:00' } } as unknown as Assignment + renderSheet(makePlanner({ + handleMoveToDay, + tripAccommodations: [{ id: 7, check_in: null }], + assignments: { '2': [timed], '3': [early] }, + storedAssignments: { '2': [timed], '3': [lodging, early] }, + })) + fireEvent.click(screen.getByRole('button', { name: 'Move to another day' })) + fireEvent.click(screen.getByText('Day 3')) + expect(handleMoveToDay).toHaveBeenCalledWith(11, 2, 3, 2) + }) + it('FE-MOB-PLSH-011: treats an assignment without participants as everyone joined', async () => { vi.spyOn(assignmentsApi, 'setParticipants').mockResolvedValue({ participants: [{ user_id: 2, username: 'bob' }] }) renderSheet()