diff --git a/client/e2e/urlbar-scroll-1809.spec.ts b/client/e2e/urlbar-scroll-1809.spec.ts index 586725d3b..64f3c87b8 100644 --- a/client/e2e/urlbar-scroll-1809.spec.ts +++ b/client/e2e/urlbar-scroll-1809.spec.ts @@ -102,9 +102,9 @@ test('#1809 iPhone: flow screens scroll the document, full-screen ones do not', // deliberately do NOT scroll the document (and so keep the address bar), and // the map must not collapse to zero height now that the shell has none. await page.goto('/atlas') - await expect(page.locator('.leaflet-container')).toBeVisible({ timeout: 20_000 }) + await expect(page.locator('canvas[aria-label="Atlas"]')).toBeVisible({ timeout: 20_000 }) const atlas = await page.evaluate(() => { - const map = document.querySelector('.leaflet-container') as HTMLElement + const map = document.querySelector('canvas[aria-label="Atlas"]') as HTMLElement window.scrollBy(0, 400) return { top: document.scrollingElement!.scrollTop, diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json index db6d44f70..f57edfb5c 100644 --- a/client/scripts/feature-pairs.json +++ b/client/scripts/feature-pairs.json @@ -135,24 +135,24 @@ { "feature": "Atlas country/region action sheet", "hooks": ["src/pages/atlas/useAtlasCountryActions.ts"], - "desktop": ["src/pages/AtlasPage.tsx"], + "desktop": ["src/pages/atlas/AtlasCountryActionDialog.tsx"], "mobile": ["src/mobile/screens/atlas/MAtlasCountryPopup.tsx"] }, + { + "feature": "Atlas globe", + "hooks": ["src/pages/atlas/useAtlasGlobe.ts", "src/pages/atlas/useGlobeStats.ts"], + "desktop": ["src/pages/atlas/AtlasGlobeView.tsx"], + "mobile": ["src/mobile/screens/atlas/MAtlasGlobe.tsx"] + }, { "feature": "Atlas page: atlasModel", "hooks": ["src/pages/atlas/atlasModel.ts"], "desktop": [ "src/components/Atlas/AtlasCountryPlaces.tsx", "src/components/shared/CountryFlag.tsx", - "src/pages/AtlasPage.tsx" + "src/pages/atlas/AtlasGlobeView.tsx" ], - "mobile": ["src/mobile/screens/atlas/MAtlas.tsx", "src/mobile/screens/atlas/MAtlasBucketSheet.tsx"] - }, - { - "feature": "Atlas page: useAtlas", - "hooks": ["src/pages/atlas/useAtlas.ts"], - "desktop": ["src/pages/AtlasPage.tsx"], - "mobile": ["src/mobile/screens/atlas/MAtlas.tsx", "src/mobile/screens/atlas/atlasController.ts"] + "mobile": ["src/mobile/screens/atlas/MAtlasGlobe.tsx"] }, { "feature": "Audit log", @@ -1127,8 +1127,8 @@ "src/mobile/screens/admin/MAdminUi.tsx": "Phone only admin UI primitives (button, card, field, input, secret input, sheet frame).", "src/mobile/screens/admin/MPluginVersionDate.tsx": "Markup only; the published date of a plugin version in MAdminPluginsPanel, formatted with the user's date format through useFormatDate.", "src/mobile/screens/admin/MStorageReclaimCard.tsx": "Markup only; renders the reclaim view and handlers that MAdminStoragePanel takes from useStoragePanel, the twin of StorageReclaimSection.", - "src/mobile/screens/atlas/MAtlasSearch.tsx": "Phone full screen country search overlay; options, suggestions and selection come through props from MAtlas.", - "src/mobile/screens/atlas/MAtlasStatsCard.tsx": "Markup only; renders the AtlasStats that MAtlas passes in.", + "src/mobile/screens/atlas/MAtlas.tsx": "The phone route entry; it only renders MAtlasGlobe, which runs on useAtlasGlobe in the \"Atlas globe\" pair.", + "src/mobile/screens/atlas/MAtlasStatsCard.tsx": "Markup only; renders the globe figures from useGlobeStats that MAtlasGlobe passes in.", "src/mobile/screens/collections/MCollCategoryPicker.tsx": "Phone only category dropdown; value and categories come through props from the collection sheets.", "src/mobile/screens/collections/MCollInvites.tsx": "Markup only; the invites and accept and decline come through props from useCollections via MCollections.", "src/mobile/screens/collections/MCollLabelsSheet.tsx": "Phone label sheet; create, update, delete and assign come through props from useCollections.", @@ -1207,6 +1207,16 @@ "src/mobile/screens/trip/tabs/tabModel.ts": "Phone tab prop type and status colour tokens only the phone tabs use.", "src/mobile/screens/trip/tabs/transportsModel.ts": "Phone transport card readers (metadata, day and time cells) for MTransportsTab and MBookingsTab.", "src/mobile/screens/vacay/MVacayMonth.tsx": "Markup only; its day cell colours come from the phone vacayDayModel.", - "src/mobile/screens/vacay/vacayDayModel.ts": "Phone day cell colour model for MVacayMonth; the desktop card styles its cells inline." + "src/mobile/screens/vacay/vacayDayModel.ts": "Phone day cell colour model for MVacayMonth; the desktop card styles its cells inline.", + "src/mobile/screens/atlas/hub/MAtlasHub.tsx": "The Atlas hub as a phone sheet: the tab strip and the sheets on top; the desktop opens AtlasGlobePassport, a dialog with its own markup, over the same useAtlasGlobe state.", + "src/mobile/screens/atlas/hub/MHubOverview.tsx": "Phone layout of one tab of the Atlas hub sheet (MAtlasHub); the desktop draws the same tab inside AtlasGlobePassport with its own markup, and both read the state of useAtlasGlobe and the derived values of pages/atlas/atlasHubModel.ts.", + "src/mobile/screens/atlas/hub/MHubBadges.tsx": "Phone layout of one tab of the Atlas hub sheet (MAtlasHub); the desktop draws the same tab inside AtlasGlobePassport with its own markup, and both read the state of useAtlasGlobe and the derived values of pages/atlas/atlasHubModel.ts.", + "src/mobile/screens/atlas/hub/MHubWishlist.tsx": "Phone layout of one tab of the Atlas hub sheet (MAtlasHub); the desktop draws the same tab inside AtlasGlobePassport with its own markup, and both read the state of useAtlasGlobe and the derived values of pages/atlas/atlasHubModel.ts.", + "src/mobile/screens/atlas/hub/MHubTours.tsx": "Phone layout of one tab of the Atlas hub sheet (MAtlasHub); the desktop draws the same tab inside AtlasGlobePassport with its own markup, and both read the state of useAtlasGlobe and the derived values of pages/atlas/atlasHubModel.ts.", + "src/mobile/screens/atlas/hub/MHubTravellers.tsx": "Phone layout of one tab of the Atlas hub sheet (MAtlasHub); the desktop draws the same tab inside AtlasGlobePassport with its own markup, and both read the state of useAtlasGlobe and the derived values of pages/atlas/atlasHubModel.ts.", + "src/mobile/screens/atlas/hub/mHubKit.tsx": "The phone's building blocks for the Atlas hub tabs on the --m-* tokens; markup only, the desktop has its own kit in pages/atlas/atlasHubKit.tsx.", + "src/mobile/screens/atlas/hub/MHubDawarich.tsx": "Phone layout of the Atlas hub's Dawarich tab; the desktop tab AtlasGlobeDawarich draws its own markup over the same useDawarichAtlas hook.", + "src/mobile/screens/atlas/MAtlasLayersSheet.tsx": "The globe's layers as a phone sheet (switches and the colouring); the desktop opens GlobeLayersDialog over the same useAtlasGlobe state.", + "src/mobile/screens/atlas/MAtlasCountrySheets.tsx": "The globe's country action card and country sheet on the phone; the desktop opens GlobeCountryDialogs over the same useAtlasGlobe state and useAtlasCountryActions." } } diff --git a/client/scripts/i18n-keys.mjs b/client/scripts/i18n-keys.mjs index 0e23662c9..7a97d1245 100644 --- a/client/scripts/i18n-keys.mjs +++ b/client/scripts/i18n-keys.mjs @@ -72,8 +72,8 @@ const UNUSED_BASELINE = join(HERE, 'i18n-unused-baseline.json'); /** * Where else a translation key can be named: the server sends keys for the * client to translate (system notices, notification channels), the plugin - * SDK names the ones plugin surfaces use, and the shared book engine names - * its layout templates. Read only to find which en keys are reached. + * SDK names the ones plugin surfaces use, the shared book engine names + * its layout templates and the Atlas badge rules their titles. Read only to find which en keys are reached. */ export const REFERENCE_ROOTS = [ // The address screen the native apps ship (vite.native.config.js): its own @@ -82,6 +82,8 @@ export const REFERENCE_ROOTS = [ join(HERE, '..', '..', 'server', 'src'), join(HERE, '..', '..', 'plugin-sdk', 'src'), join(HERE, '..', '..', 'shared', 'src', 'book'), + // The Atlas badge rules name each badge's title and description keys. + join(HERE, '..', '..', 'shared', 'src', 'atlas'), ]; /** How many en keys a template may reach and still pass without an entry below. */ diff --git a/client/scripts/layers-baseline.json b/client/scripts/layers-baseline.json index ca9772de9..2c14dd2da 100644 --- a/client/scripts/layers-baseline.json +++ b/client/scripts/layers-baseline.json @@ -13,7 +13,6 @@ "src/components/Collections/ListEditorModal.tsx": 1, "src/components/Collections/MSaveToCollectionSheet.tsx": 3, "src/components/Dawarich/DawarichAcceptDialog.tsx": 3, - "src/components/Dawarich/DawarichAtlasDialog.tsx": 3, "src/components/Dawarich/DawarichSuggestionsPanel.tsx": 1, "src/components/Journey/ContributorInviteDialog.tsx": 1, "src/components/Journey/JourneyDetailPageAddTripDialog.tsx": 1, diff --git a/client/scripts/offline-baseline.json b/client/scripts/offline-baseline.json index ad9ce83dc..5f90144dd 100644 --- a/client/scripts/offline-baseline.json +++ b/client/scripts/offline-baseline.json @@ -42,7 +42,6 @@ "src/components/Collections/useSaveTripPlacesToList.ts", "src/components/Collections/useTripCopyPicker.ts", "src/components/Dashboard/useCollectionLists.ts", - "src/components/Dawarich/DawarichAtlasDialog.tsx", "src/components/Files/FileManagerAuthedImg.tsx", "src/components/Files/FileManagerImageLightbox.tsx", "src/components/Files/docsync/useConflicts.ts", @@ -130,7 +129,6 @@ "src/pages/OAuthAuthorizePage.tsx", "src/pages/admin/useAdmin.ts", "src/pages/admin/useNotificationDefaults.ts", - "src/pages/atlas/useAtlas.ts", "src/pages/atlas/useAtlasCountryActions.ts", "src/pages/collections/useCollections.ts", "src/pages/dashboard/useDashboard.ts", diff --git a/client/scripts/rtl-baseline.json b/client/scripts/rtl-baseline.json index 78a6ade35..d3fb5e621 100644 --- a/client/scripts/rtl-baseline.json +++ b/client/scripts/rtl-baseline.json @@ -90,7 +90,6 @@ "pages/VacayPage.tsx": 1, "pages/admin/AdminNotificationsTab.tsx": 1, "pages/admin/AdminSettingsTab.tsx": 1, - "pages/atlas/AtlasLayerToggle.tsx": 1, "pages/sharedTrip/SharedMap.tsx": 4, "styles/collections.css": 1, "styles/studio.css": 7, diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.json index 90827cfe9..621a1bd7c 100644 --- a/client/scripts/size-baseline.json +++ b/client/scripts/size-baseline.json @@ -20,7 +20,6 @@ "src/pages/JourneyDetailPage.test.tsx": 3886, "src/pages/LoginPage.tsx": 1273, "src/pages/TripPlannerPage.tsx": 1127, - "src/pages/atlas/useAtlas.ts": 1207, "src/pages/tripPlanner/useTripPlanner.roadtrip.test.tsx": 3518, "src/pages/tripPlanner/useTripPlanner.test.tsx": 3267, "src/styles/studio.css": 1918 diff --git a/client/scripts/strict-baseline.json b/client/scripts/strict-baseline.json index 8a4ffd8ea..63a5e4f89 100644 --- a/client/scripts/strict-baseline.json +++ b/client/scripts/strict-baseline.json @@ -117,7 +117,6 @@ "src/pages/VacayPage.tsx": 1, "src/pages/admin/useAdmin.ts": 4, "src/pages/atlas/atlasModel.ts": 2, - "src/pages/atlas/useAtlas.ts": 9, "src/pages/collections/collectionsModel.ts": 1, "src/pages/journeyDetail/useJourneyDetail.ts": 3, "src/pages/sharedTrip/SharedPlanView.tsx": 1, diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index e4275bea6..82e739675 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -21,7 +21,6 @@ "components/Collections/CollectionHero.tsx": 1, "components/Collections/MSaveToCollectionSheet.tsx": 12, "components/Collections/StatusBadge.tsx": 4, - "components/Dawarich/DawarichAtlasDialog.tsx": 3, "components/Files/FileManagerAvatarChip.tsx": 1, "components/Files/FileManagerImageLightbox.tsx": 8, "components/Journey/ContributorInviteDialog.tsx": 76, @@ -164,9 +163,7 @@ "mobile/screens/admin/MAdminUsersSection.tsx": 13, "mobile/screens/admin/MApiProviderBlocks.tsx": 10, "mobile/screens/atlas/MAtlas.tsx": 5, - "mobile/screens/atlas/MAtlasBucketSheet.tsx": 14, "mobile/screens/atlas/MAtlasCountryPopup.tsx": 11, - "mobile/screens/atlas/MAtlasSearch.tsx": 5, "mobile/screens/atlas/MAtlasStatsCard.tsx": 3, "mobile/screens/collections/MCollAddSheet.tsx": 6, "mobile/screens/collections/MCollCategoryPicker.tsx": 2, @@ -297,7 +294,6 @@ "pages/ResetPasswordPage.tsx": 23, "pages/TripPlannerPage.tsx": 7, "pages/VacayPage.tsx": 13, - "pages/atlas/useAtlas.ts": 2, "pages/collections/useCollections.ts": 1, "pages/login/MfaCodeStep.tsx": 4, "pages/sharedTrip/SharedChrome.tsx": 2, diff --git a/client/scripts/theme-disable-baseline.json b/client/scripts/theme-disable-baseline.json index b9692c6be..4a856327b 100644 --- a/client/scripts/theme-disable-baseline.json +++ b/client/scripts/theme-disable-baseline.json @@ -11,7 +11,6 @@ "components/Collections/ImportCollectionModal.tsx": 1, "components/Collections/MoveToListModal.tsx": 1, "components/Collections/SaveTripPlacesToListModal.tsx": 1, - "components/Dawarich/DawarichAtlasSidePanel.tsx": 1, "components/Files/FileManagerImageLightbox.tsx": 1, "components/Files/FileManagerRow.tsx": 3, "components/Files/FileManagerToolbar.tsx": 1, @@ -58,7 +57,6 @@ "mobile/components/MWalletButton.tsx": 1, "mobile/screens/atlas/MAtlas.tsx": 1, "mobile/screens/atlas/MAtlasCountryPopup.tsx": 2, - "mobile/screens/atlas/MAtlasSearch.tsx": 1, "mobile/screens/collections/MCollEditSheet.tsx": 2, "mobile/screens/collections/MCollPlaceSheet.tsx": 2, "mobile/screens/collections/MCollShareSheet.tsx": 1, diff --git a/client/src/App.tsx b/client/src/App.tsx index f60363385..d9ff8b209 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -320,7 +320,7 @@ function RouteFallback() { } export default function App() { - const { loadUser, isAuthenticated, demoMode, setManaged, setDemoMode, setDevMode, setIsPrerelease, setAppVersion, setHasMapsKey, setHasAmapKey, setPlacesProvider, setServerTimezone, setAppRequireMfa, setTripRemindersEnabled, setPlacesPhotosEnabled, setPlacesAutocompleteEnabled, setPlacesDetailsEnabled, setPlacesEnrichEnabled, setPlaceShadowEnabled } = useAuthStore() + const { loadUser, isAuthenticated, demoMode, setManaged, setDemoMode, setDevMode, setIsPrerelease, setAppVersion, setHasMapsKey, setHasAmapKey, setPlacesProvider, setServerTimezone, setAppRequireMfa, setTripRemindersEnabled, setAtlasCompareEnabled, setPlacesPhotosEnabled, setPlacesAutocompleteEnabled, setPlacesDetailsEnabled, setPlacesEnrichEnabled, setPlaceShadowEnabled } = useAuthStore() const { loadSettings } = useSettingsStore() const { loadAddons } = useAddonStore() const { loadPlugins } = usePluginStore() @@ -351,7 +351,7 @@ export default function App() { }, Math.min(30_000, 1_000 * 2 ** attempt)) }) }) - fetchAppConfig(0).then(async (config: { managed?: boolean; demo_mode?: boolean; dev_mode?: boolean; is_prerelease?: boolean; has_maps_key?: boolean; has_amap_key?: boolean; places_provider?: string; version?: string; timezone?: string; require_mfa?: boolean; trip_reminders_enabled?: boolean; places_photos_enabled?: boolean; places_autocomplete_enabled?: boolean; places_details_enabled?: boolean; places_enrich_enabled?: boolean; place_shadow_enabled?: boolean; max_upload_mb?: number; permissions?: Record }) => { + fetchAppConfig(0).then(async (config: { managed?: boolean; demo_mode?: boolean; dev_mode?: boolean; is_prerelease?: boolean; has_maps_key?: boolean; has_amap_key?: boolean; places_provider?: string; version?: string; timezone?: string; require_mfa?: boolean; trip_reminders_enabled?: boolean; atlas_compare_enabled?: boolean; places_photos_enabled?: boolean; places_autocomplete_enabled?: boolean; places_details_enabled?: boolean; places_enrich_enabled?: boolean; place_shadow_enabled?: boolean; max_upload_mb?: number; permissions?: Record }) => { setManaged(!!config?.managed) setDemoMode(!!config?.demo_mode) if (config?.dev_mode) setDevMode(true) @@ -363,6 +363,7 @@ export default function App() { if (config?.timezone) setServerTimezone(config.timezone) if (config?.require_mfa !== undefined) setAppRequireMfa(!!config.require_mfa) if (config?.trip_reminders_enabled !== undefined) setTripRemindersEnabled(config.trip_reminders_enabled) + if (config?.atlas_compare_enabled !== undefined) setAtlasCompareEnabled(config.atlas_compare_enabled) if (config?.places_photos_enabled !== undefined) setPlacesPhotosEnabled(config.places_photos_enabled) if (config?.places_autocomplete_enabled !== undefined) setPlacesAutocompleteEnabled(config.places_autocomplete_enabled) if (config?.places_details_enabled !== undefined) setPlacesDetailsEnabled(config.places_details_enabled) diff --git a/client/src/components/Admin/AddonManager.tsx b/client/src/components/Admin/AddonManager.tsx index da038115c..be09df170 100644 --- a/client/src/components/Admin/AddonManager.tsx +++ b/client/src/components/Admin/AddonManager.tsx @@ -1,6 +1,6 @@ import type { ComponentType } from 'react' import { useTranslation } from '../../i18n' -import { Puzzle, ListChecks, Wallet, FileText, CalendarDays, Globe, Briefcase, Image, Terminal, Link2, Compass, BookOpen, Sparkles, Luggage, Plane, Bookmark, Users, Loader2, Mountain, CarFront, Radar } from 'lucide-react' +import { Puzzle, ListChecks, Wallet, FileText, CalendarDays, Globe, Briefcase, Image, Terminal, Link2, Compass, BookOpen, Sparkles, Luggage, Plane, Bookmark, Users, Loader2, Mountain, CarFront, Radar, Trophy } from 'lucide-react' import EmptyState from '../shared/EmptyState' import DawarichIcon from '../shared/DawarichIcon' import AirTrailIcon from '../shared/AirTrailIcon' @@ -94,6 +94,8 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking, wandererOffered, toggleToursWanderer, mapSwitches, + atlasCompare, + toggleAtlasCompare, } = useAddonManager() if (loading) { return ( @@ -109,6 +111,17 @@ export default function AddonManager({ bagTrackingEnabled, onToggleBagTracking, * parent as shelf rows, and each shelf only shows while its parent is on — * a provider toggled under a disabled Journey would hit the server's 409. */ const shelfFor = (addon: Addon) => { + if (addon.id === 'atlas' && addon.enabled) { + return ( + } + title={t('admin.atlasCompare.title')} + description={t('admin.atlasCompare.subtitle')} + enabled={atlasCompare} + onToggle={() => void toggleAtlasCompare()} + /> + ) + } if (addon.id === 'packing' && addon.enabled && onToggleBagTracking) { return ( s.atlasCompareEnabled); + const setAtlasCompare = useAuthStore((s) => s.setAtlasCompareEnabled); const loadAddons = async () => { try { @@ -105,6 +108,11 @@ export function useAddonManager() { void refreshGlobalAddons(); toast.success(t('admin.addons.toast.updated')); }; + /** Whether travellers on this instance see the Atlas ranking and each other's profiles. */ + const toggleAtlasCompare = () => + flipToursSwitch(atlasCompare, setAtlasCompare, (enabled) => + authApi.updateAppSettings({ atlas_compare_enabled: enabled }) + ); const toggleToursWanderer = () => flipToursSwitch(toursWanderer, setToursWanderer, wandererAdminApi.update); /** The maps and the piste router Tours offers on their operators' terms, one switch each (MAP-01, BIK-06, SKI-02). */ const mapSwitches = [ @@ -167,5 +175,7 @@ export function useAddonManager() { wandererOffered, toggleToursWanderer, mapSwitches, + atlasCompare, + toggleAtlasCompare, }; } diff --git a/client/src/components/Atlas/tourActivity/AtlasTourActivityPane.test.tsx b/client/src/components/Atlas/tourActivity/AtlasTourActivityPane.test.tsx deleted file mode 100644 index 29b8b26ac..000000000 --- a/client/src/components/Atlas/tourActivity/AtlasTourActivityPane.test.tsx +++ /dev/null @@ -1,150 +0,0 @@ -// FE-STA2-PANE-001 to FE-STA2-PANE-006 -// STA-02: the Atlas tab of the user's own tour activities: the distance large -// with how many tours at its corner, the climb, the types, what the numbers -// rest on, and the full list in a dialog. -import userEvent from '@testing-library/user-event'; -import { summarizeTourActivities, type TourActivityStatsEntry, type TourActivityStatsResponse } from '@trek/shared'; -import { beforeEach, describe, expect, it, vi } from 'vitest'; -import { buildSettings } from '../../../../tests/helpers/factories'; -import { render, screen } from '../../../../tests/helpers/render'; -import { resetAllStores, seedStore } from '../../../../tests/helpers/store'; -import { useSettingsStore } from '../../../store/settingsStore'; -import { AtlasTourActivityPane } from './AtlasTourActivityPane'; -import type { TourActivityStats } from './useTourActivityStats'; - -const hook = vi.hoisted(() => ({ current: null as unknown, active: [] as boolean[] })); -vi.mock('./useTourActivityStats', () => ({ - useTourActivityStats: (active: boolean) => { - hook.active.push(active); - return hook.current; - }, -})); - -const TODAY = '2026-10-20'; - -function entry(overrides: Partial = {}): TourActivityStatsEntry { - return { - place_id: 1, - name: 'Ridge', - tour_type: 'hike', - trip: { id: 5, title: 'Alps' }, - derived_from_place_id: null, - date: '2026-07-02', - basis: 'plan', - track: null, - day_count: 1, - distance_km: 12, - ascent_m: 800, - descent_m: 790, - excluded: false, - ...overrides, - }; -} - -function statsOf(data: TourActivityStatsResponse | null, overrides: Partial = {}) { - const stats: TourActivityStats = { - status: data ? 'ready' : 'loading', - data, - summary: data ? summarizeTourActivities(data.entries, { today: TODAY }) : null, - period: 'all', - setPeriod: vi.fn(), - periods: ['all', 'thisYear', 'last12'], - type: 'all', - setType: vi.fn(), - types: ['all', 'hike', 'kayak'], - pending: new Set(), - setExcluded: vi.fn().mockResolvedValue(undefined), - retry: vi.fn(), - ...overrides, - }; - hook.current = stats; - return stats; -} - -const data: TourActivityStatsResponse = { - entries: [ - entry(), - entry({ place_id: 2, name: 'Summit', date: '2026-08-01', distance_km: 20.5, ascent_m: 1200, descent_m: 1200 }), - entry({ - place_id: 3, - name: 'Lake', - tour_type: 'kayak', - basis: 'track', - track: { place_id: 9, name: 'Watch' }, - distance_km: 8, - ascent_m: null, - descent_m: null, - }), - ], - uncounted: { unassigned: 0, undated: 1 }, -}; - -beforeEach(() => { - resetAllStores(); - vi.clearAllMocks(); - hook.active = []; - seedStore(useSettingsStore, { settings: buildSettings({ distance_unit: 'metric' }) }); -}); - -describe('AtlasTourActivityPane', () => { - it('FE-STA2-PANE-001: follows whether the tab is shown, silent before, loading until the read is there', () => { - statsOf(null, { status: 'idle' }); - const { rerender } = render(); - expect(hook.active).toEqual([false]); - expect(screen.queryByRole('status')).not.toBeInTheDocument(); - statsOf(null); - rerender(); - expect(hook.active).toEqual([false, true]); - expect(screen.getByRole('status')).toHaveTextContent('Loading'); - }); - - it('FE-STA2-PANE-002: shows the distance large with the tour count at its corner, and the climb', () => { - statsOf(data); - render(); - expect(screen.getByTestId('atlas-tour-activity-distance')).toHaveTextContent('40.5km'); - expect(screen.getByTestId('atlas-tour-activity-count')).toHaveTextContent('3'); - expect(screen.getByTestId('atlas-tour-activity-ascent')).toHaveTextContent('2000m'); - expect(screen.getByTestId('atlas-tour-activity-type-hike')).toHaveTextContent('2'); - expect(screen.getByTestId('atlas-tour-activity-type-kayak')).toHaveTextContent('8 km'); - }); - - it('FE-STA2-PANE-003: says what the numbers rest on and what does not count', () => { - statsOf(data); - render(); - expect(screen.getByTestId('tour-activity-basis-plan')).toHaveTextContent('Planned2'); - expect(screen.getByTestId('tour-activity-basis-track')).toHaveTextContent('Recorded1'); - expect(screen.getByTestId('tour-activity-undated')).toHaveTextContent('1'); - }); - - it('FE-STA2-PANE-004: one type chosen leaves the type columns out; nothing done says so', () => { - statsOf(data, { type: 'hike', summary: summarizeTourActivities(data.entries, { today: TODAY, type: 'hike' }) }); - const { rerender } = render(); - expect(screen.queryByTestId('atlas-tour-activity-type-hike')).not.toBeInTheDocument(); - - statsOf(data, { summary: summarizeTourActivities(data.entries, { today: TODAY, from: '2027-01-01' }) }); - rerender(); - expect(screen.getByText('No completed tours in this period')).toBeInTheDocument(); - expect(screen.queryByRole('button', { name: 'Show tours' })).not.toBeInTheDocument(); - }); - - it('FE-STA2-PANE-005: the full list opens in the dialog', async () => { - statsOf(data); - const user = userEvent.setup(); - render(); - await user.click(screen.getByRole('button', { name: 'Show tours' })); - expect(screen.getByRole('heading', { name: 'My tour activities' })).toBeInTheDocument(); - expect(screen.getByTestId('tour-activity-list')).toBeInTheDocument(); - }); - - it('FE-STA2-PANE-006: offline and failed reads say so, a failed one with a retry', async () => { - statsOf(null, { status: 'offline' }); - const { rerender } = render(); - expect(screen.getByText(/needs a connection/i)).toBeInTheDocument(); - - const failed = statsOf(null, { status: 'error' }); - rerender(); - expect(screen.getByRole('alert')).toHaveTextContent('Tour activities could not be loaded'); - await userEvent.setup().click(screen.getByRole('button', { name: 'Try again' })); - expect(failed.retry).toHaveBeenCalled(); - }); -}); diff --git a/client/src/components/Atlas/tourActivity/AtlasTourActivityPane.tsx b/client/src/components/Atlas/tourActivity/AtlasTourActivityPane.tsx deleted file mode 100644 index 64fb9769b..000000000 --- a/client/src/components/Atlas/tourActivity/AtlasTourActivityPane.tsx +++ /dev/null @@ -1,223 +0,0 @@ -import type { TourActivitySummary } from '@trek/shared'; -import { Footprints, ListOrdered } from 'lucide-react'; -import { useState } from 'react'; -import { useTranslation } from '../../../i18n'; -import type { DistanceUnit } from '../../../types'; -import { fs } from '../../shared/DialogShell'; -import { Tooltip } from '../../shared/Tooltip'; -import { CardAction, InfoDot } from '../../Tours/tourParts'; -import { ActivityFilters, ActivityStatusLine, BasisBadges, UncountedBadges } from './tourActivityParts'; -import { distanceReading, heightReading, typeIcon, typeLabel, useDistanceUnit } from './tourActivityReading'; -import { TourActivityStatsDialog } from './TourActivityStatsDialog'; -import { splitMeasure } from './tourActivityStatsModel'; -import { useTourActivityStats, type TourActivityStats } from './useTourActivityStats'; - -/** The wash the hero tile sits on, as the Atlas numbers do: the text colour, faintly, over the glass. */ -const HERO_TINT = 'color-mix(in srgb, var(--text-primary) 7%, transparent)'; -/** How many types the strip names before the dialog takes over. */ -const STRIP_TYPES = 3; -const EYEBROW = 'mt-1.5 whitespace-nowrap font-semibold uppercase tracking-wide text-content-faint'; - -function Divider() { - return