fix(planner): booking codes stay blurred in the edit forms too

With "Blur booking codes" on, the bookings list and the transport details
hid a code, but opening the same booking to edit it printed the code in
the clear: the reservation and transport forms with every per-segment
code of a flight or train, the hotel editor in the day panel and the
three phone sheets. The stay's own code in the day panel, the booking
strip in the place inspector and the booking lines under a stay and a
stop on the phone showed it plainly as well.

One shared BookingCodeInput and BlurredCode now carry the setting to all
of them. A filled code field stays blurred until it is hovered or
focused, so clicking, tapping or tabbing into it still reveals the code
for editing, and the value is saved exactly as typed. With the setting
off nothing changes, and the PDF export and the share pages stay as
they were.
This commit is contained in:
Maurice
2026-09-22 21:09:25 +02:00
parent 93dddaa4af
commit bb515ac3cc
22 changed files with 769 additions and 35 deletions
@@ -4,9 +4,11 @@ import MAccommodationSheet from '../../../../src/mobile/screens/trip/sheets/MAcc
import type { Accommodation, Category, Day, Place } from '../../../../src/types'
import { buildPlanner, buildShell } from '../../../helpers/mobileTrip'
import { resetAllStores } from '../../../helpers/store'
import { useSettingsStore } from '../../../../src/store/settingsStore'
import { isBlurred } from '../../../helpers/bookingCodeBlur'
import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render'
// FE-MOB-ACCSH-001 to FE-MOB-ACCSH-025
// FE-MOB-ACCSH-001 to FE-MOB-ACCSH-029
// The pickers have their own suites; here they only need to be addressable, so
// they render as plain controls. data-value keeps the requested value readable
@@ -352,4 +354,45 @@ describe('MAccommodationSheet', () => {
expect(shell.openSheet).not.toHaveBeenCalled()
expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled()
})
// ── Blur booking codes in the stay editor (#2457) ──────────────────────────
describe('blur booking codes (#2457)', () => {
/** Both sources the phone reads the preference from: the settings store and planner.settings. */
function plannerWithBlur(on: boolean) {
useSettingsStore.setState({ settings: { ...useSettingsStore.getState().settings, blur_booking_codes: on } })
return makePlanner({
settings: { time_format: '24h', date_format: 'DD.MM.YYYY', default_currency: 'EUR', distance_unit: 'km', blur_booking_codes: on },
})
}
const codeField = () => screen.getByPlaceholderText('ABC-12345') as HTMLInputElement
it('FE-MOB-ACCSH-026: the confirmation field of an edited stay is blurred while the setting is on', () => {
setup(plannerWithBlur(true), makeShell({ dayId: 12, accId: 77 }))
expect(codeField()).toHaveValue('ABC-1')
expect(isBlurred(codeField())).toBe(true)
})
it('FE-MOB-ACCSH-027: focusing the field reveals the code for editing, leaving it hides it again', () => {
setup(plannerWithBlur(true), makeShell({ dayId: 12, accId: 77 }))
const field = codeField()
act(() => field.focus())
expect(isBlurred(field)).toBe(false)
act(() => field.blur())
expect(isBlurred(field)).toBe(true)
})
it('FE-MOB-ACCSH-028: with the setting off the code stays plain', () => {
setup(plannerWithBlur(false), makeShell({ dayId: 12, accId: 77 }))
expect(isBlurred(codeField())).toBe(false)
})
it('FE-MOB-ACCSH-029: a blurred code still saves unchanged', async () => {
const update = vi.spyOn(accommodationsApi, 'update').mockResolvedValue({})
setup(plannerWithBlur(true), makeShell({ dayId: 12, accId: 77 }))
fireEvent.click(screen.getByRole('button', { name: 'Save' }))
await waitFor(() => expect(update).toHaveBeenCalled())
expect(update.mock.calls[0][2]).toMatchObject({ confirmation: 'ABC-1' })
})
})
})
@@ -9,8 +9,9 @@ import { useTripStore } from '../../../../src/store/tripStore'
import type { Accommodation, Assignment, Day, DayNote, Reservation } from '../../../../src/types'
import { resetAllStores, seedStore } from '../../../helpers/store'
import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render'
import { isBlurred } from '../../../helpers/bookingCodeBlur'
// FE-MOB-DAYSH-001 to FE-MOB-DAYSH-028
// FE-MOB-DAYSH-001 to FE-MOB-DAYSH-030
const DAYS = [
{ id: 1, trip_id: 5, day_number: 1, date: '2026-05-01', title: null },
@@ -418,4 +419,22 @@ describe('MDaySheet', () => {
await renderSheet(makePlanner({ days, tripAccommodations: [] }))
expect(screen.getByRole('dialog', { name: 'Day 2' })).toBeInTheDocument()
})
// ── Blur booking codes on the stay tile (#2457) ────────────────────────────
it('FE-MOB-DAYSH-029: with the blur on, the linked booking code under the stay is blurred like the stay code', async () => {
seedStore(useSettingsStore, { settings: { blur_booking_codes: true } })
await renderSheet()
// The stay's own code already honours the setting ...
expect(isBlurred(screen.getByText('ABC123'))).toBe(true)
// ... the linked booking's code right below it did not.
expect(isBlurred(screen.getByText(/#X9/))).toBe(true)
})
it('FE-MOB-DAYSH-030: with the blur off both codes stay plain', async () => {
seedStore(useSettingsStore, { settings: { blur_booking_codes: false } })
await renderSheet()
expect(isBlurred(screen.getByText('ABC123'))).toBe(false)
expect(isBlurred(screen.getByText(/#X9/))).toBe(false)
})
})
@@ -1,5 +1,7 @@
import { describe, expect, it, vi } from 'vitest'
import { fireEvent, render, screen } from '../../../helpers/render'
import { useSettingsStore } from '../../../../src/store/settingsStore'
import { isBlurred } from '../../../helpers/bookingCodeBlur'
import {
ConnRow, HotelConnRow, NoteRow, PlaceRow, PlanScheduleRow, ReorderStack, TransitRow, TransportRow,
} from '../../../../src/mobile/screens/trip/plan/MPlanTimelineRows'
@@ -7,7 +9,7 @@ import type { TransitMeta, TransportEntry } from '../../../../src/mobile/screens
import type { PluginDayScheduleItem } from '../../../../src/api/client'
import type { Assignment, DayNote, Place, Reservation, RouteSegment, TranslationFn } from '../../../../src/types'
// FE-MOB-PLROW-001 to FE-MOB-PLROW-041
// FE-MOB-PLROW-001 to FE-MOB-PLROW-044
// Same echo strategy as tests/helpers/mobileTrip: assertions stay on keys, not copy.
const t: TranslationFn = (key, params) =>
@@ -531,3 +533,42 @@ describe('NoteRow', () => {
expect(onEdit).toHaveBeenCalledTimes(1)
})
})
// ── Blur booking codes on the plan row (#2457) ────────────────────────────────
describe('PlaceRow blur booking codes (#2457)', () => {
const props = {
assignment: assignment(),
fullPlace: undefined,
chrome: chrome(),
reorder: REORDER,
onOpen: vi.fn(),
onEdit: vi.fn(),
onRemove: vi.fn(),
}
const blurOn = (on: boolean) =>
useSettingsStore.setState({ settings: { ...useSettingsStore.getState().settings, blur_booking_codes: on } })
it('FE-MOB-PLROW-042: the booking code in the row subtitle is blurred while the setting is on', () => {
blurOn(true)
const linkedRes = { id: 31, status: 'confirmed', confirmation_number: 'ROW-SECRET' } as unknown as Reservation
render(<PlaceRow {...props} linkedReservations={[linkedRes]} />)
expect(isBlurred(screen.getByText(/ROW-SECRET/))).toBe(true)
})
it('FE-MOB-PLROW-043: the extra booking lines of a stop with several bookings blur their codes too', () => {
blurOn(true)
const first = { id: 31, title: 'Lunch', status: 'confirmed', confirmation_number: 'ROW-ONE' } as unknown as Reservation
const second = { id: 32, title: 'Tour', status: 'pending', confirmation_number: 'ROW-TWO' } as unknown as Reservation
render(<PlaceRow {...props} linkedReservations={[first, second]} />)
expect(isBlurred(screen.getByText(/ROW-ONE/))).toBe(true)
expect(isBlurred(screen.getByText(/ROW-TWO/))).toBe(true)
})
it('FE-MOB-PLROW-044: with the setting off the code stays plain', () => {
blurOn(false)
const linkedRes = { id: 31, status: 'confirmed', confirmation_number: 'ROW-PLAIN' } as unknown as Reservation
render(<PlaceRow {...props} linkedReservations={[linkedRes]} />)
expect(isBlurred(screen.getByText(/ROW-PLAIN/))).toBe(false)
})
})
@@ -2,12 +2,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import MReservationSheet from '../../../../src/mobile/screens/trip/sheets/MReservationSheet'
import { useAddonStore } from '../../../../src/store/addonStore'
import { useTripStore } from '../../../../src/store/tripStore'
import { useSettingsStore } from '../../../../src/store/settingsStore'
import { isBlurred } from '../../../helpers/bookingCodeBlur'
import type { Accommodation, Assignment, Day, Place, Reservation, TripMember } from '../../../../src/types'
import { buildPlanner } from '../../../helpers/mobileTrip'
import { resetAllStores } from '../../../helpers/store'
import { fireEvent, render, screen, waitFor } from '../../../helpers/render'
import { act, fireEvent, render, screen, waitFor } from '../../../helpers/render'
// FE-MOB-RESSH-001 to FE-MOB-RESSH-051
// FE-MOB-RESSH-001 to FE-MOB-RESSH-061
// Date/time/select pickers have their own suites — here they only have to be
// addressable, so they render as plain controls.
@@ -807,4 +809,46 @@ describe('MReservationSheet', () => {
expect(titleField()).toHaveValue('Cafe Central')
expect(screen.getByPlaceholderText('reservations.locationPlaceholder')).toHaveValue('Manual 3')
})
// ── Blur booking codes in the edit sheet (#2457) ───────────────────────────
describe('blur booking codes (#2457)', () => {
/** Both sources the phone reads the preference from: the settings store and planner.settings. */
function plannerWithBlur(on: boolean, overrides: Record<string, unknown> = {}) {
useSettingsStore.setState({ settings: { ...useSettingsStore.getState().settings, blur_booking_codes: on } })
return makePlanner({
settings: { time_format: '24h', date_format: 'DD.MM.YYYY', default_currency: 'EUR', distance_unit: 'km', blur_booking_codes: on },
...overrides,
})
}
const codeField = () => screen.getByPlaceholderText('reservations.confirmationPlaceholder') as HTMLInputElement
it('FE-MOB-RESSH-058: the booking code field is blurred while the setting is on', () => {
setup(plannerWithBlur(true, { editingReservation: DINNER }))
expect(codeField()).toHaveValue('C1')
expect(isBlurred(codeField())).toBe(true)
})
it('FE-MOB-RESSH-059: focusing the field reveals the code for editing, leaving it hides it again', () => {
setup(plannerWithBlur(true, { editingReservation: DINNER }))
const field = codeField()
expect(isBlurred(field)).toBe(true)
act(() => field.focus())
expect(isBlurred(field)).toBe(false)
act(() => field.blur())
expect(isBlurred(field)).toBe(true)
})
it('FE-MOB-RESSH-060: with the setting off the code stays plain', () => {
setup(plannerWithBlur(false, { editingReservation: DINNER }))
expect(isBlurred(codeField())).toBe(false)
})
it('FE-MOB-RESSH-061: a blurred code still saves unchanged', async () => {
const { planner } = setup(plannerWithBlur(true, { editingReservation: DINNER }))
fireEvent.click(submitBtn())
await waitFor(() => expect(planner.handleSaveReservation).toHaveBeenCalled())
expect(savedPayload(planner).confirmation_number).toBe('C1')
})
})
})
@@ -3,12 +3,14 @@ import MTransportFormSheet from '../../../../src/mobile/screens/trip/sheets/MTra
import type { TripPlanner } from '../../../../src/mobile/screens/trip/MTripShell'
import { useAddonStore } from '../../../../src/store/addonStore'
import { useTripStore } from '../../../../src/store/tripStore'
import { useSettingsStore } from '../../../../src/store/settingsStore'
import { isBlurred } from '../../../helpers/bookingCodeBlur'
import type { Day, Reservation, TripMember } from '../../../../src/types'
import { buildPlanner } from '../../../helpers/mobileTrip'
import { resetAllStores, seedStore } from '../../../helpers/store'
import { act, fireEvent, render, screen } from '../../../helpers/render'
// FE-MOB-TRFRM-001 to FE-MOB-TRFRM-048
// FE-MOB-TRFRM-001 to FE-MOB-TRFRM-052
//
// The sheet's own pickers (airport/location search, day select, time picker) and
// the embedded transit panel are replaced by minimal controlled stand-ins so the
@@ -957,4 +959,66 @@ describe('MTransportFormSheet', () => {
fireEvent.click(screen.getByRole('button', { name: 'reservations.type.bus' }))
expect(daySelects().map(s => s.value)).toEqual(['13', '13'])
})
// ── Blur booking codes in the edit sheet (#2457) ───────────────────────────
describe('blur booking codes (#2457)', () => {
/** Both sources the phone reads the preference from: the settings store and planner.settings. */
function plannerWithBlur(on: boolean, overrides: Record<string, unknown> = {}) {
useSettingsStore.setState({ settings: { ...useSettingsStore.getState().settings, blur_booking_codes: on } })
return makePlanner({
settings: { time_format: '24h', date_format: 'DD.MM.YYYY', default_currency: 'EUR', distance_unit: 'km', blur_booking_codes: on },
...overrides,
})
}
const codeFields = () => screen.getAllByPlaceholderText('reservations.confirmationPlaceholder') as HTMLInputElement[]
const layover = () => ({
id: 45, trip_id: 1, type: 'flight', title: 'FRA-IST-HND', status: 'pending',
day_id: 11, end_day_id: 12, confirmation_number: 'BOOK1',
metadata: {
legs: [
{ from: 'FRA', to: 'IST', confirmation_number: 'ABC123', dep_day_id: 11, dep_time: '10:20', arr_day_id: 11, arr_time: '14:05' },
{ from: 'IST', to: 'HND', confirmation_number: 'XYZ789', dep_day_id: 11, dep_time: '16:30', arr_day_id: 12, arr_time: '09:00' },
],
},
endpoints: [
{ id: 1, reservation_id: 45, role: 'from', sequence: 0, name: 'Frankfurt (FRA)', code: 'FRA', lat: 50.03, lng: 8.57, timezone: 'Europe/Berlin', local_date: null, local_time: null },
{ id: 2, reservation_id: 45, role: 'stop', sequence: 1, name: 'Istanbul (IST)', code: 'IST', lat: 41.27, lng: 28.75, timezone: 'Europe/Istanbul', local_date: null, local_time: null },
{ id: 3, reservation_id: 45, role: 'to', sequence: 2, name: 'Tokyo (HND)', code: 'HND', lat: 35.55, lng: 139.78, timezone: 'Asia/Tokyo', local_date: null, local_time: null },
],
} as unknown as Reservation)
it('FE-MOB-TRFRM-049: the booking code and every segment code are blurred while the setting is on', () => {
renderSheet(plannerWithBlur(true, { editingTransport: layover() }))
const codes = codeFields()
expect(codes.map(i => i.value)).toEqual(['ABC123', 'XYZ789', 'BOOK1'])
expect(codes.map(i => isBlurred(i))).toEqual([true, true, true])
})
it('FE-MOB-TRFRM-050: focusing a code field reveals it for editing, leaving it hides it again', () => {
renderSheet(plannerWithBlur(true, { editingTransport: layover() }))
const field = codeFields()[2]
expect(isBlurred(field)).toBe(true)
act(() => field.focus())
expect(isBlurred(field)).toBe(false)
act(() => field.blur())
expect(isBlurred(field)).toBe(true)
})
it('FE-MOB-TRFRM-051: with the setting off every code field stays plain', () => {
renderSheet(plannerWithBlur(false, { editingTransport: layover() }))
expect(codeFields().map(i => isBlurred(i))).toEqual([false, false, false])
})
it('FE-MOB-TRFRM-052: blurred codes still save unchanged', async () => {
const handleSaveTransport = makeSave()
renderSheet(plannerWithBlur(true, { editingTransport: layover(), handleSaveTransport }))
await submit('common.update')
const payload = handleSaveTransport.mock.calls[0][0]
const legs = (payload.metadata as { legs: Record<string, unknown>[] }).legs
expect(legs.map(l => l.confirmation_number)).toEqual(['ABC123', 'XYZ789'])
expect(payload.confirmation_number).toBe('BOOK1')
})
})
})