mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 02:34:21 +00:00
@
fix(export): print the reader clock format, and split window bookings in the feed Three v4.0.0 reports that all come down to a surface printing what is stored instead of what the reader asked for. The PDF (#2066) is assembled as an HTML string outside React, so no hook could reach it and no time format was ever passed in. It printed the column: four clock sites, all 24h whatever the personal setting or the admin default said, and a place time typed by a 12h user came out as "3:00 PM" for a 24h reader. Both export entry points now hand the format over the way they already hand over the locale, and the four sites go through formatClockTime. The journey editors (#2067) used a native <input type="time">, which paints 12h or 24h from the browser locale and cannot be told otherwise by any attribute. Every other time field in TREK has used CustomTimePicker for exactly that reason; the journey editor, its phone sheet and the phone place sheet were never migrated, so the same place form obeyed the setting on desktop and ignored it on a phone. The picker gained a disabled prop so the read-only journey sheet keeps the affordance the native input gave it. In the subscribed calendar (#2068), a booking that is a window rather than an activity read as one block across its whole range: a week of airport parking sat on all seven days. Both hand-overs now stand on their own — an hour each, carrying what the block used to say — and the block goes. Only when the two ends fall on different days: a same-day booking is one sitting, and a rental with only its pickup geocoded keeps the block, which is the only thing holding the return time and its zone at all. Rental cars were missing outright, because the planner writes reservation_time = NULL when its optional time pickers are left blank while still setting day_id, and nothing in the exporter ever read the linked days. It reads them now, as the last resort, for every type — so a hand-typed bus or train shows up as well. @
This commit is contained in:
@@ -285,7 +285,9 @@ function mountSheet(sheetEntry: JourneyEntry, opts: MountOptions = {}) {
|
||||
|
||||
const multiFileInput = () => document.querySelector('input[type="file"][multiple]') as HTMLInputElement;
|
||||
const dateField = () => document.querySelector('input[type="date"]') as HTMLInputElement;
|
||||
const timeField = () => document.querySelector('input[type="time"]') as HTMLInputElement;
|
||||
// The time field is CustomTimePicker's text input, not a native time input — a
|
||||
// native one paints 12h/24h from the browser locale and ignored the setting (#2067).
|
||||
const timeField = () => document.querySelector('input[placeholder="00:00"], input[placeholder="2:30 PM"]') as HTMLInputElement;
|
||||
const jpeg = (name = 'a.jpg') => new File(['x'], name, { type: 'image/jpeg' });
|
||||
|
||||
const originalCreateObjectURL = URL.createObjectURL;
|
||||
|
||||
@@ -3,8 +3,11 @@ import PlTimeFields from '../../../../src/mobile/screens/trip/sheets/PlTimeField
|
||||
import type { Assignment } from '../../../../src/types'
|
||||
import { buildPlanner } from '../../../helpers/mobileTrip'
|
||||
import { fireEvent, render, screen } from '../../../helpers/render'
|
||||
import { seedStore } from '../../../helpers/store'
|
||||
import { buildSettings } from '../../../helpers/factories'
|
||||
import { useSettingsStore } from '../../../../src/store/settingsStore'
|
||||
|
||||
// FE-MOB-PLTIME-001 to FE-MOB-PLTIME-012
|
||||
// FE-MOB-PLTIME-001 to FE-MOB-PLTIME-013
|
||||
|
||||
const planner = buildPlanner()
|
||||
|
||||
@@ -47,7 +50,12 @@ function setup({
|
||||
hasTimeError={hasTimeError}
|
||||
/>,
|
||||
)
|
||||
const inputs = Array.from(view.container.querySelectorAll('input[type="time"]')) as HTMLInputElement[]
|
||||
// Both fields are CustomTimePicker text inputs now, so they answer to its
|
||||
// 24h placeholder rather than to a native time input (#2067).
|
||||
// Both fields are CustomTimePicker text inputs now, and they are the only text
|
||||
// inputs this component renders — the placeholder itself changes with the
|
||||
// user's format, so it cannot be the hook (#2067).
|
||||
const inputs = Array.from(view.container.querySelectorAll('input[type="text"]')) as HTMLInputElement[]
|
||||
return { ...view, onChange, start: inputs[0], end: inputs[1] }
|
||||
}
|
||||
|
||||
@@ -72,6 +80,25 @@ describe('PlTimeFields', () => {
|
||||
expect(onChange).toHaveBeenCalledWith('end_time', '12:45')
|
||||
})
|
||||
|
||||
// #2067 — the desktop twin (PlaceFormModal) has used CustomTimePicker for ages;
|
||||
// the phone kept a native time input, so the same form obeyed the setting on one
|
||||
// shell and ignored it on the other.
|
||||
// The normalisation back to 24h on blur belongs to CustomTimePicker and is
|
||||
// covered by its own suite; what this file owns is that the phone shows the
|
||||
// user's format at all, which the native input it replaced never did.
|
||||
it('FE-MOB-PLTIME-013: a 12h user sees meridiem clocks, a 24h user does not', () => {
|
||||
seedStore(useSettingsStore, { settings: buildSettings({ time_format: '12h' }) })
|
||||
const twelve = setup()
|
||||
expect(twelve.start).toHaveValue('10:00 AM')
|
||||
expect(twelve.end).toHaveValue('11:00 AM')
|
||||
twelve.unmount()
|
||||
|
||||
seedStore(useSettingsStore, { settings: buildSettings({ time_format: '24h' }) })
|
||||
const twentyFour = setup()
|
||||
expect(twentyFour.start).toHaveValue('10:00')
|
||||
expect(twentyFour.end).toHaveValue('11:00')
|
||||
})
|
||||
|
||||
it('FE-MOB-PLTIME-004: shows the end-before-start warning only when the sheet flags it', () => {
|
||||
setup()
|
||||
expect(screen.queryByText('places.endTimeBeforeStart')).not.toBeInTheDocument()
|
||||
|
||||
Reference in New Issue
Block a user