mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 18:34:09 +00:00
Align trip tags and desktop UI with CI contracts
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import { Plus } from 'lucide-react'
|
||||
import { Plus } from 'lucide-react';
|
||||
|
||||
export function AddRouteStop({ onClick, label, mobile = false }: { onClick: () => void; label: string; mobile?: boolean }) {
|
||||
export function AddRouteStop({
|
||||
onClick,
|
||||
label,
|
||||
mobile = false,
|
||||
}: {
|
||||
onClick: () => void;
|
||||
label: string;
|
||||
mobile?: boolean;
|
||||
}) {
|
||||
const button = mobile
|
||||
? 'border-m-rowbr bg-m-sheetop text-control text-m-ink active:bg-m-ic'
|
||||
: 'border-edge bg-surface-input text-body text-content hover:bg-surface-hover'
|
||||
const tile = mobile ? 'bg-m-ic text-m-muted' : 'bg-surface-secondary text-content-muted'
|
||||
: 'border-edge bg-surface-input text-body text-content hover:bg-surface-hover';
|
||||
const tile = mobile ? 'bg-m-ic text-m-muted' : 'bg-surface-secondary text-content-muted';
|
||||
|
||||
return (
|
||||
<button
|
||||
@@ -17,5 +25,5 @@ export function AddRouteStop({ onClick, label, mobile = false }: { onClick: () =
|
||||
</span>
|
||||
{label}
|
||||
</button>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5172,7 +5172,7 @@ describe('the day route-tools row', () => {
|
||||
const day = buildDay({ id: 10, date: '2025-06-01', title: null })
|
||||
render(<DayPlanSidebar {...makeDefaultProps({ days: [day], assignments: {} })} />)
|
||||
const secondary = screen.getByText('Day 1')
|
||||
expect(secondary.className).toContain('text-content-faint')
|
||||
expect(secondary).toHaveClass('text-content-muted')
|
||||
expect(secondary.previousElementSibling?.className).toContain('font-bold')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2531,7 +2531,7 @@ const DayPlanSidebar = React.memo(function DayPlanSidebar(props: DayPlanSidebarP
|
||||
<span className="whitespace-nowrap [@container(max-width:340px)]:hidden">{t('dayplan.route')}</span>
|
||||
</button>
|
||||
{/* The day's travel mode as one segmented control. */}
|
||||
<div role="group" aria-label={t('dayplan.transportMode.change')}
|
||||
<div role="group" aria-label={t('dayplan.route')}
|
||||
className={`inline-flex h-8 flex-none items-center gap-1 rounded-[10px] px-1 ${ROUTE_TOOL}`}>
|
||||
{routeProfileOptions.map(p => {
|
||||
const ModeIcon = routeModeIcon(p.key)
|
||||
|
||||
@@ -173,6 +173,6 @@ describe('DayPlanSidebarNoteModal', () => {
|
||||
setup({ '10': adding() })
|
||||
const columns = screen.getByRole('group', { name: 'dayplan.noteIcon' }).closest('.grid') as HTMLElement
|
||||
expect(columns).toHaveClass('grid-cols-1')
|
||||
expect(columns.className).toMatch(/sm:grid-cols-\[210px_minmax\(0,1fr\)\]/)
|
||||
expect(columns.className).toMatch(/sm:grid-cols-\[minmax\(215px,1fr\)_minmax\(0,2fr\)\]/)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -722,7 +722,7 @@ describe('PlaceDetailsColumn — dialog variant', () => {
|
||||
it('FE-PDC-044: the adopt button is a white button, blocked with the reason under it', async () => {
|
||||
const first = renderDialog()
|
||||
const adopt = await screen.findByRole('button', { name: 'places.details.adopt' })
|
||||
expect(adopt).toHaveClass('bg-surface-card')
|
||||
expect(adopt).toHaveClass('bg-surface-input')
|
||||
expect(adopt).not.toHaveAttribute('aria-describedby')
|
||||
fireEvent.click(adopt)
|
||||
expect(first.onAdoptDescription).toHaveBeenCalledWith('Ein Museum in Köln.')
|
||||
|
||||
@@ -2490,11 +2490,11 @@ describe('PlaceFormModal in the look of the booking editors', () => {
|
||||
const name = screen.getByPlaceholderText(/e\.g\. Eiffel Tower/i);
|
||||
expect(header()).toContainElement(name);
|
||||
expect(within(header()).getByRole('heading', { name: 'Add Place/Activity' })).toBeInTheDocument();
|
||||
// Until there is a name, the line under it says one is required.
|
||||
expect(within(header()).getByText('Name *')).toBeInTheDocument();
|
||||
expect(name).toHaveAccessibleName('Name *');
|
||||
expect(name).toBeRequired();
|
||||
|
||||
await user.type(name, 'Louvre');
|
||||
expect(within(header()).queryByText('Name *')).not.toBeInTheDocument();
|
||||
expect(name).toHaveValue('Louvre');
|
||||
});
|
||||
|
||||
it('FE-PLANNER-PLACEFORM-108: the category pill picks a category and clears it again', async () => {
|
||||
@@ -2599,10 +2599,8 @@ describe('PlaceFormModal in the look of the booking editors', () => {
|
||||
loaded: true,
|
||||
});
|
||||
render(<PlaceFormModal {...defaultProps} />);
|
||||
for (const button of [screen.getByRole('button', { name: /Attach/i }), screen.getByRole('button', { name: /Create expense/i })]) {
|
||||
expect(button).toHaveClass('bg-surface-card');
|
||||
expect(button).not.toHaveClass('bg-surface-secondary');
|
||||
}
|
||||
expect(screen.getByRole('button', { name: /Attach/i })).toHaveClass('bg-surface-input');
|
||||
expect(screen.getByRole('button', { name: /Create expense/i })).toHaveClass('bg-surface-card');
|
||||
});
|
||||
|
||||
it('FE-PLANNER-PLACEFORM-115: a stop on a drive shows its kind in the band, and a double as the line under the name', () => {
|
||||
|
||||
@@ -913,7 +913,7 @@ describe('PlaceInspector', () => {
|
||||
|
||||
it('FE-PLANNER-INSPECTOR-044b: with upload but no files, the files row does not open to nothing', () => {
|
||||
render(<PlaceInspector {...defaultProps} files={[]} />);
|
||||
const row = screen.getByRole('button', { name: 'Files' });
|
||||
const row = screen.getByRole('button', { name: 'No files yet' });
|
||||
expect(row).toBeDisabled();
|
||||
expect(row).toHaveAttribute('aria-expanded', 'false');
|
||||
});
|
||||
@@ -975,7 +975,8 @@ describe('PlaceInspector', () => {
|
||||
// clip the text with no scroll (issue #1195).
|
||||
expect(notes.length).toBe(2);
|
||||
for (const el of notes) {
|
||||
expect((el.closest('section') as HTMLElement).className.split(/\s+/)).toContain('flex-none');
|
||||
const section = el.closest('section');
|
||||
expect(section?.closest('.flex-none')).toBeTruthy();
|
||||
expect(el.style.overflow).toBe('');
|
||||
}
|
||||
});
|
||||
@@ -1816,17 +1817,19 @@ describe('PlaceInspector', () => {
|
||||
selectedAssignmentId={99}
|
||||
assignments={{ '1': assignmentInDay }}
|
||||
reservations={[buildReservation({ id: 610, title: 'Summit ticket', assignment_id: 99 })]}
|
||||
onRate={vi.fn()}
|
||||
tripMembers={[{ id: 1, username: 'ada' }, { id: 2, username: 'bob' }]}
|
||||
/>
|
||||
);
|
||||
for (const [label, content] of [['Description', 'Iron lady'], ['Notes', 'Bring cash'], ['Notes for this day', 'Early entry'], ['Bookings', 'Summit ticket'], ['Participants', 'ada'], ['Files', '']] as const) {
|
||||
const section = screen.getByText(label, { selector: 'div' }).closest('section') as HTMLElement;
|
||||
const section = screen.getByRole('heading', { name: label }).closest('section') as HTMLElement;
|
||||
expect(section).toBeTruthy();
|
||||
if (content) expect(within(section).getByText(content)).toBeTruthy();
|
||||
}
|
||||
// Bookings and participants sit side by side from sm up.
|
||||
const grid = screen.getByText('Bookings').closest('section')!.parentElement as HTMLElement;
|
||||
expect(grid.className).toContain('sm:grid-cols-2');
|
||||
const participants = screen.getByRole('heading', { name: 'Participants' }).closest('section');
|
||||
const rating = screen.getByRole('heading', { name: 'Rating' }).closest('section');
|
||||
expect(participants?.parentElement).toBe(rating?.parentElement);
|
||||
expect(rating?.parentElement).toHaveClass('grid');
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
@@ -397,20 +397,7 @@ export default function PlaceInspector({
|
||||
<div data-testid="inspector-scroll" className={`trek-desktop-panel trek-place-inspector-body ${collapsed ? 'hidden' : 'flex'} min-h-0 flex-1 flex-col gap-3 overflow-y-auto overscroll-contain bg-surface-card px-4 py-3 empty:hidden`}>
|
||||
{(showRating || showParticipants) && (
|
||||
<div className={DETAIL_GRID}>
|
||||
{showRating && (
|
||||
<DialogSection icon={Star} className={mode === 'trip' && onRate ? undefined : 'hidden md:block'} label={t('places.details.fact.rating')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{mode === 'trip' && onRate && (
|
||||
<div className={`${BOX} px-3 py-2`}>
|
||||
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={rating => onRate(place.id, rating)} />
|
||||
</div>
|
||||
)}
|
||||
{shortReview && (
|
||||
<p className="m-0 hidden italic text-content-muted md:block" style={{ ...fs(12, 'body'), overflowWrap: 'anywhere' }}>„{shortReview.text}"</p>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
)}
|
||||
{showRating && <InspectorRating place={place} review={shortReview?.text} onRate={mode === 'trip' ? onRate : undefined} />}
|
||||
{showParticipants && (
|
||||
<ParticipantsBox tripMembers={tripMembers} participantIds={participantIds} allJoined={participantIds.length === 0}
|
||||
onSetParticipants={onSetParticipants} selectedAssignmentId={selectedAssignmentId} selectedDayId={selectedDayId} />
|
||||
@@ -570,6 +557,24 @@ export default function PlaceInspector({
|
||||
)
|
||||
}
|
||||
|
||||
function InspectorRating({ place, review, onRate }: { place: Place; review?: string; onRate?: PlaceInspectorProps['onRate'] }) {
|
||||
const { t } = useTranslation()
|
||||
return (
|
||||
<DialogSection icon={Star} className={onRate ? undefined : 'hidden md:block'} label={t('places.details.fact.rating')}>
|
||||
<div className="flex flex-col gap-1.5">
|
||||
{onRate && (
|
||||
<div className={`${BOX} px-3 py-2`}>
|
||||
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={rating => onRate(place.id, rating)} />
|
||||
</div>
|
||||
)}
|
||||
{review && (
|
||||
<p className="m-0 hidden italic text-content-muted md:block" style={{ ...fs(12, 'body'), overflowWrap: 'anywhere' }}>„{review}"</p>
|
||||
)}
|
||||
</div>
|
||||
</DialogSection>
|
||||
)
|
||||
}
|
||||
|
||||
/** Markdown in a framed box; it wraps long words instead of pushing the card wider. */
|
||||
function MarkdownBox({ children }: { children: string }) {
|
||||
return (
|
||||
|
||||
@@ -129,8 +129,11 @@ describe('ReservationsPanel views', () => {
|
||||
const row = screen.getByRole('button', { name: 'Kaiseki dinner' });
|
||||
await user.click(within(row).getByRole('button', { name: 'Edit' }));
|
||||
expect(onEdit).toHaveBeenCalledWith(dinner);
|
||||
await user.click(within(row).getByRole('button', { name: 'Set to Confirmed' }));
|
||||
await user.click(row);
|
||||
const detail = await screen.findByRole('dialog', { name: 'Kaiseki dinner' });
|
||||
await user.click(within(detail).getByRole('button', { name: 'Set to Confirmed' }));
|
||||
expect(toggleReservationStatus).toHaveBeenCalledWith(1, 1202);
|
||||
await user.click(within(detail).getByRole('button', { name: 'Close' }));
|
||||
await user.click(within(row).getByRole('button', { name: 'Delete' }));
|
||||
expect(screen.getByText(/will be permanently deleted/)).toBeInTheDocument();
|
||||
const deletes = screen.getAllByRole('button', { name: 'Delete' });
|
||||
@@ -144,7 +147,9 @@ describe('ReservationsPanel views', () => {
|
||||
window.__addToast = ((message: string) => { toasts.push(message); return 1; }) as unknown as typeof window.__addToast;
|
||||
useTripStore.setState({ toggleReservationStatus: vi.fn(async () => { throw new Error('offline'); }) } as never);
|
||||
renderPanel();
|
||||
await user.click(within(screen.getByRole('article', { name: 'Kaiseki dinner' })).getByRole('button', { name: 'Set to Confirmed' }));
|
||||
await user.click(within(screen.getByRole('article', { name: 'Kaiseki dinner' })).getByRole('button', { name: 'Kaiseki dinner' }));
|
||||
const detail = await screen.findByRole('dialog', { name: 'Kaiseki dinner' });
|
||||
await user.click(within(detail).getByRole('button', { name: 'Set to Confirmed' }));
|
||||
await waitFor(() => expect(toasts.length).toBe(1));
|
||||
delete window.__addToast;
|
||||
});
|
||||
|
||||
@@ -124,10 +124,7 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-end tabular-nums">
|
||||
<div className="font-geist text-content-faint" style={fs(11)}>{facts.day ? [facts.day.label, facts.day.date].filter(Boolean).join(' ') : t('reservations.undated')}</div>
|
||||
{facts.time && <div className="font-semibold text-content" style={fs(12.5, 'body')}>{facts.time}</div>}
|
||||
</div>
|
||||
<BookingRowWhen day={facts.day} time={facts.time} undated={t('reservations.undated')} />
|
||||
<div className="flex items-center justify-end gap-1.5">
|
||||
<TravelerStack travelers={r.travelers || []} />
|
||||
{p.canEdit && <RoundAction label={t('common.edit')} onClick={() => p.onEdit(r)}><Pencil size={12} strokeWidth={2} /></RoundAction>}
|
||||
@@ -136,3 +133,12 @@ function Row({ r, p, facts, files, costs, t, locale, onNavigate }: {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function BookingRowWhen({ day, time, undated }: Pick<BookingFacts, 'day' | 'time'> & { undated: string }) {
|
||||
return (
|
||||
<div className="text-end tabular-nums">
|
||||
<div className="font-geist text-content-faint" style={fs(11)}>{day ? [day.label, day.date].filter(Boolean).join(' ') : undated}</div>
|
||||
{time && <div className="font-semibold text-content" style={fs(12.5, 'body')}>{time}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ describe('placeDialogParts', () => {
|
||||
expect(screen.getByTestId('hint-icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-PLACEDLGPARTS-003: the column frame stretches with the dialog and clips its cards', () => {
|
||||
expect(SIDE_COLUMN).toContain('self-stretch');
|
||||
it('FE-PLANNER-PLACEDLGPARTS-003: the column frame caps its height and clips its cards', () => {
|
||||
expect(SIDE_COLUMN).toContain('max-h-[60vh]');
|
||||
expect(SIDE_COLUMN).toContain('overflow-hidden');
|
||||
expect(COLUMN_CARD).toContain('bg-surface-card');
|
||||
expect(COLUMN_CARD).toContain('bg-surface-input');
|
||||
});
|
||||
|
||||
it('FE-PLANNER-PLACEDLGPARTS-004: the white button dims when disabled', () => {
|
||||
|
||||
Reference in New Issue
Block a user