Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(demo): the phone welcome lives with the phone dashboard, not under components

Maurice7797a9a56218
diff --git a/client/src/components/Demo/DemoWelcome.test.tsx b/client/src/components/Demo/DemoWelcome.test.tsx
index a11179b1a..25b192ed6 100644
--- a/client/src/components/Demo/DemoWelcome.test.tsx
+++ b/client/src/components/Demo/DemoWelcome.test.tsx
@@ -1,4 +1,4 @@
-import { act, fireEvent, waitFor, within } from '@testing-library/react';
+import { act, fireEvent, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { render, screen } from '../../../tests/helpers/render';
@@ -6,10 +6,6 @@ import { resetAllStores, seedStore } from '../../../tests/helpers/store';
import { useAuthStore } from '../../store/authStore';
import DemoWelcome from './DemoWelcome';
-// useIsPhone follows matchMedia, which the global stub always answers with false.
-const phone = vi.hoisted(() => ({ value: false }));
-vi.mock('../../mobile/useIsPhone', () => ({ useIsPhone: () => phone.value }));
-
beforeEach(() => {
resetAllStores();
seedStore(useAuthStore, { serverTimezone: 'UTC' });
@@ -17,7 +13,6 @@ beforeEach(() => {
afterEach(() => {
vi.useRealTimers();
- phone.value = false;
});
describe('DemoWelcome', () => {
@@ -151,18 +146,4 @@ describe('DemoWelcome', () => {
'https://creativecommons.org/licenses/by-sa/3.0/'
);
});
-
- it('FE-COMP-DEMOWELCOME-030: on a phone it is a sheet with the same content and a full-width start', async () => {
- phone.value = true;
- render(<DemoWelcome />);
- const sheet = screen.getByRole('dialog', { name: 'Live demo' });
- expect(sheet).toHaveTextContent('Welcome to TREK');
- expect(within(sheet).getByTestId('demo-countdown')).toBeInTheDocument();
- expect(within(sheet).getByText('Everything resets every hour')).toBeInTheDocument();
- expect(within(sheet).getByText('Trip planner')).toBeInTheDocument();
- expect(within(sheet).getByText('Automatic backups')).toBeInTheDocument();
- expect(within(sheet).getByRole('link', { name: /source code/i })).toHaveAttribute('target', '_blank');
- await userEvent.click(within(sheet).getByRole('button', { name: /start exploring/i }));
- await waitFor(() => expect(screen.queryByText('Trip planner')).not.toBeInTheDocument());
- });
});
diff --git a/client/src/components/Demo/DemoWelcome.tsx b/client/src/components/Demo/DemoWelcome.tsx
index 00b101219..d8774e8c3 100644
--- a/client/src/components/Demo/DemoWelcome.tsx
+++ b/client/src/components/Demo/DemoWelcome.tsx
@@ -1,7 +1,6 @@
import { ArrowLeft, ArrowRight, Clock, ExternalLink, Images, RotateCcw } from 'lucide-react';
import { lazy, Suspense, useId } from 'react';
import { useTranslation } from '../../i18n';
-import { useIsPhone } from '../../mobile/useIsPhone';
import {
DialogButton,
DialogFooter,
@@ -17,7 +16,6 @@ import {
import ErrorBoundary from '../shared/ErrorBoundary';
import TrekIcon from '../shared/TrekIcon';
import { DEMO_FEATURES, DEMO_FULL_VERSION, DEMO_LIMITS, TREK_REPO_URL, type DemoLine } from './demoWelcomeModel';
-import MDemoWelcome from './MDemoWelcome';
import { useDemoWelcome } from './useDemoWelcome';
// The credits and their photo list load when a visitor opens them, not with the dashboard.
@@ -140,20 +138,6 @@ export default function DemoWelcome() {
const { t } = useTranslation();
const labelId = useId();
const { open, close, countdown, creditsOpen, backFromCredits, openCredits, closeCredits } = useDemoWelcome();
- const phone = useIsPhone();
-
- // On a phone the welcome is a sheet of the phone shell, not the desktop dialog made narrow.
- if (phone)
- return (
- <MDemoWelcome
- open={open}
- close={close}
- countdown={countdown}
- creditsOpen={creditsOpen}
- openCredits={openCredits}
- closeCredits={closeCredits}
- />
- );
return (
<DialogShell
diff --git a/client/src/mobile/screens/dashboard/MDashboard.tsx b/client/src/mobile/screens/dashboard/MDashboard.tsx
index 8f1eabbd5..e18d201eb 100644
--- a/client/src/mobile/screens/dashboard/MDashboard.tsx
+++ b/client/src/mobile/screens/dashboard/MDashboard.tsx
@@ -14,7 +14,7 @@ import { useInAppNotificationStore } from '../../../store/inAppNotificationStore
import { useDashboardPlugins } from '../../../components/Dashboard/useDashboardPlugins'
import { useAssistantHomeLauncher } from '../../../components/Assistant/useAssistantHome'
import type { TripCardBadge } from '../../../api/client'
-import DemoWelcome from '../../../components/Demo/DemoWelcome'
+import MDemoWelcome from './MDemoWelcome'
import { IcsSubscribeModal } from '../../../components/Planner/IcsSubscribeModal'
import PluginWidgets from '../../../components/Plugins/PluginWidgets'
import { entityGradient } from '../../../utils/gradients'
@@ -253,7 +253,7 @@ export default function MDashboard(): React.ReactElement {
<MUserMenu open={menuOpen} onClose={() => setMenuOpen(false)} />
- {demoMode && <DemoWelcome />}
+ {demoMode && <MDemoWelcome />}
<MPullIndicator state={pull} label={t('common.loading')} />
<div ref={contentRef} className="px-4 pb-[calc(var(--bottom-nav-h,84px)+32px)] pt-[calc(var(--m-safe-top,12px)+82px)]">
diff --git a/client/src/mobile/screens/dashboard/MDemoWelcome.test.tsx b/client/src/mobile/screens/dashboard/MDemoWelcome.test.tsx
new file mode 100644
index 000000000..b19ab0211
--- /dev/null
+++ b/client/src/mobile/screens/dashboard/MDemoWelcome.test.tsx
@@ -0,0 +1,37 @@
+import { waitFor, within } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { beforeEach, describe, expect, it } from 'vitest';
+import { render, screen } from '../../../../tests/helpers/render';
+import { resetAllStores, seedStore } from '../../../../tests/helpers/store';
+import { useAuthStore } from '../../../store/authStore';
+import MDemoWelcome from './MDemoWelcome';
+
+beforeEach(() => {
+ resetAllStores();
+ seedStore(useAuthStore, { serverTimezone: 'UTC' });
+});
+
+describe('MDemoWelcome', () => {
+ it('FE-COMP-DEMOWELCOME-030: on a phone it is a sheet with the same content and a full-width start', async () => {
+ render(<MDemoWelcome />);
+ const sheet = screen.getByRole('dialog', { name: 'Live demo' });
+ expect(sheet).toHaveTextContent('Welcome to TREK');
+ expect(within(sheet).getByTestId('demo-countdown')).toBeInTheDocument();
+ expect(within(sheet).getByText('Everything resets every hour')).toBeInTheDocument();
+ expect(within(sheet).getByText('Trip planner')).toBeInTheDocument();
+ expect(within(sheet).getByText('Automatic backups')).toBeInTheDocument();
+ expect(within(sheet).getByRole('link', { name: /source code/i })).toHaveAttribute('target', '_blank');
+ await userEvent.click(within(sheet).getByRole('button', { name: /start exploring/i }));
+ await waitFor(() => expect(screen.queryByText('Trip planner')).not.toBeInTheDocument());
+ });
+
+ it('FE-COMP-DEMOWELCOME-031: the photo credits open in its place and lead back', async () => {
+ render(<MDemoWelcome />);
+ const sheet = screen.getByRole('dialog', { name: 'Live demo' });
+ await userEvent.click(within(sheet).getByRole('button', { name: /photo credits/i }));
+ const back = await within(sheet).findByRole('button', { name: /back/i });
+ expect(within(sheet).queryByText('Trip planner')).not.toBeInTheDocument();
+ await userEvent.click(back);
+ expect(within(sheet).getByText('Trip planner')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/components/Demo/MDemoWelcome.tsx b/client/src/mobile/screens/dashboard/MDemoWelcome.tsx
similarity index 87%
rename from client/src/components/Demo/MDemoWelcome.tsx
rename to client/src/mobile/screens/dashboard/MDemoWelcome.tsx
index 2737072b8..42e0cd303 100644
--- a/client/src/components/Demo/MDemoWelcome.tsx
+++ b/client/src/mobile/screens/dashboard/MDemoWelcome.tsx
@@ -1,26 +1,24 @@
import { ArrowLeft, ArrowRight, Clock, ExternalLink, Images, RotateCcw } from 'lucide-react';
import { lazy, Suspense } from 'react';
-import { useTranslation } from '../../i18n';
-import MSheet from '../../mobile/components/MSheet';
-import { Eyebrow, SHEET_PRIMARY, SHEET_SECONDARY } from '../../mobile/screens/trip/sheets/MTripSheetUi';
-import { FormSheetHeader } from '../../mobile/screens/trip/sheets/PlSheetChrome';
-import ErrorBoundary from '../shared/ErrorBoundary';
-import TrekIcon from '../shared/TrekIcon';
-import { DEMO_FEATURES, DEMO_FULL_VERSION, DEMO_LIMITS, TREK_REPO_URL, type DemoLine } from './demoWelcomeModel';
+import {
+ DEMO_FEATURES,
+ DEMO_FULL_VERSION,
+ DEMO_LIMITS,
+ TREK_REPO_URL,
+ type DemoLine,
+} from '../../../components/Demo/demoWelcomeModel';
+import { useDemoWelcome } from '../../../components/Demo/useDemoWelcome';
+import ErrorBoundary from '../../../components/shared/ErrorBoundary';
+import TrekIcon from '../../../components/shared/TrekIcon';
+import { useTranslation } from '../../../i18n';
+import MSheet from '../../components/MSheet';
+import { Eyebrow, SHEET_PRIMARY, SHEET_SECONDARY } from '../trip/sheets/MTripSheetUi';
+import { FormSheetHeader } from '../trip/sheets/PlSheetChrome';
-const DemoCredits = lazy(() => import('./DemoCredits'));
+const DemoCredits = lazy(() => import('../../../components/Demo/DemoCredits'));
type Translate = ReturnType<typeof useTranslation>['t'];
-interface MDemoWelcomeProps {
- open: boolean;
- close: () => void;
- countdown: string;
- creditsOpen: boolean;
- openCredits: () => void;
- closeCredits: () => void;
-}
-
const CARD = 'rounded-[18px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)]';
function Lines({ lines, accent, t }: { lines: readonly DemoLine[]; accent?: boolean; t: Translate }) {
@@ -90,15 +88,9 @@ function Welcome({ t }: { t: Translate }) {
* screen. The head stays small so the list gets the room, the start button
* runs the full width, and the two links sit under it.
*/
-export default function MDemoWelcome({
- open,
- close,
- countdown,
- creditsOpen,
- openCredits,
- closeCredits,
-}: MDemoWelcomeProps) {
+export default function MDemoWelcome() {
const { t } = useTranslation();
+ const { open, close, countdown, creditsOpen, openCredits, closeCredits } = useDemoWelcome();
const title = t(creditsOpen ? 'demo.credits.title' : 'demo.welcome.title');
return (