mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
fix(places): settle the gates for the place form rework
The text tabs name their field type for the switch, so it type-checks. The colour field's sliders run left to right in every language and say so with dir=ltr and a logical inset. The new phone fields take their sizes from the type tiers or fs() instead of rem literals, the category field builds its icon as an element, and the ESLint and theme baselines come down to what the tree now holds. The tests follow the tabs (only the open tab's field and formatting bar are shown), the category list and the files row, whose link button keeps its place before attach.
This commit is contained in:
@@ -54,7 +54,7 @@ describe('PlaceContactFields (#2472)', () => {
|
||||
const opens = screen.getAllByRole('textbox', { name: /Monday opens/ })
|
||||
await user.type(opens[0], '0930')
|
||||
expect(opens[0]).toHaveValue('09:30')
|
||||
expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: false, open: '09:30' })
|
||||
expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: false, open: '09:30' })
|
||||
})
|
||||
|
||||
it('FE-PLANNER-CONTACT-004: looked-up hours fill an empty place, and an edited one offers to take them over', async () => {
|
||||
@@ -97,7 +97,7 @@ describe('PlaceContactFields (#2472)', () => {
|
||||
const allDay = screen.getByRole('switch', { name: 'Monday: Open 24 hours' })
|
||||
expect(allDay).toHaveAttribute('aria-checked', 'false')
|
||||
await user.click(allDay)
|
||||
expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: false, open: '00:00', close: '23:59' })
|
||||
expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: false, open: '00:00', close: '23:59' })
|
||||
expect(allDay).toHaveAttribute('aria-checked', 'true')
|
||||
// The two time fields give way to the word.
|
||||
expect(screen.queryByRole('textbox', { name: /Monday opens/ })).not.toBeInTheDocument()
|
||||
@@ -105,7 +105,7 @@ describe('PlaceContactFields (#2472)', () => {
|
||||
|
||||
// Closing the day turns the all-day switch off.
|
||||
await user.click(screen.getByRole('switch', { name: 'Monday: Closed' }))
|
||||
expect(JSON.parse(onChange.mock.lastCall![1])[0]).toEqual({ closed: true })
|
||||
expect(JSON.parse(onChange.mock.lastCall?.[1])[0]).toEqual({ closed: true })
|
||||
expect(allDay).toHaveAttribute('aria-checked', 'false')
|
||||
})
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ export default function PlaceDetailsColumn({
|
||||
className="flex h-[36px] w-full shrink-0 items-center gap-2 rounded-full border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] pe-3 ps-3.5 text-start"
|
||||
>
|
||||
<Landmark size={13} strokeWidth={2.2} className="flex-none text-m-muted" />
|
||||
<span className="min-w-0 flex-1 truncate font-geist text-[0.75rem] font-semibold text-m-ink">{t('places.details.title')}</span>
|
||||
<span className="min-w-0 flex-1 truncate font-geist text-caption font-semibold text-m-ink">{t('places.details.title')}</span>
|
||||
<ChevronDown
|
||||
size={13}
|
||||
strokeWidth={2.2}
|
||||
|
||||
@@ -2448,8 +2448,9 @@ describe('PlaceFormModal on the dialog frame', () => {
|
||||
const coords = screen.getByRole('group', { name: 'Coordinates' });
|
||||
expect(within(coords).getByPlaceholderText(/Latitude/i)).toBeInTheDocument();
|
||||
expect(within(coords).getByPlaceholderText(/Longitude/i)).toBeInTheDocument();
|
||||
// Each Markdown field keeps its own formatting bar.
|
||||
expect(screen.getAllByRole('toolbar')).toHaveLength(2);
|
||||
// Each Markdown field keeps its own formatting bar; only the open tab's is shown.
|
||||
expect(screen.getAllByRole('toolbar', { hidden: true })).toHaveLength(2);
|
||||
expect(screen.getAllByRole('toolbar')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('FE-PLANNER-PLACEFORM-105: the new category field takes the focus when it opens', async () => {
|
||||
@@ -2685,7 +2686,8 @@ describe('PlaceFormModal in the look of the booking editors', () => {
|
||||
it('FE-PLANNER-PLACEFORM-120: the formatting bars show their names in the shared tooltip, never the native one', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PlaceFormModal {...defaultProps} />);
|
||||
const bars = screen.getAllByRole('toolbar');
|
||||
// Both Markdown texts have a bar; the hidden tab's waits under its tab.
|
||||
const bars = screen.getAllByRole('toolbar', { hidden: true });
|
||||
expect(bars).toHaveLength(2);
|
||||
for (const bar of bars) {
|
||||
for (const button of within(bar).getAllByRole('button')) expect(button).not.toHaveAttribute('title');
|
||||
@@ -2748,6 +2750,8 @@ describe('PlaceFormModal and the columns beside it', () => {
|
||||
const assignment = buildAssignment({ id: 123, day_id: 5, place, notes: 'Old note' });
|
||||
render(<PlaceFormModal {...defaultProps} onSave={onSave} place={place} assignmentId={123} dayAssignments={[assignment]} />);
|
||||
|
||||
// The day's note sits under its own tab.
|
||||
await user.click(within(screen.getByRole('group', { name: 'Text to edit' })).getByRole('button', { name: /day/i }));
|
||||
const notes = screen.getByRole('textbox', { name: 'Notes for this day' });
|
||||
expect(notes).toHaveValue('Old note');
|
||||
await user.clear(notes);
|
||||
|
||||
@@ -58,7 +58,7 @@ export function PlaceFormTexts({
|
||||
|
||||
return (
|
||||
<div className={PANEL}>
|
||||
<Segmented
|
||||
<Segmented<PlaceTextField>
|
||||
fill
|
||||
value={shown.field}
|
||||
onChange={setActive}
|
||||
|
||||
@@ -97,6 +97,8 @@ export function TagColorField({
|
||||
<div className="flex w-full flex-col gap-2.5">
|
||||
<div
|
||||
role="slider"
|
||||
// The gradient runs left to right in every language; so does the pick on it.
|
||||
dir="ltr"
|
||||
tabIndex={0}
|
||||
aria-label={t('places.tagColorCustom')}
|
||||
aria-valuetext={hex}
|
||||
@@ -111,10 +113,15 @@ export function TagColorField({
|
||||
return { h: hsv.h, s: p.x, v: 1 - p.y };
|
||||
})}
|
||||
>
|
||||
<span className={THUMB} style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: hex }} />
|
||||
<span
|
||||
className={THUMB}
|
||||
style={{ insetInlineStart: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: hex }}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
role="slider"
|
||||
// The gradient runs left to right in every language; so does the pick on it.
|
||||
dir="ltr"
|
||||
tabIndex={0}
|
||||
aria-label={t('places.tagColorHue')}
|
||||
aria-valuenow={Math.round(hsv.h)}
|
||||
@@ -132,7 +139,10 @@ export function TagColorField({
|
||||
}}
|
||||
{...drag((e) => ({ ...hsv, h: at(e).x * 359.9 }))}
|
||||
>
|
||||
<span className={`${THUMB} top-1/2`} style={{ left: `${(hsv.h / 360) * 100}%`, background: hueHex(hsv.h) }} />
|
||||
<span
|
||||
className={`${THUMB} top-1/2`}
|
||||
style={{ insetInlineStart: `${(hsv.h / 360) * 100}%`, background: hueHex(hsv.h) }}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('typing and taking over (#2472)', () => {
|
||||
// Google writes a place open all week as one period on Sunday that never closes.
|
||||
expect(weekFromPeriods([{ open: p(0, 0), close: null }])).toEqual(Array.from({ length: 7 }, () => ({ closed: false, ...ALL_DAY })))
|
||||
// A day from midnight to the next midnight is the same.
|
||||
expect(weekFromPeriods([{ open: p(1, 0), close: p(2, 0) }])![0]).toEqual({ closed: false, ...ALL_DAY })
|
||||
expect(weekFromPeriods([{ open: p(1, 0), close: p(2, 0) }])?.[0]).toEqual({ closed: false, ...ALL_DAY })
|
||||
expect(isAllDay({ closed: false, open: '00:00', close: '23:59' })).toBe(true)
|
||||
expect(isAllDay({ closed: false, open: '00:00', close: '00:00' })).toBe(true)
|
||||
expect(isAllDay({ closed: false, open: '00:00', close: '22:00' })).toBe(false)
|
||||
@@ -78,10 +78,10 @@ describe('typing and taking over (#2472)', () => {
|
||||
const week = emptyWeek()
|
||||
week[0] = { closed: false, ...ALL_DAY }
|
||||
week[1] = { closed: false, open: '09:00', close: '17:00' }
|
||||
const lines = hoursLines(writeWeek(week), 'en', 'Closed', 'Open 24 hours')!
|
||||
const lines = hoursLines(writeWeek(week), 'en', 'Closed', 'Open 24 hours') ?? []
|
||||
expect(lines[0]).toBe('Monday: Open 24 hours')
|
||||
expect(lines[1]).toBe('Tuesday: 09:00 – 17:00')
|
||||
// Without the label the times stay, as before.
|
||||
expect(hoursLines(writeWeek(week), 'en', 'Closed')![0]).toBe('Monday: 00:00 – 23:59')
|
||||
expect(hoursLines(writeWeek(week), 'en', 'Closed')?.[0]).toBe('Monday: 00:00 – 23:59')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user