mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 07:07:31 +00:00
feat(planner): bring the plan tab and every trip dialog into the new look
The Plan tab was the last trip tab still in the old design. It now reads like Bookings, Costs, Lists, Files and Collab, without losing a function: - Day plan: each day is a card with a head band (day tile with weather, stay and rental pills, a "+" menu for place, stay, transport, transit and note), rows with "..." menus, white badges and a white route bar. - Places column: add, search and filters in three rows, a show dropdown, category and rating filters, and a selection bar at the foot. - Place inspector, day details and the stay editor on the shared dialog frame; the place form in the editor look with the name in the head band. - Clicking a booking or transport anywhere on the plan opens the booking detail popup first; Edit leads to the editor. The popup is one host shared with the Bookings and Transports tabs. - Files and Collab dialogs, notes, polls, links and chat moved to the same frame; shared DialogShell and dialogParts hold the building blocks. - The map hover card shows the place photo and follows the theme. Every new and reworded string is translated into all locales, and a few older English leftovers (help center, cost split, import hints) with them. Phone screens keep their own look.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-PLANNER-EXPORTMODAL-001 to FE-PLANNER-EXPORTMODAL-014
|
||||
// FE-PLANNER-EXPORTMODAL-001 to FE-PLANNER-EXPORTMODAL-017
|
||||
import { render, screen, waitFor } from '../../../tests/helpers/render'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { downloadTripPDF } from '../PDF/TripPDF'
|
||||
@@ -8,15 +8,20 @@ import { TripExportModal } from './TripExportModal'
|
||||
vi.mock('../PDF/TripPDF', () => ({ downloadTripPDF: vi.fn().mockResolvedValue(undefined) }))
|
||||
|
||||
// The subscribe dialog fetches its feed token on mount; it is exercised in its
|
||||
// own test, here we only care that the entry mounts it.
|
||||
vi.mock('./IcsSubscribeModal', () => ({
|
||||
IcsSubscribeModal: ({ title, onClose }: { title: string; onClose: () => void }) => (
|
||||
<div data-testid="ics-subscribe-modal">
|
||||
{title}
|
||||
<button onClick={onClose}>close-subscribe</button>
|
||||
</div>
|
||||
),
|
||||
}))
|
||||
// own test, here we only care that the entry mounts it. Portalled to the body
|
||||
// like the real one, so the stacking order can be checked.
|
||||
vi.mock('./IcsSubscribeModal', async () => {
|
||||
const { createPortal } = await import('react-dom')
|
||||
return {
|
||||
IcsSubscribeModal: ({ title, onClose }: { title: string; onClose: () => void }) => createPortal(
|
||||
<div data-testid="ics-subscribe-modal">
|
||||
{title}
|
||||
<button onClick={onClose}>close-subscribe</button>
|
||||
</div>,
|
||||
document.body,
|
||||
),
|
||||
}
|
||||
})
|
||||
|
||||
const t = (key: string, params?: Record<string, unknown>) =>
|
||||
params ? `${key}|${Object.values(params).join('|')}` : key
|
||||
@@ -77,15 +82,43 @@ describe('TripExportModal', () => {
|
||||
|
||||
it('FE-PLANNER-EXPORTMODAL-002: open, every export sits in its own section', () => {
|
||||
render(<TripExportModal {...makeProps()} />)
|
||||
expect(screen.getByRole('dialog', { name: 'dayplan.export' })).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportIntro')).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportDocument')).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportCalendar')).toBeInTheDocument()
|
||||
expect(screen.getByText('dayplan.exportMaps · GPX')).toBeInTheDocument()
|
||||
// The format stands beside the plain-language heading as a pill, not behind a "·".
|
||||
expect(screen.getByText('dayplan.exportMaps')).toBeInTheDocument()
|
||||
expect(screen.getByText('GPX')).toBeInTheDocument()
|
||||
expect(document.body.textContent).not.toContain('·')
|
||||
for (const label of ['dayplan.pdf', 'mobileTrip.icsDownload', 'mobileTrip.icsSubscribe',
|
||||
'dayplan.gpxAll', 'dayplan.gpxPlaces', 'dayplan.gpxDays']) {
|
||||
expect(screen.getByText(label)).toBeInTheDocument()
|
||||
}
|
||||
})
|
||||
|
||||
it('FE-PLANNER-EXPORTMODAL-015: Escape and the head band close button close the dialog', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onClose = vi.fn()
|
||||
render(<TripExportModal {...makeProps({ onClose })} />)
|
||||
await user.keyboard('{Escape}')
|
||||
expect(onClose).toHaveBeenCalledTimes(1)
|
||||
await user.click(screen.getByRole('button', { name: 'Close' }))
|
||||
expect(onClose).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('FE-PLANNER-EXPORTMODAL-016: while one export works, every row waits', async () => {
|
||||
const user = userEvent.setup()
|
||||
let finish: (() => void) | null = null
|
||||
vi.mocked(downloadTripPDF).mockImplementationOnce(() => new Promise<void>(res => { finish = res }))
|
||||
render(<TripExportModal {...makeProps()} />)
|
||||
await user.click(screen.getByText('dayplan.pdf'))
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: /dayplan\.gpxAll/ })).toBeDisabled())
|
||||
expect(screen.getByRole('button', { name: /mobileTrip\.icsDownload/ })).toBeDisabled()
|
||||
expect(screen.getByRole('button', { name: /dayplan\.pdf/ })).toBeDisabled()
|
||||
finish!()
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: /dayplan\.gpxAll/ })).toBeEnabled())
|
||||
})
|
||||
|
||||
// ── PDF ───────────────────────────────────────────────────────────────────
|
||||
|
||||
it('FE-PLANNER-EXPORTMODAL-003: the PDF row exports the trip with the day notes flattened', async () => {
|
||||
@@ -160,6 +193,27 @@ describe('TripExportModal', () => {
|
||||
expect(screen.queryByTestId('ics-subscribe-modal')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
// The subscription dialog used to sit under the export dialog (9999 against
|
||||
// 10000), and one Escape closed the export behind it as well.
|
||||
it('FE-PLANNER-EXPORTMODAL-017: the subscribe dialog stacks on top, and Escape leaves the export alone while it is open', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onClose = vi.fn()
|
||||
render(<TripExportModal {...makeProps({ onClose })} />)
|
||||
await user.click(screen.getByText('mobileTrip.icsSubscribe'))
|
||||
const exportBackdrop = screen.getByRole('dialog', { name: 'dayplan.export' }).parentElement!
|
||||
const subscribe = screen.getByTestId('ics-subscribe-modal')
|
||||
// Both hang off the body; the later one paints above the earlier.
|
||||
expect(exportBackdrop.compareDocumentPosition(subscribe) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
|
||||
await user.keyboard('{Escape}')
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
// A press on the export's backdrop is spent on nothing either.
|
||||
await user.click(exportBackdrop)
|
||||
expect(onClose).not.toHaveBeenCalled()
|
||||
await user.click(screen.getByText('close-subscribe'))
|
||||
await user.keyboard('{Escape}')
|
||||
expect(onClose).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
// The subscription mints a link that reads the trip without an account, so it
|
||||
// needs share_manage; the one-off download is a file this member may already
|
||||
// read. Leaving the entry visible would only produce a dialog whose enable
|
||||
|
||||
Reference in New Issue
Block a user